Page 3 of 5

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

Posted: Tue Dec 06, 2016 9:02 pm
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.

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

Posted: Tue Dec 06, 2016 10:20 pm
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.

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

Posted: Fri Dec 09, 2016 11:03 pm
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.
 

FontColor and button - is it possible to change?

Posted: Sat Dec 10, 2016 1:06 am
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 !

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

Posted: Sat Dec 10, 2016 9:52 am
by serge_girard
Thanks Krzysztof !

Really great!

Serge

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

Posted: Sat Dec 10, 2016 1:52 pm
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?

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

Posted: Sat Dec 10, 2016 3:15 pm
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

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

Posted: Sat Dec 10, 2016 8:12 pm
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])

FontColor and button - is it possible to change?

Posted: Sat Dec 10, 2016 8:43 pm
by Pablo César
I did not know I could use RGB in Hexadecimal...

Thank you Krzysztof for your indications. :)

FontColor and button - is it possible to change?

Posted: Sun Dec 11, 2016 3:11 am
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 6608 times
OwnButton.rar
Source files with my contributions
(7.24 KiB) Downloaded 381 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 :)