|
-
June 4th, 2006, 12:42 AM
#1
drawing in the dialog
I am trying to draw something in a modeless dialog in some where other than OnPaint member function. I used a bitmap to save the drawing and show it in OnPaint. like this
void CMyDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
MemDC.TextOut(10, 10, "text 1");
CBitmap* pOldBmp = MemDC.SelectObject(&m_Bmp);
dc.BitBlt(0, 0, 100, 100, &MemDC, 0, 0, SRCCOPY);
MemDC.SelectObject(pOldBmp);
}
and did some drawing in another function
void CMyDialog: raw()
{
CClientDC dc(this);
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
CBitmap *pOldBmp = MemDC.SelectObject(&m_Bmp);
MemDC.TextOut(10, 30, "text 2");
MemDC.SelectObject(pOldBmp);
}
And after I create this modeless dialog, I ran Draw(). But only "text 1" was shown on the dialog, "text 2" was not. I know this method can be used in Doc/View without any problem, but why it didnot work in dialogs?
could you help me? thank you!
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
|