Click here to Skip to main content
15,921,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CView in a Dialog box Pin
Carlos Antollini7-Dec-01 2:25
Carlos Antollini7-Dec-01 2:25 
GeneralRe: CView in a Dialog box Pin
Lars Dirks7-Dec-01 1:33
Lars Dirks7-Dec-01 1:33 
GeneralRe: CView in a Dialog box Pin
#realJSOP7-Dec-01 1:49
professional#realJSOP7-Dec-01 1:49 
GeneralRe: CView in a Dialog box Pin
Giles7-Dec-01 2:59
Giles7-Dec-01 2:59 
GeneralRe: CView in a Dialog box Pin
#realJSOP7-Dec-01 3:14
professional#realJSOP7-Dec-01 3:14 
GeneralPropertysheet of ActiveX Pin
Mazdak6-Dec-01 7:15
Mazdak6-Dec-01 7:15 
GeneralRe: Propertysheet of ActiveX Pin
J Patel7-Dec-01 11:38
J Patel7-Dec-01 11:38 
QuestionNever-ending WM_PAINT messages!!? Pin
Jamie Hale6-Dec-01 5:30
Jamie Hale6-Dec-01 5:30 
I have several applications that use custom CWnd controls. And for some reason, when I use GetDC() and ReleaseDC() while handling a WM_PAINT message, as soon as OnPaint() is done, it gets called again. This craziness seems to go away when I use a local CPaintDC.

Trouble is, I'm now trying to fix an old app that uses a seperate thread to handle the drawing. OnPaint() puts a custom PAINT message in a queue for the thread, which in turn uses GetDC() on a hWnd (GetSafeHwnd()). I can't seem to construct a CPaintDC without MFC ASSERTing that the CWnd is invalid.

void OnPaint() {
  queue.PushEvent(PAINT, currentRange);
}

int ThreadProc(CWnd *pWnd) {
  while(1) {
    t = queue.PopEvent();
    switch(t) {
      case PAINT:
        HWND hWnd = pWnd->GetSafeHwnd();
        HDC hDC = GetDC(hWnd);
        CDC *pDC = CDC::FromHandle(hDC);
        ...
        ReleaseDC(hWnd, hDC);
        break;
      ...
    }
  }
}


When I try CPaintDC dc(pWnd), it ASSERTs.

So...

Q1) Has anyone else ever seen the never-ending stream of WM_PAINT messages? And if so, any idea how to prevent it?

Q2) Can anyone come up with a nice way of creating a CPaintDC from a CWnd inside a thread? I can't easily (and safely) create the DC outside the thread and pass it in.

J
AnswerFixed it I think... Pin
Jamie Hale6-Dec-01 6:42
Jamie Hale6-Dec-01 6:42 
GeneralDraw problem Pin
6-Dec-01 3:45
suss6-Dec-01 3:45 
GeneralRe: Draw problem Pin
Michael P Butler6-Dec-01 3:57
Michael P Butler6-Dec-01 3:57 
GeneralPainting dialog background Pin
6-Dec-01 4:12
suss6-Dec-01 4:12 
GeneralRe: Painting dialog background Pin
Christian Graus6-Dec-01 9:17
protectorChristian Graus6-Dec-01 9:17 
GeneralRe: Painting dialog background Pin
Michael Dunn6-Dec-01 9:33
sitebuilderMichael Dunn6-Dec-01 9:33 
GeneralLooking for panacea...Type of the control...I have only CWnd pointer Pin
Ahmad996-Dec-01 3:07
Ahmad996-Dec-01 3:07 
GeneralRe: Looking for panacea...Type of the control...I have only CWnd pointer Pin
Rickard Andersson206-Dec-01 3:24
Rickard Andersson206-Dec-01 3:24 
GeneralRe: Looking for panacea...Type of the control...I have only CWnd pointer Pin
Jon Hulatt6-Dec-01 6:06
Jon Hulatt6-Dec-01 6:06 
GeneralRe: Looking for panacea...Type of the control...I have only CWnd pointer Pin
Alvaro Mendez6-Dec-01 10:13
Alvaro Mendez6-Dec-01 10:13 
GeneralRe: Looking for panacea...Type of the control...I have only CWnd pointer Pin
Jon Hulatt6-Dec-01 22:29
Jon Hulatt6-Dec-01 22:29 
GeneralPlease Help !!! Pin
The_Server6-Dec-01 1:26
The_Server6-Dec-01 1:26 
GeneralRe: Please Help !!! Pin
Jon Hulatt6-Dec-01 2:28
Jon Hulatt6-Dec-01 2:28 
GeneralRe: Please Help !!! Pin
Christian Graus6-Dec-01 9:19
protectorChristian Graus6-Dec-01 9:19 
GeneralEnum... Pin
Bernhard6-Dec-01 1:10
Bernhard6-Dec-01 1:10 
GeneralRe: Enum... Pin
BlackSmith6-Dec-01 11:00
BlackSmith6-Dec-01 11:00 
GeneralThank you all for your great help Pin
Bernhard6-Dec-01 19:20
Bernhard6-Dec-01 19:20 

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.