当前位置:网站首页>[visual studio 2019] create MFC desktop program (install MFC development components | create MFC application | edit MFC application window | add click event for button | Modify button text | open appl
[visual studio 2019] create MFC desktop program (install MFC development components | create MFC application | edit MFC application window | add click event for button | Modify button text | open appl
2022-07-02 11:46:00 【Programmer community】
List of articles
- One 、 install MFC Development component
- Two 、 establish MFC application
- 3、 ... and 、MFC Application window editing
- Four 、 Add click event for button
- 5、 ... and 、 Modify button text
- 6、 ... and 、 Open other applications of the system
- 7、 ... and 、 Blog source code
One 、 install MFC Development component
open Visual Studio Installer , And then choose modify Visual Studio 2019 , The following dialog box will pop up , choice " Use C++ Desktop development " , Then open the... On the right " Use C++ Desktop development " tab , Check " "

Select and click on the bottom right " modify " Button ,

Wait for the download and installation to complete ;

Two 、 establish MFC application
stay Visual Studio 2019 In the environment interface , choice " Create a new project (N) " ,

choice " Windows Desktop applications " Under the " MFC application " ,

Enter the relevant configuration , Project name , Storage path , Click on " establish " Button ;

Application type selection " Based on dialog " , The dialog based options are set to nothing ;

Other configurations can be selected by default , You can also choose other configurations , Click here " complete " Button ;
Automatic system generation MFC The procedure is as follows :

Click on " Local Windows The debugger " Button , Run the program :

3、 ... and 、MFC Application window editing
double-click " Resource file " Medium " MFCHelloWorld.rc " file , Get into " Resource view " ,

Click on " Resource view " Medium " Dialog " Under the " IDD_MFC_HELLO_WORLD_DIALOG " , You can view the dialog box ;

Drag a from the toolbox Button Button into the interface ,

Effect after operation :

Four 、 Add click event for button
Select and double-click the button , You can enter the corresponding code interface , Click event of Edit button ;

In the void CMFCHelloWorldDlg::OnBnClickedButton1() Method to edit the click event of the button ;

Add the following code to this method , Click to pop up a dialog box , The content in the dialog box is Unicode String in encoded format “Hello World” ;
void CMFCHelloWorldDlg::OnBnClickedButton1(){
// TODO: Add control notification handler code here MessageBox(L"Hello World");}The operation effect is as follows :

5、 ... and 、 Modify button text
Check button , stay " Property panel " Medium " appearance " Under the " Caption " Option is the text setting of the button ;

6、 ... and 、 Open other applications of the system
Then drag two buttons into the window , Click to open notepad and calculator respectively , UI Set as follows :

Click on the event code as follows :
void CMFCHelloWorldDlg::OnBnClickedButton2(){
// Open Notepad system("notepad");}void CMFCHelloWorldDlg::OnBnClickedButton3(){
// Turn on the calculator system("calc");}Open Notepad :

Turn on the calculator :

7、 ... and 、 Blog source code
Blog source code : https://download.csdn.net/download/han1202012/15867695
边栏推荐
- MySQL basic statement
- 制造业数字化转型和精益生产什么关系
- 进入前六!博云在中国云管理软件市场销量排行持续上升
- Homer预测motif
- RPA进阶(二)Uipath应用实践
- 揭露数据不一致的利器 —— 实时核对系统
- C file and folder operation
- What week is a date obtained by QT
- The selected cells in Excel form have the selection effect of cross shading
- [multithreading] the main thread waits for the sub thread to finish executing, and records the way to execute and obtain the execution result (with annotated code and no pit)
猜你喜欢

Principe du contrat évolutif - delegatecall

MySQL comparison operator in problem solving

A white hole formed by antineutrons produced by particle accelerators

VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题

GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R

Esp32 audio frame esp-adf add key peripheral process code tracking

The computer screen is black for no reason, and the brightness cannot be adjusted.

电脑无缘无故黑屏,无法调节亮度。

TDSQL|就业难?腾讯云数据库微认证来帮你

微信小程序利用百度api达成植物识别
随机推荐
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
C#多维数组的属性获取方法及操作注意
Order by注入
Precautions for scalable contract solution based on openzeppelin
JS——每次调用从数组里面随机取一个数,且不能与上一次为同一个
Esp32 stores the distribution network information +led displays the distribution network status + press the key to clear the distribution network information (source code attached)
MySQL comparison operator in problem solving
GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R
How to Visualize Missing Data in R using a Heatmap
Solve the problem of data blank in the quick sliding page of the uniapp list
What week is a date obtained by QT
抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
mysql 基本语句
Summary of data export methods in powerbi
ASTParser 解析含有emum 枚举方法的类文件的踩坑记
The working day of the month is calculated from the 1st day of each month
Gaode draws lines according to the track
Is it safe to open a stock account online? I'm a novice, please guide me
Redis超出最大内存错误OOM command not allowed when used memory > 'maxmemory'
Esp32 audio frame esp-adf add key peripheral process code tracking