15,976
社区成员
发帖
与我相关
我的任务
分享
long CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
{
MessageBox(hWnd, "创建窗口", "aaa", MB_OK);
}
else if (uMsg == WM_CLOSE)
{
PostQuitMessage(0);
DestroyWindow(hWnd);
}
else
DefWindowProc(hWnd, uMsg, wParam, lParam);
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
#include <windows.h>
#include <stdio.h>
long CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
WNDCLASSEX stMyclass;
MSG stMsg; HWND hWindow;
//char* ClassName = "MyClass";
//char* CaptionName = "时钟";
// 注册窗口类
RtlZeroMemory(&stMyclass, sizeof(stMyclass));
stMyclass.cbSize = sizeof(stMyclass);
stMyclass.hInstance = hInstance;
stMyclass.hIcon = LoadIcon(0, IDI_APPLICATION);
stMyclass.hIconSm = LoadIcon(0, IDI_APPLICATION);
stMyclass.hCursor = LoadCursor(0, IDC_ARROW);
stMyclass.lpszClassName = "MyClass";
stMyclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
stMyclass.style = CS_HREDRAW | CS_VREDRAW;
stMyclass.lpfnWndProc = WinProc;
RegisterClassEx(&stMyclass);
// 创建窗口
hWindow = CreateWindowEx(WS_EX_CLIENTEDGE, "MyClass", "Clock",
WS_OVERLAPPEDWINDOW, 200, 200, 200, 200, NULL, NULL, hInstance, NULL);
ShowWindow(hWindow, SW_SHOWNORMAL);
UpdateWindow(hWindow);
// 消息循环
while (GetMessage(&stMsg, NULL, 0, 0))
{
TranslateMessage(&stMsg);
DispatchMessage(&stMsg);
}
return 0;
}
long CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
{
MessageBox(hWnd, "创建窗口", "aaa", MB_OK);
}
else if (uMsg == WM_CLOSE)
{
PostQuitMessage(0);
DestroyWindow(hWnd);
}
else
DefWindowProc(hWnd, uMsg, wParam, lParam);
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}long CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
{
MessageBox(hWnd, "创建窗口", "aaa", MB_OK);
}
else if (uMsg == WM_CLOSE)
{
PostQuitMessage(0);
DestroyWindow(hWnd);
}
else
return DefWindowProc(hWnd, uMsg, wParam, lParam); //改这一句增加 return
return 0;
}
long CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
{
MessageBox(hWnd, "创建窗口", "aaa", MB_OK);
}
else if (uMsg == WM_CLOSE)
{
PostQuitMessage(0);
DestroyWindow(hWnd);
}
else
{
DefWindowProc(hWnd, uMsg, wParam, lParam);
return 1;
}
return 0;
}
long CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
{
MessageBox(hWnd, "创建窗口", "aaa", MB_OK);
}
else if (uMsg == WM_CLOSE)
{
PostQuitMessage(0);
DestroyWindow(hWnd);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);;
}