当前位置:网站首页>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
边栏推荐
- 1266_FreeRTOS调度器启动代码实现分析
- Analysis of key points and difficulties of ES6 promise source code
- P3172 [cqoi2015] data selection (Mobius inversion + Du Jiao sieve)
- 1269. number of options left in place
- 1734. arrangement after decoding XOR
- Shangtang technology has actively resumed work and will vigorously invest in the capacity and deployment of the digital sentry
- Difference between byte and bit
- Stack -- one of two common linear structures of linear structure
- Flutter 内外边距
- byte和bit的区别
猜你喜欢
![[deploy private warehouse based on harbor] 3 deploy harbor](/img/cd/be68a430e86b4b23ad93b42a338f00.jpg)
[deploy private warehouse based on harbor] 3 deploy harbor

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

教育专家王中泽老师多年经验分享:家庭教育不是附庸品

Education expert Mr. wangzhongze: family education focuses on self growth

saltstack部署lnmp

Web API、DOM

Xunwei dry goods | Ruixin micro rk3568 development board TFTP & NFS writing (Part 1)

Mistakes in Niuke JS exercise

. Net C Foundation (6): namespace - scope with name

.NET C#基础(6):命名空间 - 有名字的作用域
随机推荐
Error occurred in pycharm DeprecatedEnv: Env FrozenLake-v0 not found (valid versions include [‘FrozenLake-v1‘])
R语言并行计算实战教程
Oracle pl/sql these query results cannot be updated. Please include ROWID or use Select For update
Common troubleshooting tools and analysis artifacts are worth collecting
Heartless sword Chinese English bilingual poem 001 Love
554. brick wall
MS office level II wrong question record [10]
Leetcode hot topic 100 topic 6-10 solution
生物序列智能分析平台blog(1)
Object. Specific implementation and difference between create() and new
421. maximum XOR value of two numbers in the array
【LeetCode】-- 17. Letter combination of telephone number
SQL query. Only the column name is displayed but not the data
This comprehensive understanding
Mybags puls will report an error invalid bound statement (not found) when writing an SQL statement in the XML file:
教育专家王中泽老师一招解决学生问题
1190. invert the substring between each pair of parentheses
Leetcode-104. Maximum Depth of Binary Tree
Group arrays by a specified size
Concurrent tool class