怎样摆脱VCL让程序直接从WinMain进入程序,帮忙看一下代码,谢谢!
在BCB里新建了一个Win2000 Logo Application,删掉了所有生成的代码,可运行不了,总有Link错误
#include <windows.h>
const char lpCN[] = "NewWin";
LRESULT CALLBACK WindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int CALLBACK WinMain(HINSTANCE hCurrentInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow)
{
WNDCLASSEX wcex;
memset(&wcex,0,sizeof wcex);
wcex.cbSize = sizeof wcex;
wcex.style = CS_HREDRAW|CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hCurrentInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hbrBackground = (HBRUSH)COLOR_BTNFACE;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = lpCN;
wcex.hIconSm = NULL;
RegisterClassEx(&wcex);
HWND hWindow = CreateWindowEx(WS_EX_TOPMOST,lpCN,lpCN,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,100,100,NULL,NULL,hCurrentInstance,NULL);
ShowWindow(hWindow,iCmdShow);
UpdateWindow(hWindow);
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd,&ps);
char lpWords[] = "Keep Calm!";
TextOut(hdc,0,0,lpWords,lstrlen(lpWords));
EndPaint(hWnd,&ps);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}