Page 1 of 1
Using a .ico as image for ButtonImageGadget
Posted: Sat Sep 26, 2009 11:28 pm
by SFSxOI
is there a way to use an icon (.ico) as the image for ButtonImageGadget instead of a .bmp?
Re: Using a .ico as image for ButtonImageGadget
Posted: Sat Sep 26, 2009 11:41 pm
by netmaestro
Can't you "just do it"?
Code: Select all
If OpenWindow(0, 0, 0, 120, 100, "ButtonImage", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If LoadImage(0, #pb_compiler_home+"Examples\sources\data\cdplayer.ico")
ButtonImageGadget(0, 10, 10, 40, 40, ImageID(0))
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Solution provided courtesty Nike corporation, all rights reserved.
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 12:08 am
by SFSxOI
Thanks....but...I tried all that already. for some reason it wont use an icon. Since this is the first time i've tried to use an icon for this and could not get it to work I thought i'd ask. Oh well, back to the drawing board.
EDIT: DuH! never mind, just realized my problem...oh stupid stupid stupid. For "ImageID(#Image)" instead of putting a '0' (zero - there is only the one image) I had a 'O' (the uppercase O) that had been left there from a short experiment with using enumerated lables (in this case #Off_Image) when I deleted the rest of it and left the O for some reason, I had "ImageID(O)" and not "ImageID(0)" . DUH! ARGhhhhhhhhh! I though sure it didn't work, i'd never used icons for this purpose before and thought "The help says this should work, the forum says this should work, it just doesn't work." Looked at the darn thing for two hours on and off trying to get it to work.
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 12:22 am
by Sparkie
.ico works fine here.
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 12:29 am
by SFSxOI
read my editied post above, found the problem. Thanks for the help folks.
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 12:39 am
by netmaestro
Ok, now I'm confused. If your image# was 0 (zero) and you mistyped ImageID(O) (uppercase "o") then PureBasic would flag the error if you were using EnableExplicit. If you weren't using EnableExplicit and you didn't have another variable named "O" (uppercase "o") then it woud evaluate to zero and just work.
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 1:03 am
by SFSxOI
In the beginning had this:
ImageID(#Off_Image)
I changed it to this by editing the #Off_Image to O:
ImageID(O)
but in the LoadImage I had this:
LoadImage(0, "unknown.ico") (unknown.ico is the name as the icon in the same folder as the .pb file containing the code - thats a 0 (number zero)
And it would not work. When I changed the ImageID(O) to ImageID(0) it worked then. Yes, both would equate to zero, and no error was given. I wasn't using 'EnableExplicit' at the time, it just did not work even thought it should have evaluated to 0. Not having made this mistake before or using icons for this before I didn't realize that it should have worked anyway, and it didn't, so I just thought that the problem was the O because when I changed it to 0 it worked. OK, now I'm confused. Your saying it should have worked anyway? I just tried it again, doesn't work that way here, change it to 0 it works. Any suggestions? What am I doing wrong or is there a problem somewhere?
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 1:07 am
by netmaestro
..change it to 0 it works. Any suggestions?
Change it to 0

Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 2:00 am
by Sparkie
So you are saying this does not work for you...
Code: Select all
If OpenWindow(0, 0, 0, 120, 100, "ButtonImage", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If LoadImage(0, #PB_Compiler_Home+"Examples\sources\data\cdplayer.ico")
ButtonImageGadget(0, 10, 10, 40, 40, ImageID(o))
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Using a .ico as image for ButtonImageGadget
Posted: Sun Sep 27, 2009 2:34 am
by SFSxOI
OK, there was a problem after all. After exploring the possible fixes or trying to find the problem, recode, starting from scratch in case of some weird file corruption issue, etc....I finally removed and then re-installed PureBasic. Re-installing PureBasic solved the issue. Now it works properly. Didn't even realize there was a problem, haven't seen any other problems and would not have known about this one if it did not crop up like this. Thanks for the help folks.
No Sparkie, the ImageID(o) did not work until I re-installed PureBasic so it works now.