当前位置:网站首页>Create a form whose client area is 800 pixels by 600 pixels
Create a form whose client area is 800 pixels by 600 pixels
2022-06-11 07:11:00 【lihongtao8209】
1.Windows Desktop wizard
choice “windows Desktop wizard ”, Click on " next step ".

2. Prepare new items
modify “ Project name ”, modify “ Location ”, Click on “ establish ”.

3.Windows Desktop projects
choice “ Application type ” by “ Desktop applications .exe”.
“ Other options ” choice “ Empty item ”, Click on " determine ”.

4. Code segment
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 800 + 16, 600 + 59, nullptr, nullptr, hInstance, nullptr);5. Specific code
// Global variables :
HINSTANCE hInst; // The current instance
TCHAR szTitle[MAX_LOADSTRING]; // Title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // Main window class name
...... // Omit some code
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handles in global variables
/*
* Width = Right border width + Left border width + Customer area width =800+16=816
* Height = Status box height + Menu box Height +( Bottom border height + Top border height )+ Customer area height =23+20+16+600=659
*/
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 800+16, 600+59, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// function : WndProc(HWND, UINT, WPARAM, LPARAM)
//
// Purpose : Processing messages from the main window .
//
// WM_COMMAND - Handle the application menu
// WM_PAINT - Draw the main window
// WM_DESTROY - Send an exit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
WCHAR wcSize[64]={0L}; // Print information
RECT rect; // Client area size
int statusBarH;
int menuBarH;
int wcstrlen;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Analysis menu selection :
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
// Window creation
case WM_CREATE:
{
GetClientRect(hWnd, &rect);
break;
}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// Get the customer area
GetClientRect(hWnd,&rect);
wcstrlen=wsprintf(wcSize,_T("left=%d,right=%d,top=%d,bottom=%d"),rect.left,rect.right,rect.top,rect.bottom);
TextOut(hdc,0,0,wcSize,wcstrlen);
// Zero clearing
_wcsset_s(wcSize,64,0);
// Get status bar height
statusBarH=GetSystemMetrics(SM_CYCAPTION);
wcstrlen=wsprintf(wcSize,_T("STATUS BAR HEIGHT=%d"),statusBarH);
TextOut(hdc,0,16,wcSize,wcstrlen);
// Zero clearing
_wcsset_s(wcSize,64,0);
// Get the menu bar height
menuBarH=GetSystemMetrics(SM_CYMENU);
wcstrlen=wsprintf(wcSize,_T("MENU BAR HEIGHT=%d"),menuBarH);
TextOut(hdc,0,32,wcSize,wcstrlen);
EndPaint(hWnd, &ps);
break;
// When the user clicks the close button in the upper right corner of the window
case WM_CLOSE:
{
DestroyWindow(hWnd); // Destruction of the window
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
...... // Omit some code
边栏推荐
- 213. house raiding II
- Comparison of DOM tags of wechat applet development (native and uniapp)
- Leetcode hot topic 100 topic 11-15 solution
- 二、用户登录和注册
- Promise. All capture error
- Experience record of rural housing integration script
- 微信小程序开发(原生和uniapp)DOM标签对比介绍
- Whether the ZABBIX monitoring host is online
- 1269. number of options left in place
- Shangtang technology has actively resumed work and will vigorously invest in the capacity and deployment of the digital sentry
猜你喜欢

Leetcode hot topic 100 topic 11-15 solution

matplotlib的cmap

Modular notes

CMAP of Matplotlib

Leetcode-104. Maximum Depth of Binary Tree
![P5431 [template] multiplicative inverse 2](/img/63/1cb95a55c9ce9b92d6d55381d0215b.jpg)
P5431 [template] multiplicative inverse 2

資深OpenStacker - 彭博、Vexxhost昇級為OpenInfra基金會黃金成員

Listen to the left width of the browser to calculate the distance

Senior openstacker - Bloomberg, vexxhost upgraded to gold member of openinfra Foundation

Henan college entrance examination vs Tianjin college entrance examination (2008-2021)
随机推荐
Janus feature草稿
微信小程序开发(原生和uniapp)DOM标签对比介绍
1300. the array closest to the target value after transforming the array and
Leetcode-141. Linked List Cycle
Deep Attentive Tracking via Reciprocative Learning
SQL query. Only the column name is displayed but not the data
Dynamically change the direction of this
Leetcode hot topic 100 topic 11-15 solution
Cv2.rectangle() picture frame
[advanced concurrency] - thread pool summary
Duality-Gated Mutual Condition Network for RGBT Tracking
[MATLAB image encryption and decryption] chaotic sequence image encryption and decryption (including correlation test) [including GUI source code 1862]
matplotlib的cmap
The meaning and research significance of mathematical methodology
This comprehensive understanding
Server parameter adjustment record
@JsonProperty注解
P3811 [template] multiplicative inverse
Records how cookies are carried in cross domain requests
saltstack部署lnmp