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);
    }
    
  • 相关阅读:
    为什么要用设计模式?先看看6大原则(一)
    git版本库的创建和yaf框架环境的部署
    laravel日常小问题
    Session store not set on request.
    phpstudy集成环境安装lavarel
    html中提交表单并实现不跳转页面处理返回值
    document load 与document ready的区别
    定时器优化
    放大镜
    子组件调用父组件的方法并传递数据
  • 原文地址:https://www.cnblogs.com/wucg/p/2353486.html
Copyright © 2011-2022 走看看