Click here to Skip to main content
15,899,474 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMFC CreateCompatibleDC(), Drawtext() no display [Solved] Pin
econy16-Mar-14 16:23
econy16-Mar-14 16:23 
AnswerRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
CPallini16-Mar-14 23:41
mveCPallini16-Mar-14 23:41 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy17-Mar-14 3:01
econy17-Mar-14 3:01 
AnswerRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
Chris Losinger17-Mar-14 3:33
professionalChris Losinger17-Mar-14 3:33 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy17-Mar-14 4:09
econy17-Mar-14 4:09 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
Chris Losinger17-Mar-14 4:21
professionalChris Losinger17-Mar-14 4:21 
NewsRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy17-Mar-14 4:30
econy17-Mar-14 4:30 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
Chris Losinger17-Mar-14 5:02
professionalChris Losinger17-Mar-14 5:02 
whenever i need to draw on a dialog, i put a static 'frame' control in the place where i want to draw. then i get that control's rectangle and limit my drawing to that rect.

CRect outRect;
m_myDrawingRectControl.GetWindowRect(outRect);
ScreenToClient(outRect);


also, you should only do drawing in your CDialog's OnPaint method. if you need to trigger drawing from a timer, just call CDialog::InvalidateRect() with your control's rectangle (as above).

so:
void CDynamicShowTextDlg::OnTimer(UINT nIDEvent)
{ 
   CRect outRect;
   m_myDrawingRectControl.GetWindowRect(outRect);
   ScreenToClient(outRect);

   InvalidateRect(outRect);
}


void CDynamicShowTextDlg::OnPaint() 
{
     if (IsIconic())
     {
     ...}
   else
   {
      CRect outRect;
      m_myDrawingRectControl.GetWindowRect(outRect);
      ScreenToClient(outRect);

      CPaintDC dc(this); // device context for painting

      ...
do your drawing here.
use dc as the source for your CreateCompatible* stuff
     ...
      CDialog::OnPaint();
     }


GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy17-Mar-14 5:06
econy17-Mar-14 5:06 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy17-Mar-14 5:19
econy17-Mar-14 5:19 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
Chris Losinger17-Mar-14 5:34
professionalChris Losinger17-Mar-14 5:34 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy17-Mar-14 16:11
econy17-Mar-14 16:11 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
Chris Losinger18-Mar-14 1:41
professionalChris Losinger18-Mar-14 1:41 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
Chris Losinger18-Mar-14 1:44
professionalChris Losinger18-Mar-14 1:44 
GeneralRe: MFC CreateCompatibleDC(), Drawtext() no display Pin
econy18-Mar-14 2:26
econy18-Mar-14 2:26 
QuestionMFC set Control color question [Solved] Pin
econy16-Mar-14 11:13
econy16-Mar-14 11:13 
AnswerRe: MFC set Control color question Pin
CPallini16-Mar-14 22:29
mveCPallini16-Mar-14 22:29 
GeneralRe: MFC set Control color question Pin
econy17-Mar-14 1:58
econy17-Mar-14 1:58 
GeneralRe: MFC set Control color question Pin
CPallini17-Mar-14 2:52
mveCPallini17-Mar-14 2:52 
QuestionCompiling DLL - what is the sequence of compilation? SOLVED Pin
Vaclav_16-Mar-14 8:53
Vaclav_16-Mar-14 8:53 
AnswerRe: Compiling DLL - what is the sequence of compilation? Pin
Richard MacCutchan16-Mar-14 23:11
mveRichard MacCutchan16-Mar-14 23:11 
GeneralRe: Compiling DLL - what is the sequence of compilation? Pin
Vaclav_17-Mar-14 3:47
Vaclav_17-Mar-14 3:47 
GeneralRe: Compiling DLL - what is the sequence of compilation? Pin
Gisle Vanem17-Mar-14 4:00
Gisle Vanem17-Mar-14 4:00 
GeneralRe: Compiling DLL - what is the sequence of compilation? Pin
Richard MacCutchan17-Mar-14 4:16
mveRichard MacCutchan17-Mar-14 4:16 
GeneralRe: Compiling DLL - what is the sequence of compilation? Pin
Vaclav_17-Mar-14 7:42
Vaclav_17-Mar-14 7:42 

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.