|
- Written and documented by David Deley
Introduction to CMac Chapter 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: |
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
)
|
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
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: |
| (dlgf_GetTextFromWin | dlgf_es_MultiLine | dlgf_es_WantReturn) |
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.
All controls can have /RESIZE={XYWH}. The options are:
/RESIZE=X control will remain same size but will move if window is stretched horizontally.
/RESIZE=W control will stretch if window is stretched horizontally.
/RESIZE=Y control will remain same size but will move if window is stretched vertically.
/RESIZE=H control will stretch if window is stretched vertically (if control can stretch vertically).
Also:
/RESIZE=XY
/RESIZE=WH
If any control has /RESIZE= specified, then the dialog box can be stretched both horizontally and vertically.
Following are basic examples of each control, along with sample code.
 STATIC TEXT (dlg_Static)
| Code: |
#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, -1, "Static Text",
"",
"",
0 );
MAKE_MESSAGE("Result="+str(result));
DlgKill( Dlg );
}
|
OPTIONAL FLAGS:
| Code: |
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
|
OPTIONAL misc PARAMETERS: None
 TEXT (dlg_Text)
| Code: |
#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 );
}
|
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
Introduction to CMac: 3. Caveats. (Caveat #5))
OPTIONAL FLAGS:
| Code: |
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.
|
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: |
DlgAddCtrl( Dlg, Dlg_Text, MyText,
1, 1, //coordinates X, Y
23, 3, //Width, Height
1002, 0, "/HISTORY=!DELEY_HISTORY" );
|
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 '@'.)
Tech Note: A
dlg_Text control without /HISTORY=<global variable> corresponds
to a windows EDIT control. However if you add /HISTORY=<global
variable>, then the control corresponds to a windows COMBOBOX
control.
/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.
/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: |
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 ) );
|
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: |
#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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The field is disabled and greyed out
|
OPTIONAL misc PARAMETERS:
/MIN=<n>
Minimum number allowed.
/MAX=<n>
Maximum number allowed.
/CHANGEMAC=<macro>
Run macro whenever value is changed.
 CHOICE (dlg_Choice)
| Code: |
#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 );
}
|
All choice options end with and are separated by a pair of parenthesis ().
e.g. "Choice 1()Choice 2()Choice 3()".
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The field is disabled and greyed out
|
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>
Max drop down size. The maximum number of rows that will show when you click the down arrow to view the drop down box.
/VSCROLL=1
If you specify /MSIZE=<n>, and the list is longer than n, if
you then also specify /VSCROLL=1 then a vertical scroll bar will appear
on the right side of the list allowing you to scroll through the list.
If you don't specify /VSCROLL=1, you can scroll through the list using
the up/down arrow keys, but it's not immediately apparent that there
are more items in the list than shown.
/FOCUSMAC=<macro>
(usage unknown)
 CHECKBOX (dlg_CheckBox)
| Code: |
#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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The checkbox is disabled,
checkbox and text are greyed out.
|
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.
 AUTO 3 STATE CHECKBOX (dlg_3State)
When chosen, the box automatically advances between three states: checked, unchecked, and grayed out.
| Code: |
#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 );
}
|
Returns:
0 = box unchecked
1 = box checked
2 = box greyed out
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The checkbox is disabled,
checkbox and text are greyed out
|
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.
 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: |
#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, 1201, 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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The option and text is disabled and greyed out
|
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: |
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 );
}
}
|
 PUSH BUTTON (dlg_PushButton)
| Code: |
#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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The push button is disabled and greyed out
dlgf_DefButton - Designate this the default button
|
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: |
| "/M=wl_EditTagDatabase /T=1/WIN=" + str(window_id) |
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: |
"/DLGHANDLE=" + Str( Window ) +
"/DATAHANDLE=" + Str( Dlg) +
"/CTRLID=" + Str( Ctrl.Id )
|
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).
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.
ADVANCED OPTIONS FOR /M=<macro>:
(I do not cover the usage of these advanced options. You're on your own.)- If (Return_Str == "DESTROY_WINDOW") destroy_flag=1
- If modeless and /R=0 specified then destroy_flag=1
- /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.)
- /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".
- 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?)
 BITMAP BUTTON (dlg_BitmapBtn)
 BITMAP BUTTON with text (dlg_BitmapBtn)
All available bitmap images are listed in the
CMAC User Guide Chapter 7. This one is bitmap BT_ED_110.
| Code: |
#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, "" );
// This is a trick to make the dialog box bigger
// we place blank text in the lower right corner
DlgAddCtrl( Dlg, Dlg_Static, "",
23, 1, //coordinates X, Y
0, 0, //Width, Height
-1, 0, "" );
Result = DlgExecute( Dlg, -1, "BitmapBtn",
"",
"",
0 );
MAKE_MESSAGE("Result="+str(result));
DlgKill( Dlg );
}
|
All optional flags and misc parameters for dlg_PushButton also apply to dlg_BitmapBtn (see above).
- NOTE: Do not make a BitmapBtn the default button or the bitmap won't show (text will show instead).
 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: |
#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" );
//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 );
}
|
- You must assign a control ID number (e.g. 2011) to the Dlg_DirButton or it won't work (don't use -1).
- In Windows the maximum file path/name length is 259.
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The button is disabled and grayed out.
dlgf_DefButton - Declare this the default button.
|
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: |
"/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"
|
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: |
#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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The control is disabled and grayed out
|
OPTIONAL misc PARAMETERS:
| Code: |
"/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.
|
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: |
#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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The control is disabled and grayed out.
dlgf_DefButton - Declare this the default button.
|
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: |
#include Dialog.sh
void MyMacroBtnStrDlg()
{
int Dlg, Result;
str MyStr;
rm("Setup^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 );
}
|
OPTIONAL FLAGS:
| Code: |
dlgf_Disable - The control is disabled and grayed out
|
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.- question mark
- exclamation point
- stop sign
| Code: |
#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, -1, "Dialog Icons",
"",
"",
0 );
MAKE_MESSAGE("Result="+str(result));
DlgKill( Dlg );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
 STATIC BITMAP (dlg_BitmapStatic)
All available bitmap images are listed in the
CMAC User Guide Chapter 7. This one is bitmap BT_ED_110.
| mblue: |
#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, -1, "BitmapStatic",
"",
"",
0 );
MAKE_MESSAGE("Result="+str(result));
DlgKill( Dlg );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
BOXES, RECTANGLES, FRAMES
 GROUP BOX (dlg_GroupBox)
A group box has text such as the word "Options" here.
| mblue: |
#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 );
}
|
OPTIONAL FLAGS:
| mblue: |
dlgf_Disable - The box text is grayed out
|
OPTIONAL misc PARAMETERS:
"/RESIZE={XYWH}" (See above about /RESIZE)
The following two look similar:
 GREY FRAME (dlg_GreyFrame)
| mblue: |
#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 );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
 GREY RECTANGLE (dlg_GreyRect)
| mblue: |
#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 );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
The following four look similar:
 BLACK FRAME (dlg_BlackFrame)
| mblue: |
#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 );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
 BLACK RECTANGLE (dlg_BlackRect)
| mblue: |
#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 );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
 WHITE FRAME (dlg_WhiteFrame)
| mblue: |
#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 );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
 WHITE RECTANGLE (dlg_WhiteRect)
| mblue: |
#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 );
}
|
OPTIONAL FLAGS: None.
OPTIONAL misc PARAMETERS: None.
EXAMPLE:
Put them all together and you can make a dialog box such as this:
| mblue: |
#include Win32.sh //Must come before #include MsgLog.sh
//(defines struct TMsg used by MsgLog.sh)
#include MsgLog.sh //DebugLog is defined here.
#include Dialog.sh
#include StdDlgs.sh //Defines MsgDlg
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/M=MyBtnMac" );
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/M=MyBtnMac" );
//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" );
//RUN THE DIALOG
Result = DlgExecute( Dlg, -1, "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
/*
DebugLog(2,"MyText ",MyText );
DebugLog(2,"MyInteger ",str(MyInteger) );
DebugLog(2,"MyChoice ",str(MyChoice) );
DebugLog(2,"checked ",str(checked) );
DebugLog(2,"option1 ",str(option1) );
DebugLog(2,"option2 ",str(option2) );
DebugLog(2,"option3 ",str(option3) );
DebugLog(2,"MyFileName",MyFileName );
DebugLog(2,"MyColor ",hex_str(MyColor) );
*/
MAKE_MESSAGE("Result="+str(result));
DlgKill( Dlg );
}
macro MyBtnMac()
{
MsgDlg(
"You pressed the button which activated macro MyBtnMac.",
"MyBtnMac","",0);
}
|
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
dlg_SubDlg
MISC NOTES
"/CHANGEMAC=<macro>"
Note dlg_BitmapBtn does not do changemac but dlg_PushButton does do it.
| mblue: |
DlgMessageProc()
Process_Wcmd:
case DLG_Text :
case DLG_Integer :
if ( ( Parse_Str( "/HISTORY=", MStr ) != "" ) && g_AutoComplete ) {
switch ( wms.Notifymblue ) {
case cbn_EditChange :
call Process_ChangeMac;
else {
switch ( wms.Notifymblue ) {
case en_Change :
call Process_ChangeMac;
case DLG_DirButton :
case DLG_Checkbox :
case DLG_3State :
case Dlg_RadioButton :
case DLG_PushButton :
if ( wms.Notifymblue == BN_CLICKED) {
call Process_ChangeMac;
case DLG_ListBox :
switch ( wms.Notifymblue ) {
case lbn_KillFocus :
case lbn_SelChange :
if ( Win_Num ) {
if ( wms.Notifymblue == lbn_SelChange ) {
call Process_ChangeMac;
case DLG_Choice :
switch ( wms.Notifymblue ) {
case cbn_KillFocus :
case cbn_SelChange :
if ( wms.Notifymblue == cbn_SelChange ) {
call Process_ChangeMac;
|
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.:
| mblue: |
misc = "/CHANGEMAC=_M2ShowIndStyle //CH=1//PI=1"
YStr = Parse_Str( "/CHANGEMAC=", misc );
|
Result: YStr = "_M2ShowIndStyle /CH=1/PI=1". This string is then passed to RUN_MACRO.
Also use double forward slashes for /FOCUSMAC e.g.:
| mblue: |
misc = "/FOCUSMAC=_M2ShowIndStyle //PI=1";
YStr = Parse_Str( "/FOCUSMAC=", misc );
|
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.
Related Articles:
Introduction to CMAC 12.1 DIALOG BOXES: The Elements
Introduction to CMAC 12.2 DIALOG BOXES: The Coordinates
Introduction to CMAC 12.3 DIALOG BOXES: Sample mblue For Each Control
Introduction to CMAC 12.4 DIALOG BOXES: DlgExecute {under construction}
(Edits to this
Introduction to CMAC series are occasionally made as I learn more.) |