Adding an image to a push button
BlitzMax Forums/BlitzMax Beginners Area/Adding an image to a push button
| ||
Hello!!! I have been trying to add an image to a button, but the image never appears there. Here is what I am doing: Import MaxGui.Drivers Global image_open:TPixmap = LoadPixmap("images/open.png") Global window:TGadget = CreateWindow( "ZX Life Shield Professional", 100, 100, 640, 480, Null, WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_CLIENTCOORDS) Global panel_top:TGadget=CreatePanel(6,16+8-4-2,632-4,67+16+16-16-4-2-4-8-4,window,PANEL_RAISED) Global panel_top_snapshot1_ld_button:TGadget=CreateButton("",2+30+6,16+4+16-4-1,16+1,16+1,panel_top,BUTTON_PUSH) SetGadgetPixmap(panel_top_snapshot1_ld_button,image_open,GADGETPIXMAP_ICON|GADGETPIXMAP_NOTEXT) WaitKey What am I doing wrong? Thanks! Kind regards, >Marco A.G.Pinto -------------------- |
| ||
SuperStrict Import MaxGui.Drivers Global image_open:TPixmap = LoadPixmap("..\docs\src\brllogo.png") Global window:TGadget = CreateWindow( "ZX Life Shield Professional", 100, 100, 640, 480, Null, WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_CLIENTCOORDS) Global panel_top:TGadget=CreatePanel(6,16+8-4-2,632-4,67+16+16-16-4-2-4-8-4,window,PANEL_RAISED) Global panel_top_snapshot1_ld_button:TGadget=CreateButton("",10,5,64,48,panel_top,BUTTON_PUSH) SetGadgetPixmap(panel_top_snapshot1_ld_button,image_open,GADGETPIXMAP_ICON|GADGETPIXMAP_NOTEXT) WaitKey Are you sure about the image path? To me it works |
| ||
@degac Both don't work here. I can confirm that the image is indeed loaded and applied to the button, but it doesn't show up. Using Win7 x64. EDIT: Tried with Vista x86 and it still doesnt work. Is there an update or redraw command required? Last edited 2012 |
| ||
I am too using Windows 7 x64 and it doesn't work. Maybe a bug in BlitzMax? |
| ||
Tried it and it didn't work. Updated to the latest version on the Account/Product updates page and it worked fine. |
| ||
I'm using 1.45 already. |
| ||
Unfortunately MaxGUI has never supported images on buttons in any reliable manner and it is wrong of the documentation to suggest SetGadgetPixmap should be used on anything but Panels. If you must use such non standard customizations as buttons with pictures all over them then use a MaxGui Panel with the active flag set. |
| ||
@skidracer: Could you give an example of how to do it? Thanks! Kind regards, >Marco A.G.Pinto -------------------- |
| ||
Buaaaaaaaaa... no example so far :( I wonder if it wouldn't be easier to release an update that works with images? I have been using other Windows programming language and it accepts images in buttons, so, how is it possible that this doesn't work in BlitzMax? I am converting "ZX Life Shield Pro" from DarkBASICPro (blugui plugin) to BlitzMax. :( Kind regards, >Marco A.G.Pinto -------------------- |
| ||
Hi Marco, if you don't find a way to extend the button gadget in MaxGUI to receive images, try using other solutions: - wxMax (free, by Brucey) - ProGUI (commercial, by PrincieD) PS: I can't attest if ProGUI supports button images, but wxMax certainly does. |
| ||
I misread your earlier post, I didn't realise you were waiting on an example... As you can see I changed the panel color (and sometimes position) according to its messages, you could easily change the gadget pixmap instead. The important thing is to make the panel "active" or it won't emit any messages. Cheers |