Page 2 of 2

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 5:52 pm
by Perkin
Is there any way to use *.png images with this?
I've tried and although they load and the buttons are created, the images are missing, but text is offset.

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 6:04 pm
by Perkin
@Rook - For text overlaying an Icon, I've managed it.

Adding a few line to the 'ButtonGadgetEx.pbi' file.

Add

Code: Select all

#BIGE_Overlay
in the Enumeration section.

and add

Code: Select all

          Case #BIGE_Overlay
            ImageX = (Width-ImageWidth(*Prop\ImageID))/2
            ImageY = (Height-ImageHeight(*Prop\ImageID))/2
            TextX = (Width-SZ\cx)/2
            TextY = (Height-FontHeight)/2
into the WndProc() procedure in the Select *Prop\ImagePosition section (Around line 160)

Then use the #BIGE_Overlay constant when creating your gadget.

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 6:50 pm
by Inf0Byt3
It should work with any image format in theory. The only problem is that I used the DrawIconEx_ API to draw the images on the buttons. This is because we need to draw on a system-offered HDC (which we get by using GetDC_). In order to draw other image formats we should use a function like PB's internal DrawImage(), but this function can't draw on HDCs, it can only draw on PureBasic objects. I know that when we still used PB3.94 some people played with the PB internals in such way that they could force the DrawImage() function to draw on such HDCs but I couldn't get it to work after the drawing lib was rewritten in latter PB versions.

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 6:56 pm
by Perkin
I've discovered Trond' thread, which has the ability to use png's
http://www.purebasic.fr/english/viewtop ... 12&t=41045

So I'm going to have a play, and see if I can have the best abilities of both.

Thanks.

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 6:59 pm
by Perkin
I've also noticed, when pressing a ButtonGadgetEx, the image is not displayed.
Is that fixable?

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 7:03 pm
by Inf0Byt3
That's rather strange, could you give me more info about that? Does the example in the archive work well for you?

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 7:32 pm
by Perkin
When running example, button 2 is disabled (as programmed), button 1 is displayed as expected, but when 'pressing' (and holding left mouse button) button1, the image disappears, when releasing LMB the image re-appears.

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 7:35 pm
by Perkin
:oops:

My Mistake :roll: , I must have changed something in the include which broke it :oops: .
I re-extracted them both and now works as it should.

Sorry!

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.3

Posted: Wed Jun 02, 2010 7:48 pm
by Inf0Byt3
:D

No problem at all, i'm glad it's ok. I thought that maybe it was an OS problem (I use XP here) :D.

BTW, i uploaded a new version online that supports using your own callback... Check the example to see how to use it :).

Re: ButtonGadgetEx.pbi (buttons with image and text), v0.4

Posted: Wed Jun 02, 2010 8:06 pm
by Perkin
Thanks.