Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CNoFlickerWnd error
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CNoFlickerWnd error

 Post Reply Post Reply
Author
Message
evoX View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 July 2007
Status: Offline
Points: 207
Post Options Post Options   Thanks (0) Thanks(0)   Quote evoX Quote  Post ReplyReply Direct Link To This Post Topic: CNoFlickerWnd error
    Posted: 27 September 2007 at 1:09pm
I have this CNoFlickerWnd class

emplate<class BASE_CLASS>

class CNoFlickerWnd : public BASE_CLASS

{

protected:

virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam)

{

switch (message)

{

case WM_PAINT:

{

CPaintDC dc(this);

// Get the client rect, and paint to a memory device context.

// This will help reduce screen flicker. Pass the memory

// device context to the default window procedure to do

// default painting.

CXTPClientRect rc(this);

CXTPBufferDC memDC(dc, rc);

memDC.FillSolidRect(rc, GetXtremeColor(COLOR_WINDOW));

return BASE_CLASS::DefWindowProc(WM_PAINT,

(WPARAM)memDC.m_hDC, 0);

}

case WM_ERASEBKGND:

return TRUE;

}

return BASE_CLASS::WindowProc(message, wParam, lParam);

}

};

 

and I have my class defined like this:

class CMyView : public CNoFlickerWnd<CFormView>

Why I get this error?
Error 202 error C2512: 'CNoFlickerWnd<BASE_CLASS>' : no appropriate default constructor available d:\vs\projects\test\testview.cpp 118 
Error 203 error C2614: 'CMyView' : illegal member initialization: 'CFormView' is not a base or member d:\vs\projects\test\testview.cpp 118 
Back to Top
kstowell View Drop Down
Admin Group
Admin Group


Joined: 25 January 2003
Location: MIchigan, USA
Status: Offline
Points: 496
Post Options Post Options   Thanks (0) Thanks(0)   Quote kstowell Quote  Post ReplyReply Direct Link To This Post Posted: 27 September 2007 at 2:04pm
Hi,
 
This template was not intended to be used as a base class, a correct implementation would be:
 
public:
    CNoFlickerWnd<CSomeWnd>  m_wndSomeVar;
 
If you want to use this as a base class you could probably do it with some minor modifications by adding a constructor, however for what it is worth, it might be just as easy to add "virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam)" to your form view derived class and cut-n-paste the code from the template class, for example:
 
MyView.h:
 

protected:
    virtual LRESULT CMyView::WindowProc(UINT message,WPARAM wParam,LPARAM lParam);
 
MyView.cpp:
 

LRESULT CMyView::WindowProc(UINT message,WPARAM wParam,LPARAM lParam)
{
    switch (message)
    {
        case WM_PAINT:
        {
            CPaintDC dc(this);

            // Get the client rect, and paint to a memory device context.
            // This will help reduce screen flicker. Pass the memory
            // device context to the default window procedure to do
            // default painting.
            CXTPClientRect rc(this);
            CXTPBufferDC memDC(dc, rc);
            memDC.FillSolidRect(rc, GetXtremeColor(COLOR_WINDOW));

            return CFormView::DefWindowProc(WM_PAINT,(WPARAM)
                memDC.m_hDC, 0);
        }
        case WM_ERASEBKGND:
            return TRUE;
    }
    return CFormView::WindowProc(message, wParam, lParam);
}
 
Cheers,
Kirk Stowell, President and CEO
CODEJOCK SOFTWARE SOLUTIONS<
Back to Top
evoX View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 July 2007
Status: Offline
Points: 207
Post Options Post Options   Thanks (0) Thanks(0)   Quote evoX Quote  Post ReplyReply Direct Link To This Post Posted: 27 September 2007 at 2:15pm
ok, thanks !
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.059 seconds.