#include <windows.h> LONG WINAPI WndProc(HWND, UINT,WPARAM,LPARAM); //回调原型 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASS wc; HWND hwnd; MSG msg; //1.设计窗体 wc.style = 0; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL,IDI_WINLOGO); wc.hCursor = LoadCursor(NULL,IDC_ARROW); //wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.hbrBackground = (HBRUSH)(COLOR_GRAYTEXT); wc.lpszMenuName = NULL; wc.lpszClassName = "MyWndClass"; RegisterClass(&wc); //2.注册窗体 hwnd = CreateWindow( //3.创建窗体 "MyWndClass", //WNDCLASS NAME "SDK APPLICATION标题", //WINDOW TITLE WS_OVERLAPPEDWINDOW, //WINDOW STYLE CW_USEDEFAULT, //Horizontal position CW_USEDEFAULT, //Vertical position CW_USEDEFAULT, //Initial width CW_USEDEFAULT, //Initial height HWND_DESKTOP, //Handle of parent window NULL, //Menu handle hInstance, //Application's instance handle NULL //Window-creation data ); ShowWindow(hwnd,nCmdShow); //4.显示更新窗体 UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)){ //5.消息循环 TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT message,WPARAM wParam,LPARAM lParam){ PAINTSTRUCT ps; HDC hdc; switch(message){ case WM_PAINT: hdc=BeginPaint(hwnd,&ps); Ellipse(hdc,0,0,200,100); EndPaint(hwnd,&ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,message,wParam,lParam); }
First Win32 App, 第一个Win32 GUI程序
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Web安全性测试
下一篇:vim简单的移动光标
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
win32 炫彩界面第一个程序
用于win32中开发桌面界面
win32 c++ #include ico 初始化 -
我的第一个win32窗口程序------------记录
// Myday03.cpp : 定义应用程序的入口点。//#include "stdafx.h"#include "Myday03.h"int APIENTRY WinMain(HINSTANCE hInstance,
应用程序 win32 窗口程序 WNDCLASSEX CreateWindowEx -
【MFC】创建第一个Win32项目
00. 目录文章目录00. 目录01. 概述02. 创建Win32项目03. 程序示
CWinApp MFC C++ CFrameWnd 应用程序 -
第一个Win32程序(自动检测光驱)
vc 6.0建立以一个Win32 hello world 程序,代码如下//TestWin32.cpp:Definestheentrypointfortheapplication.//#include"stdafx.h"#include"resource.h"#include"dbt.h"#include"windows.h"#defineMAX_LOADSTRING100//GlobalVariables:HINSTANCEhInst;//currentinstanceTCHARszTitle[MAX_LOADS
ico #include 逻辑驱动器 sed #define