Sign in to follow this  
Followers 0
Orion122

Problem with image on buttons

9 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstantsEx.au3> 
#include <ButtonConstants.au3> 
#include <WindowsConstants.au3>    

GUICreate("Toolbar", 250, 250) 
GUISetState() 
$b=GUICtrlCreateButton("", 10, 170, 100, 70, $BS_ICON) 
GUICtrlSetImage($b, @DesktopDir & "\mozilla-firefox1.jpg", 1)
while 1     
sleep(1000) 
WEnd

When I run script the button is clear, without image. I tried with "shell32.dll" as filename and it works. I didn't make a func attached to button and other script parts cuz i discovered this problem and focused to solve it. Please help. I have Vista Home Premium

post-53552-12554531654769_thumb.jpg

Edited by Orion122

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3> 
#include <ButtonConstants.au3> 
#include <WindowsConstants.au3>  

Opt("GUIOnEventMode", 1)  

FileInstall("C:\Users\MARCIN\Desktop\mozilla-firefox1.jpg", "C:\Users\MARCIN\Desktop\mozilla-firefox1")   

GUICreate("Toolbar", 250, 250) 
GUISetState() 
$b=GUICtrlCreateButton("MOZILLA", 10, 170, 100, 70, $BS_BITMAP) 
GUICtrlSetImage($b, "C:\Users\MARCIN\Desktop\mozilla-firefox1") 
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
  
while 1     
sleep(1000) 
WEnd   

func close()    
Exit 
EndFunc

I tried to write smth like this. I'm only reading about UDF. I'd be very thankful if u wrote here working script, ofc it's not na problem for u. I'm new in programming. Path to jpg is: C:\Users\MARCIN\Desktop\mozilla-firefox1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3> 
#include <WindowsConstants.au3>  

Opt("GUIOnEventMode", 1)  

FileInstall("C:\Users\MARCIN\Desktop\mozilla-firefox1.jpg", @TempDir & "\mozilla-firefox1.jpg")   

GUICreate("Toolbar", 250, 250) 
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$b=GUICtrlCreateButton("MOZILLA", 10, 170, 100, 70, $BS_BITMAP) 
GUICtrlSetImage($b, @TempDir & "\mozilla-firefox1.jpg") 
GUISetState() 
  
while 1     
 sleep(1000) 
WEnd   

func close()    
 Exit 
EndFunc

Edited by Zedna

Share this post


Link to post
Share on other sites

Don't work. Did u check it on ur comp? It may be a stupid question but, Is there any requirements for jpg to use in autoit?

Share this post


Link to post
Share on other sites

Don't work. Did u check it on ur comp? It may be a stupid question but, Is there any requirements for jpg to use in autoit?

Now I tested it and it works fine with bmp, not with jpg.

So convert your jpg image to bmp.

Share this post


Link to post
Share on other sites

Should I use @TempDir? I have this file on desktop so maybe @DesktopDir? I covered it to bmp and launched ur script and it don't work. Maybe my comp is haunted :)

Share this post


Link to post
Share on other sites

Should I use @TempDir? I have this file on desktop so maybe @DesktopDir? I covered it to bmp and launched ur script and it don't work. Maybe my comp  is haunted :)

Try it without FileInstall() first to see base concept is working.

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3> 
#include <WindowsConstants.au3>  

Opt("GUIOnEventMode", 1)  

;~ FileInstall("C:\Users\MARCIN\Desktop\mozilla-firefox1.bmp", @TempDir & "\mozilla-firefox1.bmp")   

GUICreate("Toolbar", 250, 250) 
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$b=GUICtrlCreateButton("MOZILLA", 10, 170, 100, 70, $BS_BITMAP) 
;~ GUICtrlSetImage($b, @TempDir & "\mozilla-firefox1.bmp") 
GUICtrlSetImage($b, "C:\Users\MARCIN\Desktop\mozilla-firefox1.bmp") 
GUISetState() 
  
while 1     
 sleep(1000) 
WEnd   

func close()    
 Exit 
EndFunc

Share this post


Link to post
Share on other sites

It works! xD Thanks a lot! So it's all about format

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0