Using a .ico as image for ButtonImageGadget
Using a .ico as image for ButtonImageGadget
is there a way to use an icon (.ico) as the image for ButtonImageGadget instead of a .bmp?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Using a .ico as image for ButtonImageGadget
Can't you "just do it"?
Solution provided courtesty Nike corporation, all rights reserved.
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
EndIfBERESHEIT
Re: Using a .ico as image for ButtonImageGadget
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.
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.
Last edited by SFSxOI on Sun Sep 27, 2009 12:30 am, edited 2 times in total.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: Using a .ico as image for ButtonImageGadget
.ico works fine here.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
Re: Using a .ico as image for ButtonImageGadget
read my editied post above, found the problem. Thanks for the help folks.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Using a .ico as image for ButtonImageGadget
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.
BERESHEIT
Re: Using a .ico as image for ButtonImageGadget
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?
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?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
- netmaestro
- PureBasic Bullfrog

- Posts: 8453
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Using a .ico as image for ButtonImageGadget
Change it to 0..change it to 0 it works. Any suggestions?
BERESHEIT
Re: Using a .ico as image for ButtonImageGadget
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
EndIfWhat goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
Re: Using a .ico as image for ButtonImageGadget
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.
No Sparkie, the ImageID(o) did not work until I re-installed PureBasic so it works now.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
