#include<Windows.h>
#include<iostream>
#include<stdio.h>
#ifdef _UNICODE
#define __T(x) L ## x
#else
#define __T(x) x
#endif
#define _T(x) __T(x)
#define _TEXT __T(x)
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nShowCmd
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra = 0;
wndcls.cbWndExtra = 0;
wndcls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor = LoadCursor(NULL, IDC_ARROW);
wndcls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndcls.hInstance = hInstance;
wndcls.lpfnWndProc = WinSunProc;
wndcls.lpszClassName = _T("winxin2003");
wndcls.lpszMenuName = NULL;
wndcls.style = CS_HREDRAW || CS_VREDRAW;
RegisterClass(&wndcls);
HWND hwnd;
hwnd = CreateWindow(_T("weixin2003"), _T("winxin"), WS_OVERLAPPEDWINDOW, 0, 0, 600, 400, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf_s(szChar, "char is %d", wParam);
MessageBoxA(hwnd, szChar, "weixin", 0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd, _T("mose clicked"), _T("weixin"), 0);
HDC hdc;
hdc = GetDC(hwnd);
TextOut(hdc, 0, 50, _T("天佑中华"), strlen("天佑中华"));
ReleaseDC(hwnd, hdc);
break;
case WM_PAINT:
HDC hdc1;
PAINTSTRUCT ps;
hdc1 = BeginPaint(hwnd, &ps);
TextOut(hdc1, 0, 0, _T("测试实例一二三四"), strlen("测试实例一二三四"));
EndPaint(hwnd, &ps);
break;
case WM_CLOSE:
if (IDYES == MessageBox(hwnd, _T("是否真的结束"), _T("weixin"), MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
错误 LNK2019 无法解析的外部符号 _main,函数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 中引用了该符号 ConsoleApplication2
错误 LNK1120 1 个无法解析的外部命令