Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetsysColor() parameter for hot tracking 2

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,485
9
38
Scotland
www.ml-consult.co.uk
Does anyone know what value I need to pass to GetSysColor() to find the "hot tracking" colour?

To explain further ....

If you run a form with XP themes enabled, and you pass the mouse over certain controls, Windows will highlight the control. It does this by changing its colour. In my system, it changes to a sort of gold colour That's the colour whose colour code I need to find. (This applies in Windows generally, not just in VFP.)

I should be able to do this by calling GetSysColor(), but I can't find which parameter to pass for this particular colour.

Alternatively, does anyone know any other way of determining the colour in question?

Thanks in advance,

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi MikeLewis :

I have no idea with GetSysColor().

Anyway, if you want to determine transfer the color displayed in monitor into RGB code, here is the link for the tool I am using.


Best regards,
Smarty
 

Thanks for that link, but it doesn't address the issue.

I don't want to know what the colour is on my system. I can get that with any one of a dozen graphic tools. I need a way to do it programmatically, so that I can determine the colour on the user's system.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

Marcia,

Hmm. 26 doesn't work for me. It returns a deep blue on my system. The colour I am looking for is a mix between gold and brown.

Just to clarify. If you run a form containing a page frame (or any tabbed dialogue in any Windows application), and move the mouse over one of the tabs, the colour in question appears as a thin strip along the top of the tab. It also appears around the edge of a command button when you mouse over it.

Thanks anyway.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

See if this truckload of defines helps you out any.
I'm guessing it may be the COLOR_3DHIGHLIGHT value:
Code:
#define COLOR_SCROLLBAR         0
#define COLOR_BACKGROUND        1
#define COLOR_ACTIVECAPTION     2
#define COLOR_INACTIVECAPTION   3
#define COLOR_MENU              4
#define COLOR_WINDOW            5
#define COLOR_WINDOWFRAME       6
#define COLOR_MENUTEXT          7
#define COLOR_WINDOWTEXT        8
#define COLOR_CAPTIONTEXT       9
#define COLOR_ACTIVEBORDER      10
#define COLOR_INACTIVEBORDER    11
#define COLOR_APPWORKSPACE      12
#define COLOR_HIGHLIGHT         13
#define COLOR_HIGHLIGHTTEXT     14
#define COLOR_BTNFACE           15
#define COLOR_BTNSHADOW         16
#define COLOR_GRAYTEXT          17
#define COLOR_BTNTEXT           18
#define COLOR_INACTIVECAPTIONTEXT 19
#define COLOR_BTNHIGHLIGHT      20

#if(WINVER >= 0x0400)
#define COLOR_3DDKSHADOW        21
#define COLOR_3DLIGHT           22
#define COLOR_INFOTEXT          23
#define COLOR_INFOBK            24

#define COLOR_DESKTOP           COLOR_BACKGROUND
#define COLOR_3DFACE            COLOR_BTNFACE
#define COLOR_3DSHADOW          COLOR_BTNSHADOW
#define COLOR_3DHIGHLIGHT       COLOR_BTNHIGHLIGHT
#define COLOR_3DHILIGHT         COLOR_BTNHIGHLIGHT
#define COLOR_BTNHILIGHT        COLOR_BTNHIGHLIGHT
#endif /* WINVER >= 0x0400 */

-Dave Summers-
[cheers]
Even more Fox stuff at:
 

Dave,

Thanks for posting that. I had already tried all the likely looking ones from the list, including COLOR_3DHIGHLIGHT, but none of them worked. In fact, I wrote a little program to loop through all values from 1 to 50 -- no luck.

I'm beginning to think I'm looking in the wrong place. Maybe I need to interrogate the Themes settings (I don't know if that's possible) rather than the system colors.

Or maybe I need to think of some other way of achieving my goal.

Thanks anyway to all who replied.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike

Hmm. 26 doesn't work for me. It returns a deep blue on my system. The colour I am looking for is a mix between gold and brown.

This is from GetSysColor topic in the MSDN library. It says that 26 is the value for COLOR_HOTLIGHT
26 - Color for a hot-tracked item. Single clicking a hot-tracked item executes the item.

So, I am pretty sure that you got what you aked for but not what you wanted ;-)

Parameters
nIndex
[in] Display element whose color is to be retrieved. This parameter can be one of the following values. Value Meaning
COLOR_3DDKSHADOW 21 Dark shadow for three-dimensional display elements.
COLOR_3DFACE 15 Face color for three-dimensional display elements and for dialog box backgrounds.
COLOR_3DHIGHLIGHT 20 Highlight color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DHILIGHT 20 Highlight color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DLIGHT 22 Light color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DSHADOW 16 Shadow color for three-dimensional display elements (for edges facing away from the light source).
COLOR_ACTIVEBORDER 10 Active window border.
COLOR_ACTIVECAPTION 2 Active window title bar.
Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled.

Windows NT and Windows 95: This remark does not apply.

COLOR_APPWORKSPACE 12 Background color of multiple document interface (MDI) applications.
COLOR_BACKGROUND 1 Desktop.
COLOR_BTNFACE 15 Face color for three-dimensional display elements and for dialog box backgrounds.
COLOR_BTNHIGHLIGHT 20 Highlight color for three-dimensional display elements (for edges facing the light source.)
COLOR_BTNSHADOW 16 Shadow color for three-dimensional display elements (for edges facing away from the light source).
COLOR_BTNTEXT 18 Text on push buttons.
COLOR_CAPTIONTEXT 9 Text in caption, size box, and scroll bar arrow box.
COLOR_DESKTOP 1 Desktop.
COLOR_GRADIENTACTIVECAPTION 27 Right side color in the color gradient of an active window's title bar. COLOR_ACTIVECAPTION specifies the left side color. Use SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to determine whether the gradient effect is enabled.
Windows NT and Windows 95: This value is not supported.
COLOR_GRADIENTINACTIVECAPTION 28 Right side color in the color gradient of an inactive window's title bar. COLOR_INACTIVECAPTION specifies the left side color.
Windows NT and Windows 95: This value is not supported.
COLOR_GRAYTEXT 17 Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.
COLOR_HIGHLIGHT 13 Item(s) selected in a control.
COLOR_HIGHLIGHTTEXT 14 Text of item(s) selected in a control.
COLOR_HOTLIGHT 26 Color for a hot-tracked item. Single clicking a hot-tracked item executes the item.
Windows NT and Windows 95: This value is not supported.
COLOR_INACTIVEBORDER 11 Inactive window border.
COLOR_INACTIVECAPTION 3 Inactive window caption.
Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled.

Windows NT and Windows 95: This remark does not apply.

COLOR_INACTIVECAPTIONTEXT 19 Color of text in an inactive caption.
COLOR_INFOBK 24 Background color for tooltip controls.
COLOR_INFOTEXT 23 Text color for tooltip controls.
COLOR_MENU 4 Menu background.
COLOR_MENUHILIGHT 29 The color used to highlight menu items when the menu appears as a flat menu (see SystemParametersInfo). The highlighted menu item is outlined with COLOR_HIGHLIGHT.
Windows 2000/NT and Windows Me/98/95: This value is not supported.
COLOR_MENUBAR 30 The background color for the menu bar when menus appear as flat menus (see SystemParametersInfo). However, COLOR_MENU continues to specify the background color of the menu popup.
Windows 2000/NT and Windows Me/98/95: This value is not supported.
COLOR_MENUTEXT 7 Text in menus.
COLOR_SCROLLBAR 0 Scroll bar gray area.
COLOR_WINDOW 5 Window background.
COLOR_WINDOWFRAME 6 Window frame.
COLOR_WINDOWTEXT 8 Text in windows.


Marcia G. Akins
 

Marcia,

I wonder if I haven't got some fundamental misunderstanding here.

When I execute ? GetSysColor(26), it returns 16777215. If I set any VFP control's ForeColor or BackColor (say _SCREEN.BackColor) to that number, it turns dark blue.

If I open any Windows application (say, Outlook Express) and hover the mouse over a comand button, checkbox or the tab of a page frame, the control in question takes on a coloured border. The colour in question is the yellow-gold I've been talking about. This is the one I'm trying to retrieve from GetSysColor.

I have Themes set to Windows XP at the OS level. I also have Themes enabled in VFP.

Can you think of anything I am doing wrong?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I'm not sure how you can get at that color. I have a little that I use to show all the colors from the current theme and that gold (I do know what you mean) isn't in the list (although I can see it on the form itself).

Tamar
 
I'm not sure if it applies here, but one caution is that VFP uses RGB colors, and windows sometimes uses BGR colors, so you may have to reverse the byte order to get the intended color.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 

Tamar,

It looks like your right. I won't spend any more time on this. I'll just look for another way of meeting the goal.

In case anyone's interested in why I want to do this .... I have a class consisting of a container that holds a couple of labels and an image. I want to treat this class a command button. If the user has themes enabled, I want to hot track it in the same way as a command button.

No doubt I'll figure out an alternative approach.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

Bill,

Thanks for the reminder about RGB vs. BGR. However, I don't think it applies here, because I have been working with absolute colour values -- the 24-bit values you get back from GetSysColor().

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

The themed colors (entire controls for that matter) that you are seeing are drawn using uxtheme.dll. There's an example of how to use uxheme.dll that Bo Durban and I wrote in the GDIPlusX project out on VFPX (previouly SednaX). However, getting theme system colors isn't provided in that example... it will just show you how to draw themed controls.

In any event, in order to get the theme system color you need to do the following. I've set up the code to give you that Gold color you're looking for (you can look at the uxtheme.h that is in GDIPlusX for the rest of the constants - I've provided a few but far from all).
Code:
#DEFINE TMT_BORDERCOLOR             3801
#DEFINE TMT_FILLCOLOR               3802
#DEFINE TMT_TEXTCOLOR               3803
#DEFINE TMT_EDGELIGHTCOLOR          3804
#DEFINE TMT_EDGEHIGHLIGHTCOLOR      3805
#DEFINE TMT_EDGESHADOWCOLOR         3806
#DEFINE TMT_EDGEDKSHADOWCOLOR       3807
#DEFINE TMT_EDGEFILLCOLOR           3808
#DEFINE TMT_TRANSPARENTCOLOR        3809
#DEFINE TMT_GRADIENTCOLOR1          3810
#DEFINE TMT_GRADIENTCOLOR2          3811
#DEFINE TMT_GRADIENTCOLOR3          3812
#DEFINE TMT_GRADIENTCOLOR4          3813
#DEFINE TMT_GRADIENTCOLOR5          3814
#DEFINE TMT_SHADOWCOLOR             3815
#DEFINE TMT_GLOWCOLOR               3816
#DEFINE TMT_TEXTBORDERCOLOR         3817
#DEFINE TMT_TEXTSHADOWCOLOR         3818
#DEFINE TMT_GLYPHTEXTCOLOR          3819
#DEFINE TMT_GLYPHTRANSPARENTCOLOR   3820
#DEFINE TMT_FILLCOLORHINT           3821
#DEFINE TMT_BORDERCOLORHINT         3822
#DEFINE TMT_ACCENTCOLORHINT         3823

#DEFINE CLASS_BUTTON STRCONV("Button"+0h00,5)

#DEFINE BP_PUSHBUTTON 1

#DEFINE PBS_NORMAL 1
#DEFINE PBS_HOT 2
#DEFINE PBS_PRESSED 3
#DEFINE PBS_DISABLED 4
#DEFINE PBS_DEFAULTED 5

DECLARE LONG OpenThemeData IN UXTHEME LONG HWND, STRING classList
DECLARE LONG CloseThemeData IN UXTHEME LONG hTheme
DECLARE LONG GetThemeColor IN UXTHEME LONG hTheme, LONG iPartId, LONG iStateId, LONG iPropId, LONG @pColor

m.lnTheme = OpenThemeData(0, CLASS_BUTTON)
m.lnColor = 0
m.lnReturn = GetThemeColor(m.lnTheme, BP_PUSHBUTTON, PBS_HOT, TMT_ACCENTCOLORHINT, @m.lnColor)
IF m.lnReturn = 0
	_CLIPTEXT = TRANSFORM(m.lnColor)
	MESSAGEBOX("The Theme System color you specified has been copied to the clipboard.",64,"UXTHEME")
*!*		_SCREEN.BackColor = m.lnColor
ELSE
	MESSAGEBOX("The values you selected resulted in an error #" + TRANSFORM(m.lnReturn),64,"UXTHEME")
ENDIF
CloseThemeData(m.lnTheme)

boyd.gif

SweetPotato Software Website
My Blog
 
Correction:
...you can look at the uxtheme.h that is in GDIPlusX for the rest of the constants...

should read...

...you can look at the xpthemes.h that is in GDIPlusX for the rest of the constants...

boyd.gif

SweetPotato Software Website
My Blog
 

You know, Craig, I had a feeling the answer was connected with GDIPlus -- and that you would know exactly what do do. I can't claim to understand the issue, but your example worked perfectly. It's given me exactly what I wanted and more.

I'm going to re-read your articles on GDI Plus and look at your GDIPlusX project. I'm sure there'll be other good stuff there that I can make use of.

Many thanks.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top