Re: Get dialog color


[ Follow Ups ] [ Post Followup ] [ Signature.net Forum ]

Posted by Grant Foraker on January 18, 2012 at 08:33:33:

In Reply to: Re: Get dialog color posted by Grant Foraker on January 17, 2012 at 10:44:22:

Simple isn't always simple in Windows. I just wanted to turn the text in a Static control to red when there was an out of balance condition. And, back to black when the out of balance was corrected.

Comet's COS.SetControlColors sets Fore, Back, and Gray colors for a control. Currently a limited set of controls. Check documentation. When I moved my program to a Server 2008 PC (CAW Host), I found that the Back color was a darker gray than I'd seen on Win7, Vista, and XP PC's.

After some searching (Google, MSDN, and Comet's WDL), I found that COS.GetSysColor was the way to get the default control colors. Since Fore was either black or red, I didn't need to capture it's default RGB values.

LET cosIndex = Color.BtnFace ! initial cosBackColor
GOSUB COS.GetSysColor
LET cosIndex = Color.GrayText ! initial cosGrayColor
GOSUB COS.GetSysColor

I'm guessing that the GrayText is the color used when a control is disabled.

I tested some other color options. These are from my Win7 PC ...

Color.CaptionText = Black (0,0,0)
Color.HighlightText = White (255,255,255)
Color.InactiveCaptionText = Dark Gray (67,78,84)
Color.MenuText = Black (0,0,0)
Color.WindowText = Black (0,0,0)

Comet may support more. Windows has a lot more.

LENGTH 6.0 & LOCAL BtnFaceRed, BtnFaceGreen, BtnFaceBlue
LENGTH 6.0 & LOCAL GrayTextRed, GrayTextGreen, GrayTextBlue

LET cosIndex = Color.BtnFace
GOSUB COS.GetSysColor
LET BtnFaceRed = cosRed
LET BtnFaceGreen = cosGreen
LET BtnFaceBlue = cosBlue

LET cosIndex = Color.GrayText
GOSUB COS.GetSysColor
LET GrayTextRed = cosRed
LET GrayTextGreen = cosGreen
LET GrayTextBlue = cosBlue

IF DIFFER NE 0
cosCtlId = IDC.STATIC.05
cosForeColor = 255 + (0 * 256) + (0 * 65536) ! Red
cosBackColor = BtnFaceRed + (BtnFaceGreen * 256) + (BtnFaceBlue * 65536)
cosGrayColor = GrayTextRed + (GrayTextGreen * 256) + (GrayTextBlue * 65536)
Gosub COS.SetControlColors
ELSE
cosCtlId = IDC.STATIC.05
cosForeColor = 0 + (0 * 256) + (0 * 65536) ! Black
cosBackColor = BtnFaceRed + (BtnFaceGreen * 256) + (BtnFaceBlue * 65536)
cosGrayColor = GrayTextRed + (GrayTextGreen * 256) + (GrayTextBlue * 65536)
Gosub COS.SetControlColors
ENDIF




Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

What is the name of the main Signature System's Product?  

Comments:

Optional Link URL:
Link Title:
Optional Image URL:

You may attach up to 5 files to your followup (see below):





Each file can be a maximum of 1MB in length Uploaded files will be purged from the server on a regular basis.


[ Follow Ups ] [ Post Followup ] [ Signature.net Forum ]