Click here to Skip to main content
15,887,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Color to Static Control (Urgent pls) Pin
Malli_S2-Mar-06 19:56
Malli_S2-Mar-06 19:56 
GeneralRe: Color to Static Control (Urgent pls) Pin
RockyJames2-Mar-06 20:05
RockyJames2-Mar-06 20:05 
GeneralRe: Color to Static Control (Urgent pls) Pin
Malli_S2-Mar-06 20:18
Malli_S2-Mar-06 20:18 
AnswerRe: Color to Static Control (Urgent pls) Pin
Cool Ju2-Mar-06 20:21
Cool Ju2-Mar-06 20:21 
GeneralRe: Color to Static Control (Urgent pls) Pin
RockyJames2-Mar-06 20:53
RockyJames2-Mar-06 20:53 
GeneralRe: Color to Static Control (Urgent pls) Pin
RockyJames2-Mar-06 21:31
RockyJames2-Mar-06 21:31 
AnswerRe: Color to Static Control (Urgent pls) Pin
David Crow3-Mar-06 4:43
David Crow3-Mar-06 4:43 
AnswerRe: Color to Static Control (Urgent pls) Pin
DoctorEd5-Mar-06 10:12
DoctorEd5-Mar-06 10:12 
I had exactly (well ALMOST...) the same requirement. After many inquiries to experienced developers I finally had to find the solution for myself...

1.) Hand-edit the RC file (text mode) to set your static control to OWNER-DRAW. E.G.,
CTEXT "AUTH",IDC_StatAuth1,177,139,28,10,SS_CENTERIMAGE |
SS_SUNKEN | SS_OWNERDRAW | WS_BORDER | NOT WS_GROUP

2.) Override the OnPaint() handler (you don't need the OnCtlColor handler...) an example snippet follows fom the OnPaint() handler:
CWnd* pStat = m_pDlg->GetDlgItem(GetID());
CDC * pDC = pStat->GetDC();
CRect rect;

pStat->GetClientRect(&rect);
pDC->FillSolidRect(&rect, m_nRgbColor);
pDC->SelectObject(m_pDlg->GetMLEDisplayFont()); // Select presized font
pDC->DrawText(m_strText, &rect, DT_VCENTER | DT_CENTER | DT_NOCLIP);
pStat->ReleaseDC(pDC);

The problem is, with static controls is that the background is always drawn by the framework unless you specify owner draw, and the AppWiz (now non-existant in newer VS editions...) never thought of you wanting to owner draw a static control. Thus you have to edit the .rc file by hand.

Work good, no crash!

- Ed.
--------------------------------
QuestionC2491 Error Pin
subramanyeswari2-Mar-06 19:04
subramanyeswari2-Mar-06 19:04 
AnswerRe: C2491 Error Pin
Nibu babu thomas2-Mar-06 19:20
Nibu babu thomas2-Mar-06 19:20 
GeneralRe: C2491 Error Pin
subramanyeswari2-Mar-06 19:50
subramanyeswari2-Mar-06 19:50 
GeneralRe: C2491 Error Pin
Nibu babu thomas2-Mar-06 19:59
Nibu babu thomas2-Mar-06 19:59 
AnswerRe: C2491 Error Pin
Malli_S2-Mar-06 20:04
Malli_S2-Mar-06 20:04 
QuestionDialog Pin
J51219822-Mar-06 18:34
J51219822-Mar-06 18:34 
AnswerRe: Dialog Pin
Nibu babu thomas2-Mar-06 18:41
Nibu babu thomas2-Mar-06 18:41 
QuestionTCP/IP define a IP address a 32b int Pin
derek72-Mar-06 14:11
derek72-Mar-06 14:11 
AnswerRe: TCP/IP define a IP address a 32b int Pin
Ryan Binns2-Mar-06 16:51
Ryan Binns2-Mar-06 16:51 
Questionweb browser control Pin
Sam 20062-Mar-06 13:25
Sam 20062-Mar-06 13:25 
AnswerRe: web browser control Pin
Mauro Leggieri2-Mar-06 16:14
Mauro Leggieri2-Mar-06 16:14 
AnswerRe: web browser control Pin
Ryan Binns2-Mar-06 16:52
Ryan Binns2-Mar-06 16:52 
AnswerRe: web browser control Pin
Michael Dunn2-Mar-06 20:29
sitebuilderMichael Dunn2-Mar-06 20:29 
GeneralRe: web browser control Pin
Sam 20063-Mar-06 12:05
Sam 20063-Mar-06 12:05 
QuestionAdd a CR Pin
samkook2-Mar-06 12:55
samkook2-Mar-06 12:55 
AnswerRe: Add a CR Pin
Stephen Hewitt2-Mar-06 13:09
Stephen Hewitt2-Mar-06 13:09 
GeneralRe: Add a CR Pin
samkook2-Mar-06 14:02
samkook2-Mar-06 14:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.