Original Post
I am writting a windows wrapper class and I wanted the class constructor to accept a pointer to the WindowProcedure function. It gives this error:
main.cpp:8: invalid conversion from `LRESULT (*)(HWND__*, unsigned int,
unsigned int, long int)' to `LRESULT (*)(HWND__*, unsigned int, unsigned
int, long int)'
main.cpp:8: initializing argument 1 of `CWND::CWND(LRESULT (*)(HWND__*,
unsigned int, unsigned int, long int))'
Here is the code:
#include <windows.h>
#ifndef CWND_H
#define CWND_H
class CWND {
protected:
HWND m_hwnd; // handle to the window
HDC m_hdc; // handle to the window's device context (acquired at initialization)
MSG m_msg; // windows message
private:
public:
// Class Constructor / Deconstructor
CWND(LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM));
~CWND();
};
#endif
// Constructor
CWND::CWND(LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM))
{
}
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int main()
{
// construct the class
CWND *Window = new CWND(WndProc);
for(;
{
}
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
}
[edited by - Premonition on April 20, 2004 7:15:59 PM]