当前位置:网站首页>[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
边栏推荐
- On April 17, 2022, the five heart matchmaker team received double good news
- Research on and off the Oracle chain
- 2022年4月17日五心红娘团队收获双份喜报
- A sharp tool for exposing data inconsistencies -- a real-time verification system
- MySQL comparison operator in problem solving
- Power Spectral Density Estimates Using FFT---MATLAB
- HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
- BEAUTIFUL GGPLOT VENN DIAGRAM WITH R
- 抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
- 数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
猜你喜欢

MTK full dump grab

PLC-Recorder快速监控多个PLC位的技巧

Seriation in R: How to Optimally Order Objects in a Data Matrice

制造业数字化转型和精益生产什么关系

Attribute acquisition method and operation notes of C # multidimensional array

数字化转型挂帅复产复工,线上线下全融合重建商业逻辑

Develop scalable contracts based on hardhat and openzeppelin (II)

Tiktok overseas tiktok: finalizing the final data security agreement with Biden government

ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)

Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
随机推荐
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
Principe du contrat évolutif - delegatecall
制造业数字化转型和精益生产什么关系
Summary of data export methods in powerbi
RPA advanced (II) uipath application practice
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
HOW TO CREATE A BEAUTIFUL INTERACTIVE HEATMAP IN R
A white hole formed by antineutrons produced by particle accelerators
flutter 问题总结
STM32 single chip microcomputer programming learning
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
Cluster Analysis in R Simplified and Enhanced
【2022 ACTF-wp】
webauthn——官方开发文档
PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)
Order by injection
Introduction to interface debugging tools
Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
Esp32 audio frame esp-adf add key peripheral process code tracking
Power Spectral Density Estimates Using FFT---MATLAB