-
March 12th, 2014, 08:02 PM
#1
MFC CDC HDC issue
I am a bit of a noob so go easy here
I am creating an MFC app with a main window class CDataDlg.
The .h file has public method declaration:
static void CDataDlg::toScreen();
This is a simple routine to dump some buffered context to screen via BitBlt:
CDC* pDC = GetDC();
BitBlt(pDC->GetSafeHdc(),0,0,width,height, hdcMem, 0, 0, SRCCOPY);
The idea is to draw a picture directly on main window background.
This worked great, so long as the method was not static. Of course, once I made it static (as explained above), I lost the ability to call GetDC().
I tried the following:
hWnd = AfxGetApp()->m_pMainWnd->m_hWnd;
CWnd* mycw = FromHandlePermanent(hWnd);
CDC* pDC = mycw->GetDC();
But that fails miserably because mycw ends up NULL. In general, this chain of seeking a drawing context is very fishy to me. Any recommendations?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|