Reply To: ….v….1….v….2….v….3….v….4….v….50…v….6

Product Compare Forums General Test Me ….v….1….v….2….v….3….v….4….v….50…v….6 Reply To: ….v….1….v….2….v….3….v….4….v….50…v….6

#6157
deleyd
Participant

See the final version in the forum.


Introduction to CMAC. 12.3

DIALOG BOXES: Sample Code for Each Control

Note: Attached below is a file with all the sample code files shown here.

Each dialog element (control) is created by calling DlgAddCtrl:
[code:se0b9l6k]int DlgAddCtrl(
int dlg the dialog handle create with DlgCreate
int ctrltype the control type (defined in Dialog.sh)
str ctrltitle the control title (ctrltext)
int X the X coordinate
int Y the Y coordinate
int width the width of the control
int height the height of the control
int ctrlid the identifying number for the control
int flags miscellaneous flags (defined in Dialog.sh)
str misc miscellaneous parameters
)
[/code:se0b9l6k]
X and Y coordinates were discussed in Introduction to CMAC: 12.2 DIALOG BOXES: The X & Y Coordinates

Width, Height
If you specify 0 for either one then Multi-Edit will usually come up with appropriate values for the width and height. This isn’t guaranteed to work, but it often does work.

ctrlid
Do not use -1 for ctrlid for any control which actually does something (e.g. PushButton). Multi-Edit 9.10 doesn’t generate good ctrlid values when you use -1, so make up a unique ctrlid number for each control or the control won’t work. Use -1 (or 0) only for static elements, such as static text, bitmaps, or icons (or never use -1). Also do not use any of the following numbers as they have special meaning:
32767
998
995
991
990
2
1
Do not use a number > 60,000 (this is the mistake Multi-Edit 9.10 makes when you use -1). To prevent conflicts with future versions of Multi-Edit, I suggest using numbers below 30,000. So ctrlid numbers in the range [1000 – 30,000] should be OK.

flags
Most flags for the flag parameter start with the prefix dlgf_ and are defined in Dialog.sh .

Most controls accept the flag dlgf_Disable. This disables the control and greys it out. (It also greys out static text.) The flag has no effect on static icons and bitmaps. A control can be dynamically enabled/disabled as the dialog box is running.

Combine flags using the | operator. e.g.:
[code:se0b9l6k](dlgf_GetTextFromWin | dlgf_es_MultiLine | dlgf_es_WantReturn)[/code:se0b9l6k]

misc
All misc parameters should be UPPERCASE.

Some controls can have tool tip text associated with it. The tool tip text displays when the mouse pointer hovers over the control. You specify tool tip text by adding “/TT=<tool tip text>” to the misc parameter of DlgAddCtrl.

Following are basic examples of each control, along with sample code.

STATIC TEXT (dlg_Static)
[code:se0b9l6k]#include dialog.sh

void MyStaticDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_Static, "This is static text.",
1, 1, //coordinates X, Y
20, 1, //Width, Height
1001, 0, "" );

Result = DlgExecute( Dlg, 0, "Static Text",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The text is greyed out

// These can be used on the STATIC class
dlgf_ss_Left – Left justify text (the default)
dlgf_ss_Center – Center text
dlgf_ss_Right – Right justify text
(The following 3 are never used hence untested.)
dlgf_ss_LeftNoWordWrap
dlgf_ss_NoPrefix // Don’t do "&" character translation
dlgf_ws_border
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS: None

TEXT (dlg_Text)
[code:se0b9l6k]#include dialog.sh

void MyTextDlg()
{
int Dlg, Result;
str MyText[259];

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_Text, MyText,
1, 1, //coordinates X, Y
23, 1, //Width, Height
1002, 0, "/ML=259" ); //ML=Max Length

//The initial text is set to whatever is in MyText.
//We can also optionally set initial text here:
DlgSetStr( Dlg, 1002, "User enters text here." );

Result = DlgExecute( Dlg, 1002, "Text",
"",
"",
0 );

MyText = DlgGetStr( dlg, 1002);

MAKE_MESSAGE("MyText="+MyText);

DlgKill( Dlg );
}
[/code:se0b9l6k]
If you don’t specify a max length for the text control such as “/ML=259”, the length defaults to the width specified for the field. Hence here width=23 so you could enter only 23 characters if we did not specify “/ML=259”. (In windows 259 is the maximum length for a file’s full path/name.)

(If you don’t specify a size for string MyText, the string length defaults to 254. See )

OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The text field is disabled and greyed out

// Edit control styles (es)
// Use for DLG_Text controls WITHOUT history lists.
// These flags are ignored for DLG_Text controls with history
// lists.
dlgf_es_Left – Left justify text (the default)
dlgf_es_Center – Center text
dlgf_es_Right – Right justify text
dlgf_es_UpperCase – All text converted to uppercase
dlgf_es_LowerCase – All text converted to lowercase
dlgf_es_Password – astrisks are shown instead of the text
(ignored if /HISTORY= specified)
dlgf_es_ReadOnly – Any text initially in the field is
displayed, you can move the cursor across
the text, but the background is greyed
out and you can not add or delete text.
dlgf_es_MultiLine – The text field may wrap to the next line,
and continue wrapping for as many lines
as needed. (You may want to declare the
height of the dlg_Text control to be
greater than 1.) The text returned is
one long line. "/ML=<max_length>" still
defines the maximum number of characters
that can be entered.
dlgf_es_WantReturn – Used with dlgf_es_MultiLine, allows user
to press the Enter key to move to the
next line.
dlgf_es_HScrollBar
dlgf_es_AutoVScroll
dlgf_es_AutoHScroll
dlgf_es_NoHideSel
dlgf_es_OEMConvert

dlgf_GetTextFromWin – Used in conjunction with
"/WID=<window ID>" for misc parameter.
Text in specified window is displayed as
initial text, and resulting text when
dialog exits is placed in specified
window.
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS:

/ML=<max length>
The maximum number of characters the text field will accept.

/HISTORY=<global_string>
Adds a drop down history list of previously entered strings. For example:
[code:se0b9l6k]
DlgAddCtrl( Dlg, Dlg_Text, MyText,
1, 1, //coordinates X, Y
23, 3, //Width, Height
1002, 0, "/HISTORY=!DELEY_HISTORY" );
[/code:se0b9l6k]
In this example the history items are stored in global variables
!DELEY_HISTORY
!DELEY_HISTORY1
!DELEY_HISTORY2
etc…
(Note: The most recent item saved is stored in the highest number. Thus if we have two history items, !DELEY_HISTORY1 and !DELEY_HISTORY2, the most recently entered item is stored in !DELEY_HISTORY2, and will be at the top of the drop-down list.)

The history list control global is the global with no number after it (e.g. !DELEY_HISTORY). This global contains information about how many items are currently stored in this history list and optionally the maximum number of items that can be stored in this history list. The default maximum number of items that can be stored in a history list is set by TOOLS -> CUSTOMIZE -> User Interface (left side) -> “Max items in History list”. (This can be overridden if you manually specify “/HL=<n>” in the history list control global.)

Global variables with names not preceded by a ‘ ! ‘, ‘@’, or ‘~’ are restored at the beginning of each editing session if the restore feature is enabled. (This is often not necessary or wanted, which is why so many global variable names start with ‘!’ or ‘@’.)

/SHOWH0=1
(That’s a zero after “/SHOWH”). If you create global string !DELEY_HISTORY0 then the contents of this global will be placed at the very top of the drop down list of history values. If you then also use “/SHOWH0=1” then the contents of global !DELEY_HISTORY0 is initially displayed instead of the contents of MyText.

/RESIZE=W
(Something about resizing the window…)

/CHANGEMAC=<macro>
Run macro whenever text is changed.

An example of a fancy multi-line dlg_Text field is TOOLS -> NOTEBOOK. Click “Insert” to get the “Edit Text” window. The Text: field is a dlg_Text field created with the following code:
[code:se0b9l6k] DlgAddCtrl( Note_Dlg, dlg_Text, "",
1, dlg_PosOffset + 1,
70, 11,
2100, dlgf_GetTextFromWin |
dlgf_es_MultiLine |
dlgf_es_WantReturn,
"/ML=32000/WID=" + Str( g_NbEditWindow ) );
[/code:se0b9l6k]
In this example the text field is initially filled with the contents of the window specified by the Window_ID stored in g_NbEditWindow. Upon exiting this sub-dialog the text is written back to the same window.

INTEGER (dlg_Integer)
[code:se0b9l6k]#include dialog.sh

void MyIntegerDlg()
{
int Dlg, Result;
int MyInt;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_Integer, "",
1, 1, //coordinates X, Y
23, 1, //Width, Height
1003, 0, "" );
//Optionally set initial value
/* DlgSetInt( Dlg, 1003, 3 ); */

Result = DlgExecute( Dlg, 1003, "Integer",
"",
"",
0 );

MyInt = DlgGetInt( Dlg, 1003);

MAKE_MESSAGE("MyInt="+str(MyInt));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The field is disabled and greyed out
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS:

/MIN=<n>
Minimum number allowed.

/MAX=<n>
Maximum number allowed.

/RESIZE=X
(Something about resizing the window…)

/CHANGEMAC=<macro>
Run macro whenever value is changed.

CHOICE (dlg_Choice)
[code:se0b9l6k]#include dialog.sh

void MyChoiceDlg()
{
int Dlg, Result;
int choice;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_Choice,
"Choice 1()Choice 2()Choice 3()",
1, 1, //coordinates X, Y
23, 1, //Width, Height
1004, 0, "" );
//Optionally set initial choice
/* DlgSetInt( Dlg, 1004, 3 ); */

Result = DlgExecute( Dlg, 1004, "Choice",
"",
"",
0 );

choice = DlgGetInt( Dlg, 1004 );

MAKE_MESSAGE("choice="+str(choice));

DlgKill( Dlg );
}
[/code:se0b9l6k]
All choice options end with and are separated by a pair of parenthesis ().
e.g. “Choice 1()Choice 2()Choice 3()”.

OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The field is disabled and greyed out
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

/CHANGEMAC=<macro>
Run macro whenever choice is changed.

MSIZE=<n>
(usage unknown. Stands for Max Size.)

/VSCROLL=1
(usage unknown)

/FOCUSMAC=<macro>
(usage unknown)

RESIZE=W
(something about resizing window)

CHECKBOX (dlg_CheckBox)
[code:se0b9l6k]#include dialog.sh

void MyCheckboxDlg()
{
int Dlg, Result;
int checked;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_CheckBox, "Click the checkbox.",
1, 1, //coordinates X, Y
23, 1, //Width, Height
1005, 0, "" );
//Optionally initialize checkbox with check
/* DlgSetInt (dlg, 1005, 1); */

Result = DlgExecute( Dlg, 1005, "Checkbox",
"",
"",
0 );

checked = DlgGetInt( Dlg, 1005); //Get checked status

MAKE_MESSAGE("Checked="+str(checked));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The checkbox is disabled,
checkbox and text are greyed out.
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

/CHANGEMAC=<macro>
Run macro whenever checkbox is changed.

/RESIZE=X
(usage unknown)

AUTO 3 STATE CHECKBOX (dlg_3State)
When chosen, the box automatically advances between three states: checked, unchecked, and grayed out.
[code:se0b9l6k]#include dialog.sh

void My3StateDlg()
{
int Dlg, Result;
int checked;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_3State, "Click the checkbox.",
1, 1, //coordinates X, Y
23, 1, //Width, Height
1006, 0, "" );
//Optionally initialize checkbox with check
/* DlgSetInt (dlg, 1006, 1); */

Result = DlgExecute( Dlg, 1006, "3State",
"",
"",
0 );

checked = DlgGetInt( Dlg, 1006); //Get checked status

MAKE_MESSAGE("Checked="+str(checked));

DlgKill( Dlg );
}
[/code:se0b9l6k]
Returns:
0 = box unchecked
1 = box checked
2 = box greyed out

OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The checkbox is disabled,
checkbox and text are greyed out
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

/CHANGEMAC=<macro>
Run macro whenever checkbox is changed.

/RESIZE=X
(something about resizing the window…)

RADIO BUTTON (dlg_RadioButton)
Radio buttons are only useful if you have more than one. Even though each radio button itself is a separate element, when you add them via consecutive calls to DlgAddCtrl, Multi-Edit knows they go together to form a group. The group ends when you call DlgAddCtrl to add something other than a dlg_RadioButton.

“Incidentally, the reason why they are called radio buttons is that they function very similar to the old car radios where only one button can be selected at a time. If you push a new button in, the one that was in pops out.” – Multi-Edit Version 5 User’s Guide, pg. 20. (1990)

[code:se0b9l6k]#include dialog.sh

void MyRadiobtnDlg()
{
int Dlg, Result;
int option1, option2, option3;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_GroupBox, "Options",
1, 1, //coordinates X, Y
25, 4, //Width, Height
1200, 0, "" );

DlgAddCtrl( Dlg, Dlg_RadioButton, "One",
2, 2, //coordinates X, Y
23, 1, //Width, Height
1201, 0, "" );
//Optionally select option to start with
DlgSetInt (dlg, 1011, 1);

DlgAddCtrl( Dlg, Dlg_RadioButton, "Two",
2, 3, //coordinates X, Y
23, 1, //Width, Height
1202, 0, "" );

DlgAddCtrl( Dlg, Dlg_RadioButton, "Three",
2, 4, //coordinates X, Y
23, 1, //Width, Height
1203, 0, "" );

Result = DlgExecute( Dlg, 1201, "Radio Buttons",
"",
"",
0 );

option1 = DlgGetInt( Dlg, 1201);
option2 = DlgGetInt( Dlg, 1202);
option3 = DlgGetInt( Dlg, 1203);

MAKE_MESSAGE("Option1="+str(option1)+
" Option2="+str(option2)+
" Option3="+str(option3));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The option and text is disabled and greyed out
[/code:se0b9l6k]
To disable the radio button group you have to disable each radio button individually and disable the group box so everything is grayed out.

OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

Note:
An interesting bit of code in DlgBuild, which is called by DlgExecute to build the dialog box, apparently if “/G=<global_integer>” is specified in the misc parameter for Dlg_RadioButton, and “/R=<n>” is also specified, then this global integer is set to <n>. (If “/R=<n>” is not specified, then the global integer is probably set to zero, meaning it is erased.) I have found no examples of this usage.
[code:se0b9l6k] case DLG_RadioButton :
str c_str1 [32];
if( menu_item_int( dlg, c_parm, 2 ) > 0 ) {
var_parse_str( ‘/G=’, mstr, c_str1 );
if( svl(c_str1) > 0 ) {
var_parse_int( ‘/R=’, mstr, ll );
set_global_int( c_str1, ll );
}
}
[/code:se0b9l6k]

PUSH BUTTON (dlg_PushButton)
[code:se0b9l6k]#include Dialog.sh

void MyPushButtonDlg()
{
int Dlg, Result, MyInt;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_PushButton, "OK",
1, 1, //coordinates X, Y
23, 1, //Width, Height
1210, 0, "" );

Result = DlgExecute( Dlg, 1210, "PushButton",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The push button is disabled and greyed out
dlgf_DefButton – Designate this the default button
[/code:se0b9l6k]The default button is the button pushed if you press the return key. You should only declare one button to be the default button.

You can also make this the default button by calling: DlgSetInt (dlg, ctrlid, 1); [e.g. DlgSetInt (dlg, 1210, 1);]

You can also make this the default button by specifying this CtrlId as the startid in the call to DlgExecute.

OPTIONAL misc PARAMETERS:
If no misc parameter is specified (you specified “” for the misc parameter), then when the button is pressed the dialog box will exit and return the button’s ctrlid as the return value to the DlgExecute call. In the example above, Result will = 1210, and Make_Message will print the message “Result=1210”.

/R=<return value>
When the push button is clicked the dialog box exits and returns this value instead of the ctrlid. NOTE: /R=2 has a special meaning. It means do not exit but instead launch help and search for topic specified as 4th parameter to DlgExecute (the “helpindex” string). A pushbutton labeled “Help” usually has /R=2 specified for the misc parameter so help is automatically invoked. (You may also specify your own help file for the “helpindex” parameter to DlgExecute by using the format “file^topic”. See Intro to CMAC 12.4: DlgExecute for more info on the “helpindex” parameter.)

/M=<macro>
Run the specified macro when the button is pushed.

All parameters after /M=<macro> are passed to the macro as part of MParm_Str. Leave a space after /M=<macro> before adding parameters to be passed to this macro. Example:
[code:se0b9l6k]"/M=wl_EditTagDatabase /T=1/WIN=" + str(window_id)[/code:se0b9l6k]
Because of this the /M=<macro> parameter should be the last parameter in the misc string (all following parameters should be for your <macro>).

Note: The following parameters are added to the MParm_Str passed to your macro so they are available to you:
[code:se0b9l6k] "/DLGHANDLE=" + Str( Window ) +
"/DATAHANDLE=" + Str( Dlg) +
"/CTRLID=" + Str( Ctrl.Id )
[/code:se0b9l6k]
DLGHANDLE – The windows operating system handle to the dialog window.
DATAHANDLE – Dlg (set by DlgCreate).
CTRLID – The ctrlid of your pushbutton. 1210 in the example above.

Note: You may need to specify “/M=file^macro” if it’s your own macro.

If <macro> sets Return_Int=TRUE and /R=<n> is also specified then the dialog box will exit returning <n> (except if <n>=2 in which case help is invoked and the dialog box does not exit, or if <n>=0 in which case dialog box does not exit).

ADVANCED OPTIONS FOR /M=<macro>:
(I do not cover the usage of these advanced options. You’re on your own.)[list:se0b9l6k][*:se0b9l6k]If (Return_Str == “DESTROY_WINDOW”) destroy_flag=1[/*:m:se0b9l6k]
[*:se0b9l6k]If modeless and /R=0 specified then destroy_flag=1[/*:m:se0b9l6k]
[*:se0b9l6k]/SV=1 (Save Value). If specified and macro sets Return_Int=TRUE, then save Return_Str via menu_set_str(dlg, c_parm, 2, return_str). String can be retrieved via s = menu_item_str(dlg, c_parm, 2). (See Dialog.s macro DlgMessageProc subroutine Id_Menu_Item to see how c_parm is determined.)[/*:m:se0b9l6k]
[*:se0b9l6k]/NRA=1 No Reactivate. Usually after running your macro the program makes our dialog box the active window again. You can prevent this by specifying “/NRA=1”.[/*:m:se0b9l6k]
[*:se0b9l6k]If /M=<macro> is not specified then (if modeless && /R=0): return_int=0; destroy_flag=1; (i.e. do not exit dialog but destroy dialog window?)[/*:m:se0b9l6k][/list:u:se0b9l6k]

What happens when you click the push button depends on what parameters you specify for the misc parameter of DlgAddCtrl:
“” – dialog exits and returns control ID number as result (in this example, Result=1210).
“/R=2” – dialog does not exit, instead invokes help.
“/R=<n>” where (<n> != 2), dialog exits and returns <n>

“/M=<macro>” – dialog runs macro and does not exit.

“/R=0/M=<macro>” – dialog runs macro and does not exit.
“/R=2/M=<macro>” – dialog runs macro, then invokes help, and does not exit.
“/R=<n>/M=<macro>” where (<n> != 0 or 2), dialog first runs macro, then if macro sets Return_Int=TRUE the dialog exits and returns <n>.

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over PushButton.

“/RESIZE=X” or “/RESIZE=Y” or “/RESIZE=XY”
(something to do with resizing the window…)

BITMAP BUTTON (dlg_BitmapBtn)
BITMAP BUTTON with text (dlg_BitmapBtn)
All available bitmap images are listed in the
Chapter 7. This one is bitmap BT_ED_110.
[code:se0b9l6k]#include Dialog.sh

void MyBitmapBtnDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_BitmapBtn, "BT_ED_110",
1, 1, //coordinates X, Y
23, 0, //Width, Height
1211, 0, "" );

Result = DlgExecute( Dlg, 1211, "BitmapBtn",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
All optional flags and misc parameters for dlg_PushButton also apply to dlg_BitmapBtn (see above).

DIRECTORY BUTTON (dlg_DirButton)
The image here is actually two elements. There’s a dlg_Text element where you can type in a filename (or Directory), then there’s a dlg_DirButton which you can click to get a standard “Select File” (or “Select Directory”) dialog.
[code:se0b9l6k]#include Dialog.sh

void MyDirButtonDlg()
{
int Dlg, Result;
str MyFileName[259];

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_Text, "",
1, 1, //coordinates X, Y
44, 0, //Width, Height
2010, 0, "/ML=259" );

DlgAddCtrl( Dlg, Dlg_DirButton, "...",
46, 1, //coordinates X, Y
4, 0, //Width, Height
2011, 0, "/SID=2010/FILE=1/FM=*.txt" );

//Optionally set initial filename.
//Be careful of backslash in double-quoted strings.
//I suggest using a single quoted string instead.
//If path not specified then initial path is working directory
/* DlgSetStr( Dlg, 2010, ‘C:\TEMP\MyFile.txt’ ); */

Result = DlgExecute( Dlg, 2010, "DirButton",
"",
"",
0 );

MyFileName = DlgGetStr( Dlg, 2010);

MAKE_MESSAGE("MyFileName="+MyFileName);

DlgKill( Dlg );
}
[/code:se0b9l6k][list:se0b9l6k][*:se0b9l6k]You must assign a control ID number (e.g. 2011) to the Dlg_DirButton or it won’t work (don’t use -1).[/*:m:se0b9l6k]
[*:se0b9l6k]In Windows the maximum file path/name length is 259.[/*:m:se0b9l6k][/list:u:se0b9l6k]OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The button is disabled and grayed out.
dlgf_DefButton – Declare this the default button.
[/code:se0b9l6k]The default button is the button pushed if you press the return key. You should only declare one button to be the default button.

You can also make this the default button by calling: DlgSetInt (dlg, ctrlid, 1); [e.g. DlgSetInt (dlg, 1210, 1);]

You can also make this the default button by specifying this CtrlId as the startid in the call to DlgExecute.

OPTIONAL misc PARAMETERS
[code:se0b9l6k]"/SID=<control ID>" – ID of field to put file path/name into.
"/FILE=1" – File prompt instead of directory prompt.
"/FM=<file mask>" – e.g. "/FM=*.txt"
[/code:se0b9l6k]
If you specify “/FILE=1” then a file prompt dialog comes up. If you do not specify “/FILE=1” then a directory prompt dialog comes up.

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

KEYCODE (dlgKeycode)
Used for entering a key or key combination (such as Ctrl+Z).
Click the button to the right of the key field to get:

then press the key (or key combination) you want to define.
[code:se0b9l6k]#include Dialog.sh

void MyKeycodeDlg()
{
int Dlg, Result;
str key;
int disabled = false;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_Keycode, "/KL=Ctrl+Z/K1=90/K2=5",
1, 1, //coordinates X, Y
23, 1, //Width, Height
2301, 0, "" );

Result = DlgExecute( Dlg, 2301, "Keycode",
"",
"",
0 );

Key = DlgGetStr( Dlg, 2301 );

MAKE_MESSAGE(’Key="’+key+’"’);

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The control is disabled and grayed out
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS:
[code:se0b9l6k]"/FLAGS=" + str (SK_NoCurrentAssign)
Do not display current key assignment

"/FLAGS=" + str (SK_NoDelete)
Do not display "Delete" key

"/FLAGS=" + str (SK_NoDelete | SK_NoCurrentAssign)
Do not display current key assignment or "Delete" key

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.
[/code:se0b9l6k]
This one is unusual as the flags are passed using a “/FLAGS=” string.

SELECT COLOR (dlg_SelectColor)
When you click on the COLOR button it brings up a standard color selection dialog:

If you then click the DEFINE CUSTOM COLORS button it brings up:

[code:se0b9l6k]#include Dialog.sh

void MyColorDlg()
{
int Dlg, Result;
int MyColor;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_SelectColor, "&Color",
1, 1, //coordinates X, Y
13, 1, //Width, Height
2302, 0, "" );

//Optionally set the initial color.
//If not specified then initial color is black.
//Note the order is reversed.
//Usual order is 0xRRGGBB where RR=red, GG=green, BB=blue.
//Here the order is 0xBBGGRR
DlgSetInt( dlg, 2302, 0x80FFFF);

Result = DlgExecute( Dlg, 1, "Color",
"",
"",
0 );

MyColor = DlgGetInt( Dlg, 2302 );

MAKE_MESSAGE("MyColor=0x"+Hex_str(MyColor));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The control is disabled and grayed out.
dlgf_DefButton – Declare this the default button.
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

MACRO BUTTON WHICH RETURNS A STRING (dlg_MacroBtnStr)
This one’s a bit complicated. When you click the button it runs the macro you specified. The macro may return a string in system variable Return_Str. If the macro sets Return_Int=TRUE then the string returned in Return_Str is displayed in the text field. You can not manually edit the text field.

The one example of this is TOOLS -> CUSTOMIZE -> General (left side), “Command set:” . You can click the button to get the “Command Set Manager” dialog box. The “Command Set Manager” dialog box does all the work, and changes the keymap if you select another one. The “Command Set Manager” dialog box returns in system variable Return_Str a string indicating which keymap you chose to change to.

Specify a macro by adding “/M=<macro>” to the misc parameter of DlgAddCtrl.

[code:se0b9l6k]#include Dialog.sh

void MyMacroBtnStrDlg()
{
int Dlg, Result;
str MyStr;

rm("CmdSetMgr /M=1"); //Fills Return_Str with current
//command set.

DlgCreate( Dlg );

DlgAddCtrl( dlg, Dlg_MacroBtnStr, Return_Str,
1, 1, //coordinates X, Y
23, 1, //Width, Height
2400, 0, "/M=Setup^CmdSetMgr" );

Result = DlgExecute( Dlg, 2400, "MacroBtnStr",
"",
"",
0 );

MyStr = DlgGetStr( Dlg, 2400 );
MAKE_MESSAGE("MyStr="+MyStr);

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The control is disabled and grayed out
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS
/M=<macro>
The macro run when user presses button. Note: You may need to specify “/M=file^macro” if it’s your own macro. To pass parameters to the macro leave a space after “/M=<macro>” then list your parameters.

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

STATIC ICONS & BITMAPS

ICON (dlg_Icon)
These are the three icons I’ve been able to find in Mult-Edit.[list:se0b9l6k][*:se0b9l6k]question mark[/*:m:se0b9l6k][*:se0b9l6k]exclamation point[/*:m:se0b9l6k][*:se0b9l6k]stop sign[/*:m:se0b9l6k][/list:u:se0b9l6k]
[code:se0b9l6k]#include Dialog.sh

void MyIconDlg()
{
int Dlg, Result, MyInt;
str MyStr;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_Icon, "IC_QUESTION",
1, 1, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

DlgAddCtrl( Dlg, Dlg_Icon, "IC_EXCLAMATION",
8, 1, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

DlgAddCtrl( Dlg, Dlg_Icon, "IC_STOP",
16, 1, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 0, "Dialog Icons",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

STATIC BITMAP (dlg_BitmapStatic)
All available bitmap images are listed in the
Chapter 7. This one is bitmap BT_ED_110.
[code:se0b9l6k]#include Dialog.sh

void MyBitmapStaticDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_BitmapStatic, "BT_ED_110",
1, 1, //coordinates X, Y
23, 3, //Width, Height
101, 0, "" );

Result = DlgExecute( Dlg, 101, "BitmapStatic",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

BOXES, RECTANGLES, FRAMES

GROUP BOX (dlg_GroupBox)
A group box has text such as the word “Options” here.
[code:se0b9l6k]#include Dialog.sh

void MyGroupBoxDlg()
{
int Dlg, Result, MyInt;
str MyStr;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, Dlg_GroupBox, "Options",
1, 1, //coordinates X, Y
32, 3, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "GroupBox",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS:
[code:se0b9l6k]dlgf_Disable – The box text is grayed out
[/code:se0b9l6k]
OPTIONAL misc PARAMETERS

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

“/RESIZE=H”
“/RESIZE=WH”
(something to do with resizing the window…)

The following two look similar:
GREY FRAME (dlg_GreyFrame)
[code:se0b9l6k]#include Dialog.sh

void MyGreyFrameDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_GreyFrame, "",
2, 2, //coordinates X, Y
23, 0, //Width, Height
-1, 0, "" );

// This is a trick to make the dialog box bigger
// we place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
26, 4, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "GreyFrame",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

GREY RECTANGLE (dlg_GreyRect)
[code:se0b9l6k]#include Dialog.sh
void MyGreyRectDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_GreyRect, "",
2, 2, //coordinates X, Y
23, 0, //Width, Height
-1, 0, "" );

// This is a trick to make the dialog box bigger
// we place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
26, 4, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "GreyRect",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.
(This one is never used in Multi-Edit.)

The following four look similar:
BLACK FRAME (dlg_BlackFrame)
[code:se0b9l6k]#dialog.sh

void MyBlackFrameDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_BlackFrame, "",
2, 2, //coordinates X, Y
23, 0, //Width, Height
-1, 0, "" );

// This is a trick to make the dialog box bigger
// we place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
26, 4, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "BlackFrame",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

BLACK RECTANGLE (dlg_BlackRect)
[code:se0b9l6k]#include Dialog.sh

void MyBlackRectDlg()
{
int Dlg, Result, MyInt;
str MyStr;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_BlackRect, "",
2, 2, //coordinates X, Y
23, 0, //Width, Height
-1, 0, "" );

// This is a trick to make the dialog box bigger
// we place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
26, 4, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "BlackRect",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

WHITE FRAME (dlg_WhiteFrame)
[code:se0b9l6k]#include Dialog.sh

void MyWhiteFrameDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_WhiteFrame, "",
2, 2, //coordinates X, Y
23, 0, //Width, Height
-1, 0, "" );

// This is a trick to make the dialog box bigger
// We place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
26, 4, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "WhiteFrame",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

WHITE RECTANGLE (dlg_WhiteRect)
[code:se0b9l6k]#include Dialog.sh

void MyWhiteRectDlg()
{
int Dlg, Result;

DlgCreate( Dlg );

DlgAddCtrl( Dlg, dlg_WhiteRect, "",
2, 2, //coordinates X, Y
23, 0, //Width, Height
-1, 0, "" );

// This is a trick to make the dialog box bigger
// we place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
26, 4, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

Result = DlgExecute( Dlg, 1, "WhiteRect",
"",
"",
0 );

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}
[/code:se0b9l6k]
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS:

/TT=<tool tip text>
Text which pops up when you hover mouse pointer over control.

EXAMPLE:
Put them all together and you can make a dialog box such as this:

[code:se0b9l6k]#include Dialog.sh
#include StdDlgs.sh

void MyTESTDlg()
{
int Dlg, Result, MyInt;
str MyStr;

DlgCreate( Dlg );

//STATIC TEXT
DlgAddCtrl( Dlg, Dlg_Static, ‘This is static text.’,
1, 1, //coordinates X, Y
20, 1, //Width, Height
-1, 0, "" );

//TEXT
DlgAddCtrl( Dlg, Dlg_Static, ‘Enter some text:’,
dlg_PosOffset, dlg_PosOffset+1, // X, Y
17, 1, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, Dlg_Text, MyStr,
18, dlg_PosOffset, //coordinates X, Y
23, 1, //Width, Height
1200, 0, "/ML=300/HISTORY=!DELEY_HISTORY" );

//INTEGER
DlgAddCtrl( Dlg, Dlg_Static, ‘Enter an integer:’,
1, dlg_PosOffset+1, //coordinates X, Y
17, 1, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, Dlg_Integer, "",
18, dlg_PosOffset, //coordinates X, Y
23, 1, //Width, Height
1201, 0, "/MIN=0/MAX=10" );
/*DlgSetInt( Dlg, 1201, 3 );*/ //Optionally set initial value

//CHOICE
DlgAddCtrl( Dlg, Dlg_Static, ‘Make a choice:’,
1, dlg_PosOffset+1, //coordinates X, Y
17, 1, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, Dlg_Choice,
"Choice 1()Choice 2()Choice 3()",
18, dlg_PosOffset, //coordinates X, Y
23, 1, //Width, Height
1202, 0, "/TT=Choices" );

//CHECKBOX
DlgAddCtrl( Dlg, Dlg_CheckBox, ‘Click the checkbox.’,
1, dlg_PosOffset+1, //coordinates X, Y
23, 1, //Width, Height
1203, 0, "/TT=checkbox" );

//RADIO BUTTONS
DlgAddCtrl( Dlg, Dlg_GroupBox, "Options",
1, dlg_PosOffset+1, //coordinates X, Y
13, 4, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, Dlg_RadioButton, ‘One’,
2, dlg_PosOffset+1, //coordinates X, Y
11, 1, //Width, Height
1301, 0, "/TT=option #1" );
DlgSetInt (Dlg, 1301, 1 );
DlgAddCtrl( Dlg, Dlg_RadioButton, ‘Two’,
2, dlg_PosOffset+1, //coordinates X, Y
11, 1, //Width, Height
1302, 0, "/TT=option #2" );
DlgAddCtrl( Dlg, Dlg_RadioButton, ‘Three’,
2, dlg_PosOffset+1, //coordinates X, Y
11, 1, //Width, Height
1303, 0, "/TT=option #3" );

//ICONS
DlgAddCtrl( Dlg, Dlg_Icon, "IC_QUESTION",
14, dlg_NegOffset | 3, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, Dlg_Icon, "IC_EXCLAMATION",
20, dlg_PosOffset, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, Dlg_Icon, "IC_STOP",
26, dlg_PosOffset, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

//BITMAP
DlgAddCtrl( Dlg, Dlg_BitmapStatic, "BT_ED_110",
14, dlg_PosOffset+2, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );

//BITMAP BTN
DlgAddCtrl( Dlg, Dlg_BitmapBtn, "BT_ED_110",
20, dlg_PosOffset, //coordinates X, Y
6, 0, //Width, Height
1321, 0, "/TT=bitmap button" );
DlgAddCtrl( Dlg, Dlg_BitmapBtn, "BT_ED_110 &YES",
28, dlg_PosOffset, //coordinates X, Y
12, 0, //Width, Height
1322, 0, "/TT=bitmap button with text" );

//DIR BUTTON
DlgAddCtrl( Dlg, Dlg_Static, ‘File Name:’,
1, dlg_PosOffset+3, //coordinates X, Y
14, 1, //Width, Height
-1, 0, "" );
DlgAddCtrl( Dlg, dlg_Text,
‘C:\Program Files\Multi-Edit\Src\Ada.s’,
1, dlg_PosOffset+1,
32, 0,
2010, 0, "/ML=259/TT=filename" );
// ML=Maximum Length.
// For filespec on Windows max length is 259.
DlgAddCtrl( Dlg, Dlg_DirButton, "...",
34, dlg_PosOffset, //coordinates X, Y
4, 0, //Width, Height
2011, 0, "/SID=2010/FILE=1/TT=DirButton" );
// SID=<ID> of field to put filename in.
// Must assign an ID number (like 2011) to the
// Dlg_DirButton or it won’t work

//COLOR
DlgAddCtrl( Dlg, Dlg_SelectColor, "&Color",
1, dlg_PosOffset+2, //coordinates X, Y
13, 1, //Width, Height
2020, 0, "/TT=color" );
DlgSetInt( dlg, 2020, 0x80FFFF);
//Note the order is reversed
//Usual order is 0xRRGGBB where RR=red, GG=green, BB=blue.
//Here the order is 0xBBGGRR

//PUSH BUTTONS
DlgAddCtrl( Dlg, Dlg_PushButton, "Help",
dlg_PosOffset+20, dlg_PosOffset, //coordinates X, Y
9, 1, //Width, Height
2030, 0, "/R=2/TT=help button" );

DlgAddCtrl( Dlg, Dlg_PushButton, "OK",
dlg_PosOffset+12, dlg_PosOffset, //coordinates X, Y
9, 1, //Width, Height
2031, 0/*dlgf_DefButton*/,
"/TT=OK button/R=7/M=MyBtnMac" );

//RUN THE DIALOG
Result = DlgExecute( Dlg, 0, "My TEST Dialog",
"",
"",
0 );

//GET RESULTS
str MyText = DlgGetStr( Dlg, 1200); //dlg_Text
int MyInteger = DlgGetInt( Dlg, 1201); //dlg_Integer
int MyChoice = DlgGetInt( Dlg, 1202); //dlg_Choice
int checked = DlgGetInt( Dlg, 1203); //dlg_Checkbox
int option1 = DlgGetInt( Dlg, 1301); //dlg_RadioButton
int option2 = DlgGetInt( Dlg, 1302); //dlg_RadioButton
int option3 = DlgGetInt( Dlg, 1303); //dlg_RadioButton
str MyFileName = DlgGetStr( Dlg, 2010); //Dlg_DirButton
int MyColor = DlgGetInt( Dlg, 2020); //Dlg_SelectColor

MAKE_MESSAGE("Result="+str(result));

DlgKill( Dlg );
}

macro MyBtnMac()
{
MsgDlg("Inside MyBtnMac","MyBtnMac","",0);
}
[/code:se0b9l6k]

NOT DISCUSSED (See chapter 12.1)
dlg_RealNumber
dlg_Hex
dlg_ListTextBox
dlg_MacroBtnInt
dlg_HiddenStr
dlg_HiddenInt
dlg_OwnerButton

TO BE DISCUSSED LATER (maybe):
dlg_ListBox
dlg_TreeList
dlg_ViewTextBox
dlg_TabBar
dlg_TreeBar

MISC NOTES
“/CHANGEMAC=<macro>”
Note dlg_BitmapBtn does not do changemac but dlg_PushButton does do it.
[code:se0b9l6k]DlgMessageProc()
Process_Wcmd:
case DLG_Text :
case DLG_Integer :
if ( ( Parse_Str( "/HISTORY=", MStr ) != "" ) && g_AutoComplete ) {
switch ( wms.NotifyCode ) {
case cbn_EditChange :
call Process_ChangeMac;
else {
switch ( wms.NotifyCode ) {
case en_Change :
call Process_ChangeMac;

case DLG_DirButton :
case DLG_Checkbox :
case DLG_3State :
case Dlg_RadioButton :
case DLG_PushButton :
if ( wms.NotifyCode == BN_CLICKED) {
call Process_ChangeMac;

case DLG_ListBox :
switch ( wms.NotifyCode ) {
case lbn_KillFocus :
case lbn_SelChange :
if ( Win_Num ) {
if ( wms.NotifyCode == lbn_SelChange ) {
call Process_ChangeMac;

case DLG_Choice :
switch ( wms.NotifyCode ) {
case cbn_KillFocus :
case cbn_SelChange :
if ( wms.NotifyCode == cbn_SelChange ) {
call Process_ChangeMac;
[/code:se0b9l6k]
If you want to pass parameters to the CHANGEMAC <macro>, add a space after the <macro> name, then use double forward slashes for each parameter. e.g.:
[code:se0b9l6k]misc = "/CHANGEMAC=_M2ShowIndStyle //CH=1//PI=1"
YStr = Parse_Str( "/CHANGEMAC=", misc );
[/code:se0b9l6k]
Result: YStr = “_M2ShowIndStyle /CH=1/PI=1”. This string is then passed to RUN_MACRO.

Also use double forward slashes for /FOCUSMAC e.g.:
[code:se0b9l6k]misc = "/FOCUSMAC=_M2ShowIndStyle //PI=1";
YStr = Parse_Str( "/FOCUSMAC=", misc );
[/code:se0b9l6k]
Result: YStr = “_M2ShowIndStyle /PI=1”. This string is then passed to RUN_MACRO.

Note: You may need to specify “/CHANGEMAC=file^macro” if it’s your own macro.
Note: You may need to specify “/FOCUSMAC=file^macro” if it’s your own macro.