win32程序--使用dev-cpp

简介:

 

 
  1. #include <windows.h> 
  2.  
  3. /*  声明窗口过程  */ 
  4. LRESULT CALLBACK WindowProcedure (HWNDUINTWPARAMLPARAM); 
  5.  
  6. /*  声明一个全局的窗口类变量 */ 
  7. char szClassName[ ] = "WindowsApp";//窗口类名  
  8.  
  9. /* 主入口函数 */  
  10. int WINAPI WinMain (HINSTANCE hThisInstance, 
  11.                     HINSTANCE hPrevInstance, 
  12.                     LPSTR lpszArgument, 
  13.                     int nFunsterStil) 
  14.  
  15.     HWND hwnd;               /* 窗口句柄 */ 
  16.     MSG messages;            /* 消息结构:存储应用程序的消息 */ 
  17.     WNDCLASSEX wincl;        /* Data structure for the windowclass */ 
  18.  
  19.     /* The Window structure */ 
  20.     wincl.hInstance = hThisInstance; 
  21.     wincl.lpszClassName = szClassName; 
  22.     wincl.lpfnWndProc = WindowProcedure;      /* 此函数由Windows调用 */ 
  23.     wincl.style = CS_DBLCLKS;                 /* 捕捉双击 */ 
  24.     wincl.cbSize = sizeof (WNDCLASSEX); 
  25.  
  26.     /* 使用默认的图标和鼠标光标 */ 
  27.     wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); 
  28.     wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); 
  29.     wincl.hCursor = LoadCursor (NULL, IDC_ARROW); 
  30.     wincl.lpszMenuName = NULL;                 /* 窗体无菜单 */ 
  31.     wincl.cbClsExtra = 0;                      /* 字节数:不在窗口类之后预留空间 */ 
  32.     wincl.cbWndExtra = 0;                      /* structure or the window instance */ 
  33.     /* 使用Windows默认的颜色作为窗体的背景色 */ 
  34.     wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; 
  35.  
  36.     /* 注册窗口类,如果失败则程序退出 */ 
  37.     if (!RegisterClassEx (&wincl)) 
  38.         return 0; 
  39.  
  40.     /* 窗口类注册后,接着创建窗体 */ 
  41.     hwnd = CreateWindowEx ( 
  42.            0,                   /* Extended possibilites for variation */ 
  43.            szClassName,         /* 类名 */ 
  44.            "Windows App",       /* 窗口标题文本 */ 
  45.            WS_OVERLAPPEDWINDOW, /* 默认的窗体风格 */ 
  46.            CW_USEDEFAULT,       /* Windows确定x,y */ 
  47.            CW_USEDEFAULT,        
  48.            544,                 /* 窗体的像素尺寸 */ 
  49.            375,                  
  50.            HWND_DESKTOP,        /* 此窗体为desktop的子窗口。 */ 
  51.            NULL,                /* 无菜单 */ 
  52.            hThisInstance,       /* 应用程序实例句柄 */ 
  53.            NULL                 /* 无窗体创建参数 */ 
  54.            ); 
  55.  
  56.     /* 显示窗体 */ 
  57.     ShowWindow (hwnd, nFunsterStil); 
  58.  
  59.     /* 执行消息循环. 直到GetMessage()返回0 */ 
  60.     while (GetMessage (&messages, NULL, 0, 0)) 
  61.     { 
  62.         /* 将虚拟键消息转换为字符消息 */ 
  63.         TranslateMessage(&messages); 
  64.         /* 将消息发给窗口过程 */ 
  65.         DispatchMessage(&messages); 
  66.     } 
  67.  
  68.     /* 程序返回值为0----PostQuitMessage()给出。 */ 
  69.     return messages.wParam; 
  70.  
  71.  
  72. /*  此函数由Windows函数DispatchMessage()调用  */ 
  73.  
  74. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
  75.     switch (message)                  /* 处理消息 */ 
  76.     { 
  77.         case WM_DESTROY: 
  78.             PostQuitMessage (0);       /* 发送一个WM_QUIT到消息队列 ,此消息使GetMessage()返回 0*/ 
  79.             break
  80.         default:                      /* 对于我们不想处理的消息,采用默认处理 */ 
  81.             return DefWindowProc (hwnd, message, wParam, lParam); 
  82.     } 
  83.  
  84.     return 0; 

 



 本文转自 xcf007 51CTO博客,原文链接:http://blog.51cto.com/xcf007/555463,如需转载请自行联系原作者

相关文章
|
6月前
|
C++
[c++][记录]编译libusb-win32过程
[c++][记录]编译libusb-win32过程
|
17天前
STM32 ST-LINK Utility程序烧录方法
STM32 ST-LINK Utility程序烧录方法
|
3月前
|
Linux
Log4cpp在Linux下载编译
Log4cpp在Linux下载编译
|
Windows
WINDOWS编译ffmpeg:LINK : fatal error LNK1104: 无法打开文件“LIBCMT.lib”
WINDOWS编译ffmpeg:LINK : fatal error LNK1104: 无法打开文件“LIBCMT.lib”
338 0
Linux Command cmp 文件比较
Linux Command cmp 文件比较
|
Linux 计算机视觉
Linux下OpenCV出现错误:ASSERT false in file qasciikey.cpp, line 501
Linux下OpenCV出现错误:ASSERT false in file qasciikey.cpp, line 501
112 2
|
C++
C++Qt | 无法打开源文件:“x64\Debug\moc_xxx.cpp”怎么办。
编译时报错: 1>c1xx : fatal error C1083: 无法打开源文件:“x64\Debug\Res\src\Vlc\include\moc_AVPlayer.cpp”: No such file or directory的解决办法。
329 0
|
内存技术 芯片
MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL
MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL   是因为目标板的芯片处于休眠的状态,在尝试连接目标板时候也会出现报错Internal command ...
3494 0
|
程序员 C++
VS2015+Qt5.9.1编译报错:Moc系统找不到指定路径,error MSB6006 cmd.exe 已退出,代码为3 -- 完美解决
VS2015+Qt5.9.1编译报错:Moc系统找不到指定路径,error MSB6006 cmd.exe 已退出,代码为3 -- 完美解决
2308 0
Qt在pro中设置运行时库MT、MTd、MD、MDd
Qt在pro中设置运行时库MT、MTd、MD、MDd
631 0