draw on a dialog
-
Hello, I'm trying to draw on a dialog but I'm having no luck with the following code. It's my first time doing any gdi/device context stuff. I know there's better ways to display info than writing directly to a dialog but it's a bit of a hack. If anybody can help, thank-you. John //in oninitdialog CPaintDC dc(this); // device context for painting CPen* oldPen; CPen pen(PS_SOLID, 1, RGB(0,0,0)); oldPen = dc.SelectObject(&pen); dc.TextOut(20,20,"Mean Flow Velocity (m/s)"); dc.SelectObject(oldPen);
-
Hello, I'm trying to draw on a dialog but I'm having no luck with the following code. It's my first time doing any gdi/device context stuff. I know there's better ways to display info than writing directly to a dialog but it's a bit of a hack. If anybody can help, thank-you. John //in oninitdialog CPaintDC dc(this); // device context for painting CPen* oldPen; CPen pen(PS_SOLID, 1, RGB(0,0,0)); oldPen = dc.SelectObject(&pen); dc.TextOut(20,20,"Mean Flow Velocity (m/s)"); dc.SelectObject(oldPen);
Hi, You r not supposed to use the drawing code in OnInitDialog and more over CPaintDC should be used only when processing the WM_PAINT msg i.e only in OnPaint.(How abt brushing up a bit on the documentation ?) So move you code to OnPaint.
-
Hi, You r not supposed to use the drawing code in OnInitDialog and more over CPaintDC should be used only when processing the WM_PAINT msg i.e only in OnPaint.(How abt brushing up a bit on the documentation ?) So move you code to OnPaint.
Thanks Prem It works now. I'm using the following in OnPaint... CFont* pFont; CFont* pOrigFont; pFont= GetFont(); pOrigFont = pdc->SelectObject(pFont); pdc->SetBkColor(GetSysColor(COLOR_BTNFACE)); pdc->TextOut(40,40,"Mean Flow Velocity (m/s)");