这段代码没有使用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

...全文
100 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧