Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to change the color of a CStatic
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to change the color of a CStatic

 Post Reply Post Reply
Author
Message
ocoralan View Drop Down
Groupie
Groupie


Joined: 14 November 2007
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote ocoralan Quote  Post ReplyReply Direct Link To This Post Topic: How to change the color of a CStatic
    Posted: 15 November 2007 at 10:06am
Dear Support:
I have a program which is based on the CXTResizeDialog, I met two questions:

(1) There is a CStatic in this dialog, In default, the font color is black, when something is wrong, it's color will change to red, is there any such class in the xtreme toolkitpro?

(2) Can I make the resize gripper in the bottom right corner visible?

Thank you.

Back to Top
Ashok View Drop Down
Senior Member
Senior Member


Joined: 02 May 2007
Status: Offline
Points: 164
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ashok Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2007 at 8:16am

Hi, I am not sure whether this solution is suits you. But this is solution for changing the color of the Static.

 override OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

HBRUSH CDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

{

if (nCtlColor == CTLCOLOR_STATIC)

return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

COLORREF clr = RGB(0,0,0); -- type the color u want

static CBrush brush;

static COLORREF brushColor = 0;

if (brush.GetSafeHandle() == 0 || brushColor != clr)

{

brush.DeleteObject();

brush.CreateSolidBrush(clr);

brushColor = clr;

}

pDC->SetTextColor(clr);

return brush;

}

Back to Top
ocoralan View Drop Down
Groupie
Groupie


Joined: 14 November 2007
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote ocoralan Quote  Post ReplyReply Direct Link To This Post Posted: 18 November 2007 at 10:46am
Thank you for your help.

But I donn't think this method suits for me, because there are other CStatic controls in my dialog.

My requirement is following:
When the customers enter the wrong password, the font color of the specified CStatic will be changed to red.

to Support: Are there any such class which is derived from CStatic in the XTreme ToolkitPro?
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2007 at 4:51am
Create your own class CTransparentStatic : public CStatic.
And this class handle OnCtlColor itself.
Or your create a complete owndraw CStatic with Transparent flag.
See www.codeproject.com, there are some sample.

  Jimmy

Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 954
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 27 November 2007 at 1:33pm
A static doesn' t have to use the fixed ID assigned by the resource editor. Open your resource file and select the control on the dialog and invoke the properties command. Give the static control its own ID. Then in OnCtlColor simply take the input CWnd and call GetDlgCtrlID().
 
Look for the ID you gave it and when your static comes thru color it appropriately.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.