The DialogControl class provides methods that are common to all dialog controls. It is a generic class that serves as a superclass to all dialog control specific classes. In the graphical user interface (GUI) for the Windows operating system both dialogs and dialog controls are windows. Therefore, many of the methods of the DialogControl class are the same as the methods of the ooDialog dialog classes. These are the methods that are common to all windows, whether they are dialog windows or dialog control windows.
In the Windows GUI all windows are created with a set of window styles. Dialog control windows are created using styles that are common to all windows, (for example the visible style,) and styles specific to the dialog control itself, (for example the multi-line style of the EditControl class.) In general the styles of a control fall into three categories: Styles that can only be set when the control is created and then can not be changed afterwards. Styles that can be changed after the control is created by sending messages to the control. And, styles that can be changed after the control is created by accessing the control window directly.
The ooDialog programmer chooses the window styles for dialog controls when he defines the dialog, either by using the Add... Methods for a user dialog, or by using a resource editor for dialogs defined with resource scripts or binary compiled resources. After the dialog control has been created, the individual dialog control classes provide methods to change those styles that can be changed, either by sending the proper message to the control or by accessing the control window directly.
The DialogControl class requires the class definition file oodwin32.cls:
::requires oodwin32.cls
Instances of the DialogControl class have the following attributes:
The horizontal size of one dialog unit, in pixels.
The vertical size of one dialog unit, in pixels.
The width of the dialog control, in dialog units, when the ooRexx object that represents the control is created.
Note: The SizeX attribute is not changed by ooDialog after the object is instantiated. If the programmer resizes the dialog control manually, and requires that the value of the attribute be correct, then the programmer would need to update the value herself.
The height of the dialog control, in dialog units, when the ooRexx object that represents the control is created.
Note: The SizeY attribute is not changed by ooDialog after the object is instantiated. If the programmer resizes the dialog control manually, the programmer would also need to update the value of this attribute herself, if she requires that the value remain correct.
Instances of the DialogControl class implement the methods listed in the following DialogControl Instance Methods table.
Table 5-1. DialogControl Instance Methods
Method... | ...on page |
---|---|
AbsRect2LogRect | AbsRect2LogRect |
AssignFocus | AssignFocus |
AssignWindow | AssignWindow |
CaptureMouse | CaptureMouse |
Clear | Clear |
ClearRect | ClearRect |
ClientToScreen | ClientToScreen |
ConnectFKeyPress | ConnectFKeyPress |
ConnectKeyPress | ConnectKeyPress |
CreateBrush | CreateBrush |
CreateFont | CreateFont |
CreatePen | CreatePen |
Cursor_AppStarting | Cursor_AppStarting |
Cursor_Arrow | Cursor_Arrow |
Cursor_Cross | Cursor_Cross |
Cursor_No | Cursor_No |
CursorPos | CursorPos |
Cursor_Wait | Cursor_Wait |
DeleteFont | DeleteFont |
DeleteObject | DeleteObject |
Disable | Disable |
DisconnectKeyPress | DisconnectKeyPress |
Display | Display |
Draw | Draw |
DrawAngleArc | DrawAngleArc |
DrawArc | DrawArc |
DrawLine | DrawLine |
DrawPie | DrawPie |
DrawPixel | DrawPixel |
Enable | Enable |
FillDrawing | FillDrawing |
FontColor | FontColor |
FontToDC | FontToDC |
ForegroundWindow | ForegroundWindow |
FreeDC | FreeDC |
GetArcDirection | GetArcDirection |
GetClientRect | GetClientRect |
GetDC | GetDC |
GetFocus | GetFocus |
GetID | GetID |
GetMouseCapture | GetMouseCapture |
GetPixel | GetPixel |
GetPos | GetPos |
GetRect | GetRect |
GetSize | GetSize |
GetStyleRaw | GetStyleRaw |
GetTextSize | GetTextSize |
Group | Group |
HasKeyPressConnection | HasKeyPressConnection |
Hide | Hide |
HideFast | HideFast |
HScrollPos | HScrollPos |
IsMouseButtonDown | IsMouseButtonDown |
LoadBitmap | LoadBitmap |
LogRect2AbsRect | LogRect2AbsRect |
Move | Move |
ObjectToDC | ObjectToDC |
OpaqueText | OpaqueText |
ProcessMessage | ProcessMessage |
Rectangle | Rectangle |
Redraw | Redraw |
RedrawClient | RedrawClient |
RedrawRect | RedrawRect |
ReleaseMouseCapture | ReleaseMouseCapture |
RemoveBitmap | RemoveBitmap |
Resize | Resize |
RestoreCursorShape | RestoreCursorShape |
ScreenToClient | ScreenToClient |
Scroll | Scroll |
SetArcDirection | SetArcDirection |
SetColor | SetColor |
SetCursorPos | SetCursorPos |
SetFocus | SetFocus |
SetFocusToWindow | SetFocusToWindow |
SetFont | SetFont |
SetForegroundWindow | SetForegroundWindow |
SetHScrollPos | SetHScrollPos |
SetVScrollPos | SetVScrollPos |
SetRect | SetRect |
SetTitle | SetTitle |
Show | Show |
ShowFast | ShowFast |
TabStop | TabStop |
TabToNext | TabToNext |
TabToPrevious | TabToPrevious |
Title | Title |
Title= | Title= |
TransparentText | TransparentText |
Update | Update |
Value | Value |
Value= | Value= |
VScrollPos | VScrollPos |
Write | Write |
WriteToButton | WriteToButton |
WriteToWindow | WriteToWindow |
The following methods deal with the appearance or the behavior of the dialog control. The list contains methods to get or change the size, position, visibility, behavior, etc., of dialog controls.
>>-aDialogControl~Show-----------------------------------------><
The Show method makes a dialog control visible and activates it.
The following example makes the edit control NAME visible and activates it:
MyDialog~GetEditControl("NAME")~Show
>>-aDialogControl~Hide-----------------------------------------><
The Hide method makes a dialog or dialog control invisible and activates another dialog or dialog control.
MyDialog~GetEditControl("NAME")~Hide
>>-aDialogControl~HideFast-------------------------------------><
The HideFast method marks a dialog or dialog control as invisible but does not redraw it. Send the Update method (see page Update) to the dialog or dialog control to force a redraw.
MyDialog~GetEditControl("NAME")~HideFast ... MyDialog~Update
>>-aDialogControl~ShowFast-------------------------------------><
The ShowFast method marks a dialog or dialog control as visible but does not redraw it. Send the Update method (see page Update) to the dialog or dialog control to force a redraw.
MyDialog~GetEditControl("NAME")~ShowFast ... MyDialog~Update
+-NORMAL---+------+--+ | +-FAST-+ | >>-aDialogControl~Display(--"--+-DEFAULT--+------+--+--"--)---->< | +-FAST-+ | +-HIDE-----+------+--+ | +-FAST-+ | +-INACTIVE-----------+
The Display method displays (shows, makes visible, or invisible) a dialog control as specified.
This argument can be one of the following keywords (case is not significant.) If no argument is given, the default keyword is NORMAL:
Shows (makes visible) the dialog control. Same as calling the Show method (see page Show).
Default is an alias for NORMAL. The behavior is exactly the same for the two keywords.
Hides (makes invisible) the dialog control. Same as calling the Hide method (see page Hide).
Displays (shows, makes visible,) the dialog control in its current state. The active dialog remains active. When this method is invoked with the NORMAL keyword the dialog the control belongs to will be made the active window. If instead the INACTIVE keyword is used, the active window will not be changed. (Obviously, if the dialog that the control belongs to is already the active window, the INACTIVE keyword behaves exactly the same as the NORMAL keyword.
To each keyword, except the INACTIVE keyword, you can add FAST, separated by a blank, to suppress the redrawing of the dialog control.
The following statement makes a tree control in the dialog visible without redrawing it.
MyDialog~GetTreeControl(IDC_TREECONTROL_FILES)~Display("NORMAL FAST")This is usually done when there are a number of controls to make visible at one time. The programmer would make them all visible without redrawing. Then use the Update method to repaint everything at once.
>>-aDialogControl~Enable---------------------------------------><
The Enable method enables a dialog or dialog control to accept user interaction.
MyDialog~GetEditControl("Name")~Enable
>>-aDialogControl~Disable--------------------------------------><
The Disable method disables a dialog or dialog control.
MyDialog~GetEditControl("Name")~Disable
>>-aDialogControl~Group(--+-----------+--)--------------------->< +-wantStyle-+
Add or remove the group style for this control. The group style controls how the user can navigate through the dialog using the keyboard. For most dialogs this does not change while the dialog is executing. However, in some dialogs the programmer may want to change the navigation depending on the options the user selects.
The only argument is
A boolean (.true or .false) to indicate whether the control should have or not have the group style. True (the default) indicates the control should have the group style and false indicates the control should not have the style.
Negative values indicate the function failed, non-negative values indicate success.
The value is the negated Operating System Error code. The absolute value of the return can be used to look up the error reason in the Windows documentation.
The optional argument to the method is not a boolean.
There is an (internal) problem with the dialog or the dialog handle.
There is an (internal) problem with the resource ID of the control.
The window style of the dialog control prior to adding or removing the group style.
>>-aDialogControl~TabStop(--+-----------+--)-------------------->< +-wantStyle-+
Add or remove the tab stop style for the control. When a control has the tabstop style, the user can set the focus to the control by using the tab key. When a control does not have this style, the tab key will skip over the control. Adding or removing this style during the execution of a dialog allows the programmer to alter how the user navigates through the dialog controls.
The only argument is:
A boolean (.true or .false) to indicate whether the control should have or not have the tabstop style. True (the default) indicates the control should have the tabstop style and false indicates the control should not have the style.
Negative values indicate the function failed, non-negative values indicate success.
The value is the negated Operating System Error code. The absolute value of the return can be used to look up the error reason in the Windows documentation.
The second argument to the method is not a boolean.
There is an (internal) problem with the dialog or the dialog handle.
There is an (internal) problem with the resource ID of the control.
The window style of the dialog control prior to adding or removing the tabstop style.
>>-aDialogControl~Resize(--width--,--height--+-----------------------------+--)->< | +----------------+ | | V | | +-,--"----+-HIDEWINDOW-+-+--"-+ +-SHOWWINDOW-+ +-NOREDRAW---+
The Resize method resizes a dialog or dialog control.
The arguments are:
The new width of the dialog or dialog control, in dialog units.
The new height of the dialog or dialog control, in dialog units.
One or more of the following keywords, separated by blanks:
The dialog or dialog control is to be made invisible.
The dialog or dialog control is to be made visible.
The dialog or dialog control is to be repositioned without redrawing it.
Resizing was successful.
Resizing failed.
The following example resizes the tree view control FILES almost to the size of the window and displays the new size:
obj = MyDialog~GetTreeControl("FILES") if obj = .Nil then return obj~Resize(MyDialog~SizeX -10, MyDialog~SizeY -20) parse value obj~GetSize with width height say "New width of window is" width "and new height is" height
>>-aDialogControl~Move(--xPos--,--yPos--+----------------------------+--)->< | +----------------+ | | V | | +-,-"----+-HIDEWINDOW-+-+--"-+ +-SHOWWINDOW-+ +-NOREDRAW---+
The Move method moves the associated dialog or dialog control to the specified position.
The arguments are:
The new horizontal position of the dialog or dialog control, in dialog units.
The new vertical position of the dialog or dialog control, in dialog units.
One or more of the following keywords, separated by blanks:
The dialog or dialog control is to be made invisible.
The dialog or dialog control is to be made visible.
The dialog or dialog control is to be repositioned without redrawing it.
Moving was successful.
Moving failed.
The following example repositions the tree view control FILES to the upper left corner of the window and displays the new position:
obj = MyDialog~GetTreeControl("FILES") if obj = .Nil then return obj~Move(1,1) parse value obj~GetPos with x y say "New horizontal position of window is" x "and new vertical position is" y
>>-aDialogControl~SetForegroundWindow(--hwnd--)---------------------------><
The SetForegroundWindow method changes the foreground window to the window specified. The new window must be a top-level window or a dialog window. You can not make a dialog control window the foreground window.
The only argument is:
The handle to the window that is to become the foreground window.
The handle to the previous foreground window, or 0 if this method failed.
This example makes another dialog the foreground window and returns the window handle of the current foreground window to the caller, or returns -1 if there was an error:
::method switchToReportDlg expose reportDlg currentHwnd = self~setForeGroundwindow(reportDlg~dlgHandle) if currentHwnd == 0 then return -1 -- Report an error return currentHwnd
>>-aDialogControl~ForegroundWindow-----------------------------><
The ForegroundWindow method returns the handle to the current foreground window.
The handle to the foreground window, or 0 if this method failed.
>>-aDialogControl~GetID----------------------------------------><
The GetID method retrieves the identification number of the associated dialog or dialog control.
The numeric ID.
The following example displays 1 in most cases:
say MyDialog~GetButtonControl("IDOK")~GetID
>>-aDialogControl~GetStyleRaw----------------------------------><
The GetStyleRaw method retrieves the Windows style flags of the dialog control. The flags are returned in their numeric format. This allows the programmer to determine the current style of any control. However, the programmer needs to be able to look up the numeric value of the window style flags to make use of this functionality. This can be done using the Windows documentation and the Platform SDK.
A negative return indicates an error.
The value of the negated Operating System error code. The absolute value of the return can be used to look up the error reason in the Windows documentation.
There is an (internal) problem with the dialog or the dialog handle.
The numeric value of the window style flags for the control.
The following example gets the style flags for a tree control and then checks to see if drag and drop is enabled and if label editing is enabled.
The value of the style flags has the potential of being larger than can be accommodated by the default numeric digits. Use numeric digits 11 if the returned value needs to be manipulated, for instance to use d2x on the value.
Note: It is not necessary to convert the style value in the example to its hexadecimal string representation before using it as an argument in the BinaryAnd function. That is just done in the example for display purposes.
... numeric digits 11 TVS_DISABLEDRAGDROP = "0x0010" TVS_EDITLABELS = "0x0008" treeControl = self~getTreeControl(IDC_TREE) style = treeControl~getStyleRaw style = "0x" || style~d2x~right(8, '0') if BinaryAnd( style, TVS_DISABLEDRAGDROP ) <> 0 then str1 = 'disabled' else str1 = 'enabled' if BinaryAnd( style, TVS_EDITLABELS ) <> 0 then str2 = 'enabled' else str2 = 'disabled' say 'Tree-view Control styles' say ' Raw style: ' style say ' Drag and drop:' str1 say ' Edit labels: ' str2 /* Output coule be: */ Tree-view Control styles Raw style: 0x5000002F Drag and drop: enabled Edit labels: enabled
>>-aDialogControl~GetRect--------------------------------------><
Retrieves the dimensions of the rectangle surrounding the associated dialog or dialog control. The coordinates are relative to the upper left corner of the screen and are specified in screen pixels. The order is: left, top, right, bottom; where 'left' and 'top' are the x and y coordinates of the upper left-hand corner of the rectangle, and 'right' and 'bottom' are the coordinates of the bottom right-hand corner.
The coordinates of the dialog or dialog control, separated by blanks.
The following example calculates the width and height of an entry line:
parse value MyDialog~GetEditControl("Name")~GetRect with left top, right bottom width = right - left height = bottom - top
>>-aDialogControl~SetRect(--x--,--y--,--width--,--height--> >--+-----------------------------+--)-------------------->< | +----------------+ | | V | | +-,--"----+-NOMOVE-----+-+--"-+ +-NOSIZE-----+ +-HIDEWINDOW-+ +-SHOWWINDOW-+ +-NOREDRAW---+
The SetRect method sets new coordinates for the associated dialog or dialog control.
The arguments are:
The new position of the upper left corner, in screen pixels.
The new width of the dialog or dialog control, in screen pixels.
The new height of the dialog or dialog control, in screen pixels.
One or more of the following keywords, separated by blanks:
The upper left position of the dialog or dialog control is not changed.
The size of the dialog or dialog control is not changed.
The dialog or dialog control is to be made invisible.
The dialog or dialog control is to be made visible.
The dialog or dialog control is to be repositioned without redrawing it.
Repositioning was successful.
Repositioning failed.
>>-aDialogControl~GetClientRect(--+------+--)------------------>< +-hwnd-+
The GetClientRect method returns the client rectangle of a dialog or dialog control in screen pixels. The client coordinates specify the upper left and lower right corners of the client area. Because the client coordinates are relative to the upper left corner of the client area of a dialog or dialog control, the coordinates of the upper left corner are (0,0).
The only argument is:
The handle to a dialog or dialog control. If this argument is omitted, the dimensions of the associated dialog or dialog control are returned.
The client rectangle in the format "left top right bottom", separated by blanks.
>>-aDialogControl~GetPos---------------------------------------><
The GetPos method returns the coordinates of the upper left corner of the dialog or dialog control, in dialog units.
The horizontal and vertical position, separated by a blank.
For an example, see Move.
>>-aDialogControl~GetSize--------------------------------------><
The GetSize method returns the width and height of the dialog or dialog control, in dialog units.
The width and height, separated by a blank.
For an example, see Resize.
>>-aDialogControl~AssignFocus----------------------------------><
The AssignFocus method sets the input focus to the associated dialog control.
>>-aDialogControl~GetFocus-------------------------------------><
The GetFocus method returns the handle to the dialog control that currently has the input focus.
The handle to the dialog control that has the input focus, or 0 if this method failed.
>>-aDialogControl~SetFocus(--hwnd--)---------------------------><
The SetFocus method sets the input focus to a dialog control and returns the handle of the control that previously had the focus.
The only argument is:
The handle to the dialog control that is to receive the input focus.
The method failed.
The focus was changed, but the control with the previous focus could not be determined.
The handle to the control with the previous focus.
>>-aDialogControl~SetFocusToWindow(--hwnd--)-------------------><
The SetFocusToWindow method moves the input focus to another top-level window or dialog. This has the effect of bringing that window to the foreground. This method returns a handle to the dialog control that previously had the input focus.
The only argument is:
The handle to the top-level window or dialog that is to receive the input focus.
The method failed.
The focus was changed, but the control with the previous focus could not be determined.
The handle to the control with the previous focus.
>>-aDialogControl~SetColor(--background--,--foreground--)------><
The SetColor method sets the background and foreground colors of the dialog control.
The arguments are:
The color number of the background color.
The color number of the foreground color.
The color has been assigned.
The selected color was already assigned.
The following example sets the background color of list box FILES to blue:
MyDialog~GetListBox("FILES")~SetColor(4, 15)
>>-aDialogControl~Update---------------------------------------><
The Update method makes the contents of the dialog or dialog control invalid and therefore forces it to be updated.
>>-aDialogControl~Title----------------------------------------><
The Title method retrieves the title of the dialog or dialog control.
The title was retrieved.
Retrieving the title failed.
>>-aDialogControl~Title=--new_title----------------------------><
The Title= method sets the title of the dialog or dialog control.
The only argument is:
A text string that is to be used as the title or text of the dialog or dialog control.
The title was set.
Setting the title failed.
The following example changes the label of radio button CHOICE2:
MyDialog~GetRadioControl("CHOICE2")~Title="&Object Rexx (preferred choice)" MyDialog~Redraw