To write a dialog box based program, you can write VB program as clear and simple, and quite a lot of programs are such a structure. Written in VB, so the program is almost always like this
。 Design Program Interface
As in VC, the Interface (dialog box has various controls) is generally in the form of resources. Editing a resource file is entirely possible with the VC resource Editor. But familiar
The writing and meaning of the resource file is necessary for programming. The following is an example of a resource file:
#include "\masm32\include\resource.h"
#define IDC_EDIT 3000
#define IDC_BUTTON 3001
#define IDC_EXIT 3002
MyDialog DIALOG 10, 10, 205, 60
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
CAPTION "我的对话框"
{
EDITTEXT IDC_EDIT, 15,17,111,13, ES_AUTOHSCROLL | ES_LEFT
DEFPUSHBUTTON "显示编辑框中的内容", IDC_BUTTON, 141,10,52,13
PUSHBUTTON "退出程序", IDC_EXIT, 141,26,52,13
}
Remember that in order for the compilation to succeed when using QE, it must be saved as a rsrc.rc file name (it doesn't matter if you use the command line). Select Project->compile Resource File. The resource file is compiled successfully and can be connected to use. I suggest you use the VC Resource Editor to open this resource file to see.
The first line of #include "\masm32\include\resource.h", like C, is a header file that contains definitions of various constants, such as
Pushbuotton and so on, interested, you can open this file to see.
Next, we define constants, just like the usage in C, to enhance the readability of the program.
The phrase "Mydialog DIALOG 10, 10, 205, 60" Defines a dialog box called Mydialog with the DIALOG keyword, and the name can be arbitrarily taken. The next 4 digits are the position size of the dialog box, which is typically debugged in the resource editor.
"STYLE 0x0004 | Ds_center | ws_caption | Ws_minimizebox | Ws_sysmenu | ws_visible | ws_overlapped | Ds_modalframe | Ds_3dlook "is the style that describes the dialog box. As Ws_minimizebox is said to have a minimized button. Ds_3dlook is that the dialog box is a 3D shape.
Wait a minute. These are generally changed in the resource editor, and the meaning of the various constants can be found in MSDN.
CAPTION "My dialog box" specifies that the title of the dialog box is "My dialog box"
The boxes below are all controls in the dialog box. This example uses the EditText edit box control, the Pushbutton button control,
Defpushbutton Default button controls (default check state), Idc_edit,idc_exit,idc_button are their 3 ID numbers, note the above definition, is not
can be the same. You do not have to use #define to define it, and you can use numbers to enhance the readability of your program. Many other controls, such as a radio box, duplicate
The use of marquee and so on can be edited under the Resource Editor to view source code acquisition.
The interface of the program is finished, followed by the design program.