C++窗体应用程序
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了C++窗体应用程序,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2348字,纯文字阅读大概需要4分钟。
内容图文
看了一段时间的C++了,于是就想实战一下,看了网上的一些教程,用vs写一个窗体程序,拉起一个窗口,
本人想着从初级的入门开始,到以后可以根据自己的需求,写出一些上位机软件和一些工具方便自己调试单片机
用。
1 #include <windows.h> 2 #include <stdio.h> 3 #include <tchar.h> 4 #define WIN32_LEAN_AND_MEAN 5 #include <stdlib.h> 6 #include <malloc.h> 7 #include <memory.h> 8 #include "targetver.h" 9 #include "resource.h" 10 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 11 12 13 int APIENTRY wWinMain(_In_ HINSTANCE hInstance, 14 _In_opt_ HINSTANCE hPrevInstance, 15 _In_ LPWSTR lpCmdLine, 16 _In_ int nCmdShow) { 17 char szClassName[] = "MainWClass"; 18 WNDCLASSEX wndclass; 19 20 wndclass.cbSize = sizeof(wndclass); 21 wndclass.style = CS_HREDRAW | CS_VREDRAW; 22 wndclass.lpfnWndProc = WndProc; 23 wndclass.cbClsExtra = 0; 24 wndclass.cbWndExtra = 0; 25 wndclass.hInstance = hInstance; 26 wndclass.hIcon = ::LoadIcon(NULL,IDI_APPLICATION); 27 wndclass.hCursor = ::LoadCursor(NULL,IDC_ARROW); 28 wndclass.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH); 29 wndclass.lpszClassName = szClassName; 30 wndclass.lpszMenuName = NULL; 31 wndclass.hIconSm = NULL; 32 33 ::RegisterClassEx(&wndclass); 34 35 //创建主窗口 36 HWND hWnd = ::CreateWindowEx(0, 37 szClassName, //类名 38 "GUI", 39 WS_OVERLAPPEDWINDOW, 40 CW_USEDEFAULT, 41 CW_USEDEFAULT, 42 CW_USEDEFAULT, 43 CW_USEDEFAULT, 44 NULL, 45 NULL, 46 hInstance, 47 NULL); 48 49 if (!hWnd) { 50 ::MessageBox(NULL,"FAIL","ERROR",MB_OK); 51 return FALSE; 52 } 53 54 //显示窗口 55 ::ShowWindow(hWnd,nCmdShow); 56 ::UpdateWindow(hWnd); 57 58 //从消息队列中不断的轮询消息 59 MSG msg; 60 while (::GetMessage(&msg, NULL, 0, 0)) { 61 ::TranslateMessage(&msg); 62 ::DispatchMessage(&msg); 63 } 64 65 return (int)msg.wParam; 66 67 } 68 69 70 71 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) { 72 switch (message) 73 { 74 case WM_DESTROY: 75 ::PostQuitMessage(0); 76 break; 77 default: 78 break; 79 } 80 return DefWindowProc(hWnd,message,wparam,lparam); 81 }Windows 窗体
内容总结
以上是互联网集市为您收集整理的C++窗体应用程序全部内容,希望文章能够帮你解决C++窗体应用程序所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。