#include <windows.h>
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
){
static LPCTSTR lpszClassName = TEXT("HelloWin");
LPCTSTR lpWindowName = TEXT("MyApp");
HWND hwnd;
MSG msg;
//http://www.pythonschool.com/
WNDCLASS wndclass = {
CS_HREDRAW|CS_VREDRAW,
WindowProc,
0,
0,
hInstance,
LoadIcon(hInstance, IDI_ERROR),
LoadCursor(hInstance, IDC_CROSS),
(HBRUSH)GetStockObject(WHITE_PEN),
(LPCTSTR)NULL,
lpszClassName
} ;
if(!RegisterClass(&wndclass))
return FALSE;
hwnd = CreateWindow(
lpsz
C++实例 窗口和消息 处理关闭窗口消息 是否关闭
最新推荐文章于 2019-05-30 09:02:03 发布
本文展示了一个C++ Windows应用程序的例子,详细介绍了如何处理窗口关闭消息,并在用户尝试关闭窗口时弹出确认对话框。通过注册窗口类、创建窗口、消息循环以及定义WindowProc回调函数,实现了当用户点击关闭按钮时,显示'Hello'和'World!'的确认对话框,根据用户的选择决定是否真正关闭窗口。
摘要由CSDN通过智能技术生成