0

I'm trying to wrap a gui library for windows, but I'm running into some problems. I have an event handler WinProc in my WindosBase class, I want to initialize lpfnWndProc in the initialization function, but I have a problem.

class WindowBase  //this is WindowBase
{
public:
    LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
    WindowBase();
    virtual ~WindowBase();
    ..... 
}

WindowBase::WindowBase() // this is part of initialization func
{
    g_windowBase = this;
    wcs.style          = CS_HREDRAW | CS_VREDRAW;
    wcs.lpfnWndProc    = WinProc;
    wcs.cbClsExtra     = 0;
    wcs.cbWndExtra     = 0;
    wcs.hInstance      = g_hInstance;
    wcs.hIcon          = 0;
    wcs.hCursor        = LoadCursor(nullptr, IDC_ARROW);
    wcs.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcs.lpszMenuName   = 0;
    wcs.lpszClassName  = this->szWindowClass;
    .....
}

I thought it was right, but something happened
(g++ 8.1.0)

 error: cannot convert 'WindowBase::WinProc' from type 'LRESULT (WindowBase::)(HWND, UINT, WPARAM, LPARAM)' {aka 'long long int (WindowBase::)(HWND__*, unsigned int, long long unsigned int, long long int)'} to type 'WNDPROC' {aka 'long long int (*)(HWND__*, unsigned int, long long unsigned int, long long int)'}

Is there a common way to solve this problem, or how is it done in other windows gui libraries.
very thank.:)

dbush
  • 186,650
  • 20
  • 189
  • 240
wanxin
  • 23
  • 2

0 Answers0