Mam taką klase:
#include <windows.h>
static TCHAR lpszAppName[] = TEXT( "API Windows" );
class playlist
{
public:
playlist(HINSTANCE hInstance);
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
MSG msg;
WNDCLASS wndclass;
HWND hWnd;
}
playlist::playlist(HINSTANCE hInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = MainWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszAppName;
RegisterClass(&wndclass);
hWnd = CreateWindow(lpszAppName, lpszAppName,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK playlist::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return(0L);
}
Jednak ona nie dziala:( Kompilator zwraca:
playlistclass.cpp ISO C++ forbids defining types within return type
playlistclass.cpp return type specification for constructor invalid
playlistclass.cpp: In constructor playlist::playlist(HINSTANCE__*)': playlistclass.cpp:21: no matches converting function
MainWndProc' to type `
LRESULT ()(struct HWND__, unsigned int, unsigned int, long int)'
playlistclass.cpp candidates are: LRESULT playlist::MainWndProc(HWND__*,
unsigned int, unsigned int, long int)
Co jest nie tak??