这段代码没有使用vcl类库,为什么要#include ?
wiw 2003-08-04 10:41:41 #include <windows.h>
#include <windowsx.h>
LRESULT CALLBACK WinProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
bool InitWindow(HINSTANCE hInstance,int nCmdShow);
//---------------------------------------------------------------------------
int pascal WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
if(!InitWindow(hInstance,nCmdShow))
return false;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.lParam;
}
//---------------------------------------------------------------------------
static bool InitWindow(HINSTANCE hInstance,int nCmdShow)
{
HWND hwnd;
WNDCLASS wc;
wc.style=0;
wc.lpfnWndProc=WinProc;
wc.cbClsExtra =0;
wc.cbWndExtra =0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(hInstance,IDI_APPLICATION);
wc.hCursor=LoadCursor(hInstance,IDC_ARROW);
wc.hbrBackground=GetStockObject(BLACK_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName="dxHello";
RegisterClass(&wc);
hwnd=CreateWindowEx(0,"dxHello","",WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hInstance,NULL);
if(!hwnd)return false;
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
return true;
}
LRESULT CALLBACK WinProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostMessage(hWnd,WM_CLOSE,0,0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,message,wParam,lParam);
}
否则提示
[Linker Error] Unresolved external '__InitVCL' referenced from D:\BORLAND\CBUILDER6\LIB\CP32MTI.LIB|crtlvcl
[Linker Error] Unresolved external '__ExitVCL' referenced from D:\BORLAND\CBUILDER6\LIB\CP32MTI.LIB|crtlvcl