FontColor and button - is it possible to change?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: FontColor and button - is it possible to change?

Post by KDJ »

srvet_claudio wrote:PD: A suggestion: should be used to draw the button the api functions that draw with the style of Windows active theme, otherwise the button is flat and the other controls are drawn by superimposing layers of images that recreate the active theme. This is the way that Windows draws controls with active theme.
Oh yes, I could use the functions:
OpenThemeData()
DrawThemeBackground()
DrawThemeText()
CloseThemeData()

But in this way I can not draw rounded/circular buttons.

It seems to me that the simplest solution of the colored buttons will be adding in HMG two properties for standard buttons:
TEXTCOLOR
BACKCOLOR
and processing WM_NOTIFY/NM_CUSTOMDRAW message.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: FontColor and button - is it possible to change?

Post by srvet_claudio »

KDJ wrote:
srvet_claudio wrote:PD: A suggestion: should be used to draw the button the api functions that draw with the style of Windows active theme, otherwise the button is flat and the other controls are drawn by superimposing layers of images that recreate the active theme. This is the way that Windows draws controls with active theme.
Oh yes, I could use the functions:
OpenThemeData()
DrawThemeBackground()
DrawThemeText()
CloseThemeData()

But in this way I can not draw rounded/circular buttons.

It seems to me that the simplest solution of the colored buttons will be adding in HMG two properties for standard buttons:
TEXTCOLOR
BACKCOLOR
and processing WM_NOTIFY/NM_CUSTOMDRAW message.
The problem of this type of solution is that departs from the normal behavior of Windows with active theme.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: FontColor and button - is it possible to change?

Post by KDJ »

Below is the new version of owner draw buttons.
Added: gradiend for backgroud color.
Warning: changed aColor structure. I'm sorry for the inconvenience.
 
Attachments
OwnButton.png
OwnButton.png (24.01 KiB) Viewed 6177 times
OwnButton.zip
(6.85 KiB) Downloaded 306 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

FontColor and button - is it possible to change?

Post by Pablo César »

Beautiful, perfect !

There's only one thing I'd like you to change: Is it possible to transform RGB color into HexaDecimals ? (Because we are accustomed RGB in array with the three elements). As for aesthetics, IMHO You do not have to change anything !

I liked it a lot and I would definitely use it in my applications when you need differentiated buttons.

Thank you very much, Mr. Krzysztof, great work !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3166
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: FontColor and button - is it possible to change?

Post by serge_girard »

Thanks Krzysztof !

Really great!

Serge
There's nothing you can do that can't be done...
chrisjx2002
Posts: 190
Joined: Wed Jan 06, 2010 5:39 pm

Re: FontColor and button - is it possible to change?

Post by chrisjx2002 »

Very Good Job!!!

It works but during the compilation I have plenty of warnings :

OwnButtonDemo.prg(383) Warning W0002 Ambiguous reference, assuming memvar '_HMG_SYSDATA'
....
OwnButton.prg(95) Warning W0002 Ambiguous reference, assuming memvar '_HMG_SYSDATA'
OwnButton.prg(96) Warning W0002 Ambiguous reference, assuming memvar '_HMG_SYSDATA'

Is it a problem?
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: FontColor and button - is it possible to change?

Post by KDJ »

chrisjx2002

It is not a problem.
These warnings occurs if you compile HMG program with parameter -w2 or -w3.
To avoid this, add in hmg.ch:

Code: Select all

MEMVAR _HMG_SYSDATA
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: FontColor and button - is it possible to change?

Post by KDJ »

Pablo César wrote:There's only one thing I'd like you to change: Is it possible to transform RGB color into HexaDecimals ? (Because we are accustomed RGB in array with the three elements).
You can use RGB macro and GetRed, GetGreen, GetBlue functions:

Code: Select all

RGB(0xAA, 0xBB, 0xCC) --> 0xCCBBAA (dec: 13417386)
GetRed(0x00CCBBAA)    --> 0xAA     (dec: 170)
GetGreen(0x00CCBBAA)  --> 0xBB     (dec: 187)
GetBlue(0x00CCBBAA)   --> 0xCC     (dec: 204)
If your color is defined as 3 elemnts array
aRGB := {nR, nG, nB}
use
RGB(aRGB[1], aRGB[2], aRGB[3])
or
RGBfromArray(aRGB)
to obtain nRGB value.

Code: Select all

FUNCTION RGBfromArray(aRGB)
RETURN RGB(aRGB[1], aRGB[2], aRGB[3])
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

FontColor and button - is it possible to change?

Post by Pablo César »

I did not know I could use RGB in Hexadecimal...

Thank you Krzysztof for your indications. :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

FontColor and button - is it possible to change?

Post by Pablo César »

Hi Krzysztof,

I hope you do not mind, I made a small contribution based on your code.
Screen31.png
Screen31.png (21.68 KiB) Viewed 6079 times
OwnButton.rar
Source files with my contributions
(7.24 KiB) Downloaded 360 times
Added cutomized colors and Gradient mode. I also fixed probably a typo in FrameColor of ODS_FOCUS in _OWNBUTTONDRAW C function. (I wrote Pablo FYG).

A big hug :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply