![]() |
How to change the color of a CStatic |
Post Reply
|
| Author | |
ocoralan
Groupie
Joined: 14 November 2007 Status: Offline Points: 35 |
Post Options
Thanks(0)
Quote Reply
Topic: How to change the color of a CStaticPosted: 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. |
|
![]() |
|
Ashok
Senior Member
Joined: 02 May 2007 Status: Offline Points: 164 |
Post Options
Thanks(0)
Quote Reply
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;} |
|
![]() |
|
ocoralan
Groupie
Joined: 14 November 2007 Status: Offline Points: 35 |
Post Options
Thanks(0)
Quote Reply
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? |
|
![]() |
|
jimmy
Senior Member
Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
rdhd
Senior Member
Joined: 13 August 2007 Location: United States Status: Offline Points: 954 |
Post Options
Thanks(0)
Quote Reply
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.
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |