News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

how to change background color of static control, and add text - resolved

Started by quarantined, August 14, 2022, 05:44:08 AM

Previous topic - Next topic

jj2007

Just for fun, attached a button, 42 lines of pure Masm32 SDK code.

And here is the point: In Win10, the button text is blue, and the word "Button" is not bold :sad:

jj2007

Quote from: hutch-- on August 24, 2022, 07:36:10 PMuse this technique but create the two bitmaps dynamically using GDI

Interesting idea :thumbsup:

Btw GetFontHandle (in your example): is that a regular Win32 API function, or is it part of the Masm64 SDK?

hutch--

Its just a wapper around a CreateFont API. Saves the extra typing.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

font_handle proc facename:QWORD,fHgt:QWORD,fWgt:QWORD

    invoke CreateFont,fHgt,0,0,0,fWgt,0,0,0,DEFAULT_CHARSET, \
                      OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
                      PROOF_QUALITY,DEFAULT_PITCH,facename
    ret

font_handle endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

jj2007


zedd151

Quote from: jj2007 on August 24, 2022, 07:58:32 PM
...the only missing bit is the text colour. And that's what's annoying me: SetTextColor should work, according to the documentation, but it doesn't. I've tried all stages, and it just refuses to function. SetBkMode works fine, for example :sad:
It doesn't work when creating/drawing it? Then try another method beside the messy looking custom functions.

@hutch, we hear you loud and clear. We know what bitmap buttons are, but they are not the solution to every button issue imo. I use them or at least something akin to the bitmap button examples in the Masm32 SDK for various projects already. For me the original intent of this topic has been solved and works for me. In my Tic Tac Toe game I use an alternative method yet. By getting the mouse coordinates and using BitBlt to change/insert bitmaps by clicking on predefined squares. Always more than one way to skin a cat.  :biggrin:

jj is off on a tangent in creating a custom drawn button which is much different than what the topic was about and what you propose.

Anyway hutch,  I asked in a PM for this topic to be moved out of the Campus for a reason. Since it has devolved from its original purpose, probably not Campus material...   :undecided:

jj2007

Quote from: Swordfish on August 25, 2022, 12:15:01 AMjj is off on a tangent in creating a custom drawn button which is much different than what the topic was about and what you propose.

Anyway hutch,  I asked in a PM for this topic to be moved out of the Campus for a reason. Since it has devolved from its original purpose, probably not Campus material...   :undecided:

Agreed. But check your original question - you basically asked for a pushbutton with special features ;-)

zedd151

Quote from: jj2007 on August 25, 2022, 01:30:16 AM
Agreed. But check your original question - you basically asked for a pushbutton with special features ;-)

Not to split hairs here, I never even mentioned 'pushbutton' or even 'button'. Even the topic title mentions what my intentions were i.e., 'static control'. I specifically did not want the pushbutton effect, so opted for using a static control, WM_CTRLCOLORSTATIC, SS_NOTIFY to achieve the original goal - just to clarify again. What I missed though was setting background mode to TRANSPARENT. oops
I will no longer post in this thread (again - I've said that before).  :tongue:

hutch--

 :biggrin:

> Anyway hutch,  I asked in a PM for this topic to be moved out of the Campus for a reason. Since it has devolved from its original purpose, probably not Campus material...

And I ignored it for a reason, a topic does not get moved on request when it remains in the right place. Playing with variations of creating buttons is exactly Campus material. This ain't no rocket science.  :tongue:

zedd151

Quote from: hutch-- on August 25, 2022, 05:52:35 AM
This ain't no rocket science.  :tongue:
Fair enough.
And I just said I will not be posting further here. You were just tempting me to post a reply. :tongue:

zedd151

#69
*snip*

After further testing found the code I was testing was faulty. Oops.


TimoVJL

In dialog static window SS_NOTIFY SS_BITMAP combination send messages.
SS_ICON sends too.
May the source be with you

NoCforMe

Quote from: TimoVJL on August 28, 2022, 07:49:08 PM
In dialog static window SS_NOTIFY SS_BITMAP combination send messages.
SS_ICON sends too.

Actually it's just SS_NOTIFY that enables messages; SS_BITMAP or SS_ICON have nothing to do with it. (Works for non-bitmap or -icon controls as well.)
Assembly language programming should be fun. That's why I do it.


NoCforMe

Instead of a big ol' "O" I get two thin vertical lines. Missing bitmap or something?
Assembly language programming should be fun. That's why I do it.

zedd151



Quote from: NoCforMe on September 02, 2022, 11:20:31 AM
Instead of a big ol' "O" I get two thin vertical lines. Missing bitmap or something?
Yes program uses "Segoe UI Emoji" font.  :rolleyes:
So, same issue here.
 
I'm not going to install MasmBasic just to change the font.   :undecided:
Nor am I going to look for or download that font either.

So now I can't play. I guess I'll have to hurry and finish my Tic Tac Toe game.  :biggrin: