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);
    }
    
  • 相关阅读:
    Kali 2020.3安装docker和vulhub
    Web渗透——身份管理测试
    Web渗透——配置管理测试
    网站信息收集
    linux修改MAC的方法
    '文件上传总结'
    美杜莎和九头蛇的对比
    渗透测试常见开放端口及利用
    Google hacking 语法
    web渗透测试基本步骤
  • 原文地址:https://www.cnblogs.com/wucg/p/2353486.html
Copyright © 2011-2022 走看看