• Welcome to Theos PowerBasic Museum 2017.

XPButton

Started by Joop Blokker, January 20, 2009, 10:24:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Joop Blokker

Hello José!

I must have a programmer's block.. Putting a .BMP image on an XPButton FROM FILE works as a charm, thanks for all your work!

How do I put a .BMP image that is in a resource file   on an XPbutton?

XPButton_SetBitmap asks for a handle to the bitmap and by Jove... I must be doing something very wrong, 'cause it doesn't work for me. Any idea how to get the correct Handle?

Thanks for your time!
Joop.
Have fun, no matter what..

José Roca

 
The XPButtonDemo.bas example, included in XPButtonDemo.zip ( http://www.jose.it-berater.org/smfforum/index.php?topic=2771.0 ) uses icons from a resource file.

If you want to use bitmaps instead, change


XPButton_SetIcon(GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), LoadImage(ghInstance, BYVAL 101, %IMAGE_ICON, 0, 0, %LR_DEFAULTCOLOR), %XPBI_NORMAL, %FALSE)


to


XPButton_SetBitmap(GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), LoadImage(ghInstance, BYVAL 101, %IMAGE_BITMAP, 0, 0, %LR_DEFAULTCOLOR), %XPBI_NORMAL, %FALSE)


Of course, BYVAL 101 will be BYVAL <number that you will use to identify the bitmap in your resource file>.

Joop Blokker

Thank you José!

Of course that is the way to do it, I must have had a Senior moment... :D

I know that the button text color normally cannot be set, yet I was hoping that XPButton would have a work-around.

I Googled and found this:  http://www.freevbcode.com/ShowCode.asp?ID=3472 where they claim "Caption with selectable font and color". Since I started with PB a long time ago, I have not touched VB6 - in fact, I did not bother installing VB6 on a new pc...  I wonder if DrawThemeText is the way to go, let me tinker a bit more...

Thanks again!
Joop. 
Have fun, no matter what..

José Roca

 
Quote
I know that the button text color normally cannot be set, yet I was hoping that XPButton would have a work-around.

Then it won't be a themed button. The color and font are defined by the visual style.

Quote
I Googled and found this:  http://www.freevbcode.com/ShowCode.asp?ID=3472 where they claim "Caption with selectable font and color".

It is not a themed button, but an owner draw button that mimics the appearance of an XP button.

Joop Blokker

Aaaah..!

Oh well, then icons will do the job. Thanks again for a great tool!

Ciao for now,
Joop.

Have fun, no matter what..

Joop Blokker

Hello José and all!

Thanks again for the great XPButton routine, my little program looks so much better now!

I ran into a little problem and I hope some one can give me a clue.  I know that the xpbutton text color cannot be changed. Okay, I can live with that. However it appears that the color of the text of a radio option button and the color of the text of a checkbox is always black (or XP Theme defined).

For a very good reason one of my Beta Testers has set the background color to black and the text color to yellow -- he is colorblind.  You see it coming: now the text of radio option buttons and checkboxes is "invisible".

Before I go and change the zillion option buttons and checkboxes by giving them an empty text string and adding that same text next to it in a label, I hope that there is an easier solution.

Thanks in advance,
Joop Blokker.

   
Have fun, no matter what..

Patrice Terrier

Did you considered to create a "button" superclass?

I have explained in detail how to use it in the "SDK programming" section there:
http://www.jose.it-berater.org/smfforum/index.php?board=151.0.
and look at the thread named: "Take control of your buttons"
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Joop Blokker

Hi José!

Thanks for the link, I'll try to figure out what you have been cookin' in SDK.  My program is 100,000 + lines of code in... DDT :D

Have a fine day,
Joop.
Have fun, no matter what..

Joop Blokker

So sorry....

Bonjour Patrice...!!!  Thanks for the link!

Joop.

Have fun, no matter what..

Patrice Terrier

Make sure also to try, all the SDK serie, 6, 7, 8, etc.

When it comes to interface design, nothing can beat SDK coding  ;D


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Joop Blokker

Bonjour Patrice, Ça baigne...?  :)

I believe you! I just bought Paul's FireFly with the intention to make a start with SDK-style programming. I am looking forward to learn a lot of new stuff and new ways to achieve things. My main product, which is developed in the past eight years is 100% DDT & API calls, I don't have the plan to redo the code in that monster to SDK. But NEW programs will be done while learning SDK style.... Wish me luck!

Have a great day,
Joop.
Have fun, no matter what..

Patrice Terrier

QuoteBut NEW programs will be done while learning SDK style.... Wish me luck!

The good news when learning SDK, is that you will emancipate yourself  ;)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com