Original Post
i''ve got a sample program, source code like below:
// Windows Demo in C++
#include
// Forward declaration
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
class WinClass
{
public:
WinClass(WNDPROC WinProc, const char *className, HINSTANCE hInstance);
void Register()
{
::RegisterClass(&wc);
}
private:
WNDCLASS wc;
};
WinClass::WinClass(WNDPROC WinProc, const char *className, HINSTANCE hInstance)
{
wc.style = 0;
wc.lpfnWndProc = WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = ::LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = 0;
wc.lpszClassName = className;
}
class WinMaker
{
public:
WinMaker(): hWnd(0) {}
WinMaker(char const *caption,
char const *className,
HINSTANCE hInstance);
void Show(int nCmdShow)
{
::ShowWindow(hWnd,nCmdShow);
::UpdateWindow(hWnd);
}
protected:
HWND hWnd;
};
WinMaker::WinMaker(const char *caption, const char *className, HINSTANCE hInstance)
{
hWnd = ::CreateWindow(className,
caption,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
0,
0,
hInstance,
0);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR nCmdLine, int nCmdShow)
{
char className[] = "Winnie";
WinClass wc(WindowProcedure, className, hInstance);
wc.Register();
WinMaker wm("Hello Windows!", className, hInstance);
wm.Show(nCmdShow);
MSG msg;
int status;
while ((status = ::GetMessage(&msg, 0, 0, 0)) != 0)
{
if (status == -1)
return -1;
::DispatchMessage(&msg);
}
return msg.wParam;
}
// Window Procedure
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
:
ostQuitMessage(0);
return 0;
}
return ::DefWindowProc(hWnd, msg, wParam, lParam);
}
but i could not compile it, and comes with error message as following:
-------------------Configuration: Winnie - Win32 Debug--------------------
Compiling...
Winnie.cpp
Linking...
Winnie.obj : error LNK2001: unresolved external symbol "long __stdcall WindowProcedure(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProcedure@@YGJPAUHWND__@@IIJ@Z)
Debug/Winnie.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Winnie.exe - 2 error(s), 0 warning(s)
what is the problem? how could i solve it?
thanks
terry