c++如何创建窗体程序,求详细步骤(win32)
来源:互联网 发布:联通4g网络模式 编辑:程序博客网 时间:2024/05/16 07:58
#include <windows.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){ static TCHAR szAppName[] = TEXT ("HelloWin") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR) ; return 0 ; } hwnd = CreateWindow (szAppName, // window class name TEXT ("The Hello Program"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL) ; // creation parameters ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ;}LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ HDC hdc ; PAINTSTRUCT ps ; RECT rect ; switch (message) { case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ; DrawText (hdc, TEXT ("Hello, Windows!"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ;}
http://bbs.csdn.net/topics/380262284
0 0
- c++如何创建窗体程序,求详细步骤(win32)
- Win32 创建窗体程序
- Win32创建窗体程序
- 如何创建一个win32程序
- 求win32下的多线程控制台程序(c实现)
- 创建win32透明窗体
- C如何写窗体程序
- 如何在VS2015创建动态库DLL(详细步骤)
- .NET创建Windows服务详细步骤(C#)
- java窗体程序更换皮肤方法详细步骤
- 用Visual Studio 2010 编写C程序(详细步骤)
- [c#] 通过 WIN32 API 实现嵌入程序窗体
- 如何获得WIN32 窗体中控件的样式属性(C#)
- 学习win32程序步骤
- 如何在linux下创建oracle数据库,求高手解决,我要具体的详细步骤,谢谢!
- WIN32基本窗体程序框架
- 创建Win32应用程序的步骤
- VS2012 下创建win32应用程序(不是win32 console 程序)
- Android Screen size说明
- PHP 采集程序 常用函数
- JAVA和C C++的异同
- 正则表达式
- 判断浏览器版本信息
- c++如何创建窗体程序,求详细步骤(win32)
- My97DatePicker学习
- angular 中的 DOM 操作
- cocos2dx遮罩失效的解决与分析
- C语言面试题-2
- directshow学习笔记第一天,第一章
- NameNode中几个关键的数据结构
- 删除所有.svn/.git
- 有用的Linux面试问题及答案