Add controls to the dialog

To create a dialog resource, you need to create a dialog template 、 Modify dialog properties 、 Add various controls to the dialog box , We have already talked about Create dialog templates and modify dialog properties , This section continues with how to add controls to dialog boxes .

In the last lecture, we created a program called “Addition” The engineering of , The purpose is to generate an application program to realize the addition operation . There are several necessary factors to realize addition calculation : Augend 、 Addition number 、 and . The addend and the addend need to be entered , And need output display . Then these factors need corresponding controls to input or display , Next, chicken pecks rice to explain how to add these controls step by step .

1. Add a static text box to the dialog (Static Text), Used to display strings --“ Augend ”.

In the resource template generated in the previous lecture, a title named “TODO:Place dialog controls here.” Static text box for , We can change its title and continue to use , You can also delete it . In order to explain the process of adding static text box from the beginning , Delete it , Continue adding new static text boxes .

When deleting a control , You can use the left mouse button to select it , When selected, a dotted box will appear around the control , Then press Delete Key to delete it . stay “Addition” engineering Resource View Open the dialog template created in the previous lecture IDD_ADDITION_DIALOG, Automatically added static text boxes can be removed in this way .

Before adding a new static text box , Have a look first Toolbox Whether the view shows , If not shown , Click on the menu bar View->Toolbox that will do .Toolbox The view is shown below :

Toolbox Some common controls are listed in , One of them is Static Text, That is the control we want to add . stay Toolbox Medium Static Text Up and down the left mouse button does not release , And drag to IDD_ADDITION_DIALOG Dialog template , A dashed box will appear on the template , We find the right place to release the left mouse button and put it down .

After selecting the control with the left mouse button, a dotted box appears around it , Then move the mouse to the dotted line box, and the position of several black dots will become the shape of two-way arrows , At this point, you can press the left mouse button and drag to change the size of the control . We can change the size of the newly added static text box control in this way , To better display the title . Of course , The entire dialog template can also be resized in this way .

Next, it's time to modify the text of the static text box . Right click on the static text box , Select from the context menu “Properties”( attribute ),Properties The panel will show , Modify... On the panel Caption The attribute is “ Augend ”,ID It is amended as follows IDC_SUMMAND_STATIC. The template is shown in the figure below :

2. Add an edit box to the dialog (Edit Control), It's used to enter the addend .

The process of adding an edit box is similar to that of a static text box , stay Toolbox Choose Edit Control Control onto the dialog template , And align it horizontally with the previous static text box ( For beauty ), Then adjust its size to fit the input of the plus number .

Right click on the edit box , Still select... From the right-click menu “Properties” Show properties (Properties) panel , Modify it ID by IDC_SUMMAND_EDIT. The template is shown in the figure below :

3. according to 1 Method to add a title called “ Addition number ” Static text box for , Used to display strings --“ Addition number ”. And its ID Change it to IDC_ADDEND_STATIC.

4. according to 2 To add a ID by IDC_ADDEND_EDIT Edit box for , It's used to enter addends .

5. according to 1 Method to add a title called “ and ” Static text box for , Used to display text --“ and ”. And modify it ID by IDC_SUM_STATIC.

 6. according to 2 To add a ID by IDC_SUM_EDIT Edit box for , Used to show the final sum .

 7. Like the Add button (Button) Control to dialog template , Used to trigger addition calculation after being clicked . Change its title to “ Calculation ”,ID by IDC_ADD_BUTTON.

Here we are , The dialog template is shown in the figure :

 8. Delete OK Button . open Cancel Button's property panel , Change the title to “ sign out ”, And make it with “ Calculation ” The buttons align horizontally .

 9. According to the layout of the control , Adjust the size of the entire dialog template appropriately , Make it the right size relative to the control layout , Beautiful interface .

In this way, the control we need to use in this example will be added in the dialog template . The end result is as follows :

thus , Our dialog resources are basically created . The interface effect of the application is very clear . Later, we will talk about how to implement the function of addition calculation in the dialog class , And can interact with the interface very well .

VS2010/MFC Dialog 2 : Add controls to the dialog ) More articles about

  1. 【 turn 】VS2010/MFC Introduction to programming 8 ( Dialog box : Create dialog class and add control variable )

    Original website :http://www.jizhuomi.com/software/153.html In the first two lectures, chicken pecking rice explained how to create dialog resources . After creating dialog resources, what we need to do is to generate dialog class . The chicken pecks the rice and then declares , ...

  2. VS2010/MFC Dialog three : Create dialog class and add control variable

    Create dialog class and add control variable The first two lectures explained how to create dialog resources . After creating dialog resources, what we need to do is to generate dialog class . Generating dialog class mainly includes creating new dialog class . Add control variables and control message handling functions, etc . routine Addition yes ...

  3. VS2010/MFC Introduction to programming 8 ( Dialog box : Create dialog class and add control variable )

    In the first two lectures, chicken pecking rice explained how to create dialog resources . After creating dialog resources, what we need to do is to generate dialog class . The chicken pecks the rice and then declares , Generating dialog class mainly includes creating new dialog class . Add control variables and control message handling functions, etc . Because chicken pecks rice to everybody's routine ...

  4. VS2010/MFC Introduction to programming 7 ( Dialog box : Add controls to the dialog )

    To create a dialog resource, you need to create a dialog template . Modify dialog properties . Add various controls to the dialog box , In the previous lecture, we have talked about creating dialog templates and modifying dialog properties , This section continues with how to add controls to dialog boxes . In the last lecture, the chicken pecked rice to create a brand named “A ...

  5. MFC Introduction to programming 8 ( Dialog box : Create dialog class and add control variable )

    After creating dialog resources, what we need to do is to generate dialog class . Generating dialog class mainly includes creating new dialog class . Add control variables and control message handling functions .  routine Addition It's a dialog based program , So the program automatically creates a dialog template IDD_ADDIT ...

  6. MFC Introduction to programming 7 ( Dialog box : Add controls to the dialog )

    To create a dialog resource, you need to create a dialog template . Modify dialog properties . Add various controls to the dialog box , In the previous lecture, we have talked about creating dialog templates and modifying dialog properties , This section continues with how to add controls to dialog boxes .  In the previous section, you created a "A ...

  7. MFC Insert a dialog box in the docking window of , Add control in dialog box and make control self adaptation

    After adding a docking window to a single document program , Some controls may be added to the docked window . What I do here is to add controls to the dialog box and lay them out , Then insert the dialog into the docking window . step 1. Insert dialog , Put the control in the dialog box ( Mine is a tree control ), and ...

  8. VS2010-MFC( Dialog box : Create dialog class and add control variable )

    from :http://www.jizhuomi.com/software/153.html The first two lectures explained how to create dialog resources . After creating dialog resources, what we need to do is to generate dialog class . Generating dialog class mainly includes creating new dialog class ...

  9. VS2010/MFC Introduction to programming 53 (Ribbon Interface development : by Ribbon Bar add controls )

    In the previous section, chicken pecking rice briefly introduces how to create Ribbon Style application framework , In this section, we will talk about how to make Ribbon Bar add to Ribbon Control . VS2010 by Ribbon Interface development provides Ribbon De ...

Random recommendation

  1. spark Tips -mapPartitions

    And map The method is similar to ,map It's right rdd Each element in the , and mapPartitions(foreachPartition) That's right. rdd The iterator for each partition in the . If in map Additional... Needs to be created frequently during the process ...

  2. database middleware mycat Simple introduction

    When in a project mysql When databases become bottlenecks , We usually use master-slave replication , Sub database sub table way to improve the response speed of the database , such as mysql Master slave copy , Without database middleware , We can only be controlled by the development engineer in the program , This is for a ...

  3. bzoj2119

    The meaning of the problem is to find the shape after the difference ABA The number of strings of ,B The length of is M This is a 2011 National training team mutual test questions , It's a good question , I'll give the solution of the problem maker directly : For this combinatorial counting problem on linear sequences , It's easy to think of a tool : Divide and conquer ! Divide and conquer algorithm in ...

  4. C Program storage space layout

    History goes on to this day ,C The program has always been made up of the following parts : 1. Body paragraph . This is from CPU The part of the machine instruction that is executed . Usually , The text paragraph is shareable , So even programs that are executed frequently ( Editor , compiler , command interpreter ) Only one copy is needed in memory , In addition ...

  5. ~.NET Internationalization i18n A simple example

    Because of business needs , Background site needs an international solution , Use Microsoft's own resource file to solve the problem temporarily after being lazy . I don't say much nonsense , Get to the point . First step : Under the Project menu, select add international resource folder . Second parts : After adding , Add resource letters in different language versions ...

  6. linux_grub resue Mode recovery

    //20190417 It's for lunch today linux My computer crashed …… I thought it was a hardware problem at first , After a long time , It's time to update grub The bootstrap is broken All right , No one taught us to search the Internet , I worked it out all afternoon ============= ...

  7. Cannot type “System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>” Implicitly convert to “System.Collections.Generic.List<Ecology.Model.EnergyFlowGraph>”

    Cannot type “System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>” Implicitly convert to “Sy ...

  8. Women's prison season four / The complete Orange Is the New Black Thunder download

    Women's prison Season 3 Orange Is the New Black 3 (2015) What's new this season : The play is composed of < Gilmore girl >.< Single poison mom season one > Writer Jackie · Cohen's creation . from < Nurses are in charge & ...

  9. Abreast of the times CocoaPods Installation and use

    When developing iOS When applied , Will often use a lot of third-party open source class library , The general method is to directly from GitHub download , Then drag to the project to use , If the open source library does not rely on other libraries , You can use it directly : If the open source class library also relies on some other class libraries , Then ...

  10. How to make Android Studio Project to Eclipse Project

    1. Find this directory : Project name \app\src\main, And import it into Eclipse in 2. Name the project \app\libs Copy the folder to the newly generated project , And delete .DS_Store file 3. Now let's see what else ...