I want to set the color of a window which is to be determined at run time ..
will be picked from the property of a color ? Don't know how to set it up
like this ?

Re: Custom window Color ? by man-wai

man-wai
Tue Aug 16 03:44:03 CDT 2005

Tanveer H. Malik wrote:
> I want to set the color of a window which is to be determined at run time ..
> will be picked from the property of a color ? Don't know how to set it up
> like this ?
>
>
did you mean the colors of the control in the form or the form itself,
or the whole's windows title bar and theme?

Re: Custom window Color ? by Tanveer

Tanveer
Tue Aug 16 04:00:20 CDT 2005

I want to define a window to use it as a Status Bar, so what I need is to
base base its color on the color of the Toolbar - Windows XP compliant -, so
that it acquires the same color as of Toolbar.


"man-wai chang" <toylet.toylet@gmail.com> wrote in message
news:%23m5Sk6joFHA.3408@tk2msftngp13.phx.gbl...
> Tanveer H. Malik wrote:
>> I want to set the color of a window which is to be determined at run time
>> ..
>> will be picked from the property of a color ? Don't know how to set it up
>> like this ?
>>
>>
> did you mean the colors of the control in the form or the form itself,
> or the whole's windows title bar and theme?



Re: Custom window Color ? by Rick

Rick
Tue Aug 16 09:39:12 CDT 2005

Tanveer,
This code will provide all the named current Windows color values. (I think it
answers your next question too!)
Ex.
l_cRGB = ""
IF Get_WinColor("ActiveTitle", @l_cRGB)
? l_cRGB
ELSE
? "Bad Color Name"
ENDIF


* Program....: GET_WINCOLOR.PRG
* Version....: 1.0
* Author.....: ** Richard G Bean **
* Date.......: July 18, 2001
* Compiler...: Visual FoxPro 06.00.8961.00 for Windows
* Abstract...: Note: This duplicates the old "Read the Registry" routine,
* but by using the system call, we should get more accurate
results.
* Changes....:
Procedure GET_WINCOLOR && Kill this line if in separate file
PARAMETERS p_cColorName, p_cRGB
LOCAL llretval
LOCAL ln_Color, ln_WINVER

DECLARE LONG GetSysColor IN WIN32API LONG nIndex

#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

** The following are conditional based on the OS **
*#if(WINVER >= 0x0400)
#define COLOR_3DDKSHADOW 21
#define COLOR_3DLIGHT 22
#define COLOR_INFOTEXT 23
#define COLOR_INFOBK 24
*#endif /* WINVER >= 0x0400 */

*!* *#if(WINVER >= 0x0500)
*!* #define COLOR_HOTLIGHT 26
*!* #define COLOR_GRADIENTACTIVECAPTION 27
*!* #define COLOR_GRADIENTINACTIVECAPTION 28
*!* *#endif /* WINVER >= 0x0500 */

*!* *#if(WINVER >= 0x0400)
*!* #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 */

*!* #DEFINE COLOR_ADJ_MAX 100
*!* #DEFINE COLOR_ADJ_MIN -100

** This should probably be "smarter" but this is good enough for now **
IF VARTYPE(_WIN95) <> "L"
= WINPLAT()
ENDIF
IF _WIN95
ln_WINVER = 0x0390
ELSE
ln_WINVER = 0x0400 && For now - seems to work in both NT and Win98
ENDIF
STORE "" TO p_cRGB
llretval = .T.

* p_cColorName values are named as found in
* [HKEY_CURRENT_USER\Control Panel\Colors]
* Comment based on info in
* Display Properties - Appearance

DO CASE
CASE p_cColorName == "ActiveBorder" && Active Window Border
ln_Color = COLOR_ACTIVEBORDER
CASE p_cColorName == "ActiveTitle" && Active Title Bar
ln_Color = COLOR_ACTIVECAPTION
CASE p_cColorName == "AppWorkSpace" && Application Background
ln_Color = COLOR_APPWORKSPACE
CASE p_cColorName == "Background" && Desktop
ln_Color = COLOR_BACKGROUND
CASE p_cColorName == "ButtonDkShadow"
IF ln_WINVER >= 0x0400
ln_Color = COLOR_3DDKSHADOW
ELSE
ln_Color = COLOR_BTNSHADOW
ENDIF
CASE p_cColorName == "ButtonFace" && 3D Objects
ln_Color = COLOR_BTNFACE
CASE p_cColorName == "ButtonHilight"
ln_Color = COLOR_BTNHIGHLIGHT
CASE p_cColorName == "ButtonLight"
IF ln_WINVER >= 0x0400
ln_Color = COLOR_3DLIGHT
ELSE
ln_Color = COLOR_BTNFACE
ENDIF
CASE p_cColorName == "ButtonShadow"
ln_Color = COLOR_BTNSHADOW
CASE p_cColorName == "ButtonText" && 3D Objects (Text)
ln_Color = COLOR_BTNTEXT
CASE p_cColorName == "GrayText"
ln_Color = COLOR_GRAYTEXT
CASE p_cColorName == "Hilight" && Selected Items
ln_Color = COLOR_HIGHLIGHT
CASE p_cColorName == "HilightText" && Selected Items (Text)
ln_Color = COLOR_HIGHLIGHTTEXT
CASE p_cColorName == "InactiveBorder" && Inactive Window Border
ln_Color = COLOR_INACTIVEBORDER
CASE p_cColorName == "InactiveTitle" && Inactive Title Bar
ln_Color = COLOR_INACTIVECAPTION
CASE p_cColorName == "InactiveTitleText" && Inactive Title Bar (Text)
ln_Color = COLOR_INACTIVECAPTIONTEXT
CASE p_cColorName == "InfoText" && ToolTip (Text)
IF ln_WINVER >= 0x0400
ln_Color = COLOR_INFOTEXT
ELSE
ln_Color = COLOR_WINDOWTEXT
ENDIF
CASE p_cColorName == "InfoWindow" && ToolTip (Background)
IF ln_WINVER >= 0x0400
ln_Color = COLOR_INFOBK
ELSE
ln_Color = COLOR_WINDOW
ENDIF
CASE p_cColorName == "Menu" && Menu
ln_Color = COLOR_MENU
CASE p_cColorName == "MenuText" && Menu (Text)
ln_Color = COLOR_MENUTEXT
CASE p_cColorName == "Scrollbar"
ln_Color = COLOR_SCROLLBAR
CASE p_cColorName == "TitleText" && Active Title Bar (Text)
ln_Color = COLOR_CAPTIONTEXT
CASE p_cColorName == "Window" && Window
ln_Color = COLOR_WINDOW
CASE p_cColorName == "WindowFrame"
ln_Color = COLOR_WINDOWFRAME
CASE p_cColorName == "WindowText" && Window (Text) & Message Box (Text)
ln_Color = COLOR_WINDOWTEXT
OTHERWISE
llretval = .F.
ENDCASE

IF llretval
ln_ColorRGB = GetSysColor(ln_Color)
p_cRGB = GC2RGB(ln_ColorRGB)
IF EMPTY(p_cRGB)
llretval = .F.
ENDIF
ENDIF

RETURN llretval

*!* EOP: GET_WINCOLOR.PRG

************
* WinPlat.PRG
* Author: Rick Strahl
* FPAdvisor 6/96-Tips,Tricks,Traps p.16
* Modified by: Rick Bean 4/24/96
* RGB 6/18/98 - added _WIN98
* RGB 3/05/00 - added _WIN2000
* RGB 8/13/00 - added _WINME
* RGB 10/16/01 - added _WINXP
* RGB 10/22/02 - added 2.x WIN2000/WINXP check
* RGB 02/18/05 - added WIN2003 and Longhorn checks
*
* Function: Return Windows Platform in use
* Notes: FPW 2.6+ and VFP
* Return: "WINNT", "WIN95", "WIN98", "WIN2000", "WINME", "WIN31",
* "WINXP" "WIN2003", "Longhorn"
* or "" if not running under Windows
* AND sets global logicals _WINNT, _WIN95,
* _WIN98 ,_WIN31, _WIN2000, _WINME, _WINXP, _WIN2003, _Longhorn
* which specify the current Windows platform
*
Procedure WinPlat && Kill this line if in separate file

PRIVATE lcPlatform, lcOS

RELEASE _WINNT, _WIN95, _WIN31, _WIN98, _WIN2000, _WINME, _WINXP, _WIN2003,
_Longhorn
PUBLIC _WINNT, _WIN95, _WIN31, _WIN98, _WIN2000, _WINME, _WINXP, _WIN2003,
_Longhorn
STORE .F. TO _WINNT, _WIN95, _WIN31, _WIN98, _WIN2000, _WINME, _WINXP, _WIN2003,
_Longhorn
lcPlatform = ""
* Only for Windows platforms
IF TYPE("_WINDOWS") = "U" OR !_WINDOWS
RETURN lcPlatform
ENDIF
lcPlatform = "(Unknown)"
lcOS = OS(1)
IF ATC("VISUAL", VERSION()) # 0
* Visual FoxPro
DO CASE
CASE "6.00" $ lcOS
lcPlatform = "LongHorn"
CASE "5.02" $ lcOS
lcPlatform = "WIN2003"
CASE "5.01" $ lcOS
lcPlatform = "WINXP"
* CASE "NT" $ lcOS AND "5.0" $ lcOS && Beta Only
* lcPlatform = "WIN2000"
CASE "5.0" $ lcOS
lcPlatform = "WIN2000"
CASE "NT" $ lcOS
lcPlatform = "WINNT"
CASE "4.0" $ lcOS OR "3.9" $ lcOS
lcPlatform = "WIN95"
CASE "4.1" $ lcOS
lcPlatform = "WIN98"
CASE "4.9" $ lcOS
lcPlatform = "WINME"
CASE "3." $ lcOS
lcPlatform = "WIN31"
ENDCASE
ELSE && Since EPICSYS is not going to be run under FPW, ignore Win2000, WinME,
WinXP
* FPW 2.x
DO CASE
CASE ATC("WINDOWS_NT",GETENV("OS")) <> 0 ;
OR ATC("CMD.EXE", GETENV("COMSPEC")) <> 0
IF "3.95" $ lcOS && 2000 or XP
lcPlatform = "WIN2000"
ELSE
lcPlatform = "WINNT"
ENDIF
CASE "3.95" $ lcOS && Can't tell if Win95 or Win98
lcPlatform = "WIN95"
CASE "3." $ lcOS
lcPlatform = "WIN31"
ENDCASE
ENDIF
_WINNT = (lcPlatForm == "WINNT")
_WIN98 = (lcPlatForm == "WIN98")
_WIN95 = (lcPlatForm == "WIN95")
_WIN31 = (lcPlatForm == "WIN31")
_WIN2000 = (lcPlatForm == "WIN2000")
_WINME = (lcPlatForm == "WINME")
_WINXP = (lcPlatForm == "WINXP")
_WIN2003 = (lcPlatForm == "WIN2003")
_Longhorn = (lcPlatForm == "LongHorn")
RETURN lcPlatForm

************
*FUNCTION GC2RGB
Procedure GC2RGB && Kill this line if in separate file
PARAMETERS p_nColor
PRIVATE l_nRed, l_nGreen, l_nBlue

IF PCOUNT() < 1 OR TYPE("p_nColor") <> "N"
RETURN ""
ENDIF
IF !BETWEEN(p_nColor, 0, 256^3-1)
RETURN ""
ENDIF

l_nRed = MOD(p_nColor, 256)
l_nGreen = MOD(INT(p_nColor/256), 256)
l_nBlue = MOD(INT(p_nColor/(256*256)), 256)

RETURN ALLTRIM(STR(l_nRed));
+","+ALLTRIM(STR(l_nGreen));
+","+ALLTRIM(STR(l_nBlue))
*------------

"Tanveer H. Malik" <tanmalik@hotmail.com> wrote in message
news:e5F0w0ioFHA.2156@TK2MSFTNGP09.phx.gbl...
>I want to set the color of a window which is to be determined at run time ..
>will be picked from the property of a color ? Don't know how to set it up like
>this ?
>