zoukankan      html  css  js  c++  java
  • First Win32 App, 第一个Win32 GUI程序

    #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);
    }
    
  • 相关阅读:
    sql语句游标的写法
    oracle的安装与plsql的环境配置
    oracle中创建表时添加注释
    jsp中Java代码中怎么获取jsp页面元素
    sql模糊查询
    jQuery循环给某个ID赋值
    Codeforces Round #671 (Div. 2)
    TYVJ1935 导弹防御塔
    Educational Codeforces Round 95 (Rated for Div. 2)
    Codeforces Round #670 (Div. 2)
  • 原文地址:https://www.cnblogs.com/wucg/p/2353486.html
Copyright © 2011-2022 走看看