Trouble with OnDraw function

P

Peter

Hi,
I try to display a simple text on the screen (MFC). I used
CMyAppView::OnDraw function but the application doesn't call it while
running. I tried to overload CMyAppView::OnUpdate(...) function and
inside call the OnDraw. The code looks like this:
void CMyAppView::OnUpdate(...)
{
//...//
CDC* pDC = GetDC();
this->OnDraw(pDC);
}
////////////////////////////////
void CMyAppView::OnDraw(CDC* pDC)
{
//...//
pDC->TextOut(1,1,"Display this text!");
}
And of course the OnDraw is now called but the TextOut don't display
anything!
The program does not generate any errors during compilation nor while
running, yet the text does no appear on the screen. Why is that and
what to do with it ?
Thanks in advance
Peter
 
S

Skyler York

Peter said:
Hi,
I try to display a simple text on the screen (MFC). I used
CMyAppView::OnDraw function but the application doesn't call it while
running. I tried to overload CMyAppView::OnUpdate(...) function and
inside call the OnDraw. The code looks like this:
void CMyAppView::OnUpdate(...)
{
//...//
CDC* pDC = GetDC();
this->OnDraw(pDC);
}
////////////////////////////////
void CMyAppView::OnDraw(CDC* pDC)
{
//...//
pDC->TextOut(1,1,"Display this text!");
}
And of course the OnDraw is now called but the TextOut don't display
anything!
The program does not generate any errors during compilation nor while
running, yet the text does no appear on the screen. Why is that and
what to do with it ?
Thanks in advance
Peter
How did you add the function? The function needs to be bound to the
WM_PAINT message. If you use MSVC's built-in message handler wizard, it
will follow all the necessary steps to bind your function to the message
map. Otherwise, you'll have to do it manually.
 
J

John Harrison

Peter said:
Hi,
I try to display a simple text on the screen (MFC). I used
CMyAppView::OnDraw function but the application doesn't call it while
running. I tried to overload CMyAppView::OnUpdate(...) function and
inside call the OnDraw. The code looks like this:
void CMyAppView::OnUpdate(...)
{
//...//
CDC* pDC = GetDC();
this->OnDraw(pDC);
}
////////////////////////////////
void CMyAppView::OnDraw(CDC* pDC)
{
//...//
pDC->TextOut(1,1,"Display this text!");
}
And of course the OnDraw is now called but the TextOut don't display
anything!
The program does not generate any errors during compilation nor while
running, yet the text does no appear on the screen. Why is that and
what to do with it ?
Thanks in advance
Peter

This is a question about Windows programming not C++. You are off topic
here. Try a Windows programming group such as

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top