Click here to Skip to main content
15,888,014 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dameged files Pin
Christian Graus31-Jul-05 20:05
protectorChristian Graus31-Jul-05 20:05 
QuestionHow to access the I/O port under Windows2000 Pin
pantao55131-Jul-05 15:23
pantao55131-Jul-05 15:23 
AnswerRe: How to access the I/O port under Windows2000 Pin
Abbas_Riazi31-Jul-05 20:05
professionalAbbas_Riazi31-Jul-05 20:05 
AnswerRe: How to access the I/O port under Windows2000 Pin
Marc Soleda31-Jul-05 20:53
Marc Soleda31-Jul-05 20:53 
GeneralStatus bar problem Pin
TEOlivier31-Jul-05 10:57
TEOlivier31-Jul-05 10:57 
GeneralImages in Rich edit Pin
Aqueel31-Jul-05 8:06
Aqueel31-Jul-05 8:06 
GeneralRe: Images in Rich edit Pin
Trollslayer31-Jul-05 8:57
mentorTrollslayer31-Jul-05 8:57 
GeneralTrouble getting device context Pin
theFrenchHornet31-Jul-05 7:41
theFrenchHornet31-Jul-05 7:41 
I don't know how to correctly acquire the device context for a control. If I put similar code in the OnCtlColor routine where a pointer to the device context is provided, the code works. However, when I try setting the device context, the code doesn't work. Two samples are provided - the first is the code that doesn't work. I appreciate any help fixing it. Thank-you.

This code compiles and runs without error, but does not achieve the color change. (c_navValid is a text box control)
LOGFONT lf;
CDC* dc = new CDC;
dc->Attach(c_navValid.GetDC()->m_hDC);
         
GetFont()->GetObject(sizeof(lf), &lf);
font.CreateFontIndirect(&lf);

dc->SelectObject(&font);
dc->SetTextColor(RGB(0,100,0));
font.DeleteObject();

This code works.
HBRUSH CNavDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
 W_Position_Data_Type* pPositionMsg;
 pPositionMsg = (W_Position_Data_Type*)&CInMsgs::wPositionMsg;
	
 HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);

 if (pWnd->GetDlgCtrlID() == IDC_NAV_VALID)
 {
   if (pPositionMsg->Mode_Word.Nav_Valid)
   {
     LOGFONT lf;
     GetFont()->GetObject(sizeof(lf), &lf);
     font.CreateFontIndirect(&lf);
     pDC->SelectObject(&font);
     pDC->SetTextColor(RGB(0,100,0));
     font.DeleteObject();
   }
 }

GeneralRe: Trouble getting device context Pin
Michael Dunn31-Jul-05 19:56
sitebuilderMichael Dunn31-Jul-05 19:56 
GeneralRe: Trouble getting device context Pin
theFrenchHornet1-Aug-05 5:23
theFrenchHornet1-Aug-05 5:23 
GeneralEmbedding Text into PDF Pin
Abbas_Riazi31-Jul-05 1:16
professionalAbbas_Riazi31-Jul-05 1:16 
GeneralFinding the modem Pin
Y_R30-Jul-05 23:19
Y_R30-Jul-05 23:19 
GeneralRe: Finding the modem Pin
Abbas_Riazi31-Jul-05 1:18
professionalAbbas_Riazi31-Jul-05 1:18 
GeneralRe: Finding the modem Pin
Y_R31-Jul-05 10:32
Y_R31-Jul-05 10:32 
GeneralRe: Finding the modem Pin
Abbas_Riazi31-Jul-05 20:02
professionalAbbas_Riazi31-Jul-05 20:02 
GeneralEdit Control Pin
khlins30-Jul-05 22:13
khlins30-Jul-05 22:13 
GeneralRe: Edit Control Pin
vishalmore30-Jul-05 22:58
vishalmore30-Jul-05 22:58 
Questionshellexecute get handle ? Pin
vantran0430-Jul-05 16:16
vantran0430-Jul-05 16:16 
AnswerRe: shellexecute get handle ? Pin
vishalmore30-Jul-05 23:58
vishalmore30-Jul-05 23:58 
AnswerRe: shellexecute get handle ? Pin
ThatsAlok31-Jul-05 2:44
ThatsAlok31-Jul-05 2:44 
AnswerRe: shellexecute get handle ? Pin
Blake Miller1-Aug-05 7:54
Blake Miller1-Aug-05 7:54 
GeneralLinked list, passing a pointer Pin
bitsNbites30-Jul-05 15:49
bitsNbites30-Jul-05 15:49 
GeneralRe: Linked list, passing a pointer Pin
John M. Drescher30-Jul-05 18:04
John M. Drescher30-Jul-05 18:04 
GeneralRe: Linked list, passing a pointer Pin
S. Senthil Kumar31-Jul-05 4:20
S. Senthil Kumar31-Jul-05 4:20 
QuestionHow to manipulate ActiveDesktop buttons Pin
programvinod30-Jul-05 14:04
programvinod30-Jul-05 14:04 

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.