-
April 6th, 2004, 07:07 AM
#1
OnEraseBackground
Hi gurus.
I have some problems overriding OnEraseBackground in my MFC dialog-based applications (the framework doesn't call my override).
Can anyone suggest how to handle this matter?
(before you ask: yes, I added the OnEraseBackground declaration in the message map... well, at leas I think I didi it properly )
Thanks!
-
April 6th, 2004, 07:35 AM
#2
can u plz come up with some amount of code??
-
April 6th, 2004, 07:37 AM
#3
The best way to "override OnEraseBackground" would be to let ClassWizard add Windows message handler WM_ERASEBKGND into your class.
After doing this you'd have to get
a) in your header:
Code:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
b) in your cpp:
Code:
BEGIN_MESSAGE_MAP(<your_class> ,<Base_class>)
//{{AFX_MSG_MAP(<your_class>)
ON_WM_ERASEBKGND()
.............
//}}AFX_MSG_MAP
............
BOOL <your_class>::OnEraseBkgnd(CDC* pDC)
{
return <Base_class>::OnEraseBkgnd(pDC);
}
-
April 6th, 2004, 08:00 AM
#4
Hey,
Once i also had the same problem. But it figured out that i was returning from the function before actual code.
some thing like
BOOL <your_class>::OnEraseBkgnd(CDC* pDC)
{
return <Base_class>::OnEraseBkgnd(pDC);
//your own code
}
In case this is the problem.
Amit
-
April 6th, 2004, 10:11 AM
#5
Ok... VictorN helped me understand... I forgot to put "ON_WM_ERASEBKGND()" in the message map...
Sorry for the silly question... crunch time is almost killing me!
P.S. VictorN, you wrote
BOOL <your_class>::OnEraseBkgnd(CDC* pDC)
{
return <Base_class>::OnEraseBkgnd(pDC);
}
...I think the function should return TRUE if it handles the background erasing task, right?
-
April 6th, 2004, 10:21 AM
#6
...I think the function should return TRUE if it handles the background erasing task, right?
Yes!
Sorry, i forgot to paste the rest of my code in OnEraseBkgnd() body.
Code:
BOOL <myClass>::OnEraseBkgnd(CDC* pDC)
{
if(<I do smth. myself>)
{
// do it
return TRUE;
}
else
return <aseClass>::OnEraseBkgnd(pDC);
}
-
April 6th, 2004, 12:10 PM
#7
Originally posted by Amit Sebiz
Once i also had the same problem. But it figured out that i was returning from the function before actual code.
some thing like
BOOL <your_class>::OnEraseBkgnd(CDC* pDC)
{
return <Base_class>::OnEraseBkgnd(pDC);
//your own code
}
The compiler would produce a warning (level 4) about unreachable code in such case.
You should really read your compiler output. Oh, and set your Warning Level to 4 (if it isn't yet).
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
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
|