A
When you add a control to a dialog, it is important that each control has a unique numeric identifier. This identifier helps your application to know which control is sending an event. For example, if your program has two buttons in it, the control ID allows you distinguish between them.
As each control is created, Windows assigns a unique window handle to identify the control. Because your program does not assign these handle values, your code cannot directly use them to identify individual controls. Further, each time a control is destroyed and recreated, a new unique handle value is assigned, further complicating the task. The control ID overcomes these problems, as the programmer determines the ID for each control.
Controls are added to your dialog with the CONTROL ADD statement. Make sure that each control you create has a unique numeric identifier, so that you (and Windows) can tell it apart from other controls on the dialog. |
Given the ID of a control, DDT provides the CONTROL HANDLE statement to retrieve the window handle value of the control. If a given ID is duplicated in a dialog, CONTROL HANDLE is only able to identify the first control that matches the ID, and the remaining controls will essentially be ignored. Control ID's can often be duplicated for Label (static) text controls, provided these controls (and their contents, color, or styles) are not going to be modified at run-time. If such a Label control is to be modified, its control ID must be unique.
PowerBASIC provides a comprehensive set of statements and functions for dealing with controls. The following is a small sample of these statements and functions with a brief description of the purpose of each:
Specify which messages should be sent to a Control Callback Function | |
Return the ID of the control sending a message to your Callback Function. (Only valid inside a Callback Function). | |
Return the notification ID of the control sending a message to your Callback Function. (Only valid inside a Callback Function). | |
Returns the dialog handle sending a message to your Callback Function. (Only valid inside a Callback Function). | |
Returns the lParam& value sent to your Callback Function. (Only valid inside a Callback Function). | |
Returns the wMsg& value sent to your Callback Function. (Only valid inside a Callback Function). | |
Returns the specific notification message describing the event which occurred. (Only valid inside a Callback Function). | |
Returns the address (a pointer) to the NMHDR UDT for a notification message sent to your Callback Function. (Only valid inside a Callback Function). | |
Returns the contents of the NMHDR UDT as a dynamic string. (Only valid inside a Callback Function). | |
Returns the handle of the control which sent this message to your Callback Function. (Only valid inside a Callback Function). | |
Returns the ID number assigned to this control which sent this message to your Callback Function. (Only valid inside a Callback Function). | |
Returns the wParam& value sent to your Callback Function. (Only valid inside a Callback Function). | |
Create a control in a dialog. | |
Disable a control so that it can no longer send messages to a callback. If the control is a button, it is grayed. If it is a text box, it becomes grayed out and you can no longer edit the text contained within it. | |
Enable a control that was previously disabled. A control must be enabled in order for it to send notifications to a Callback Function. | |
Get the size of a control. | |
Get the location of a control inside of its parent dialog. | |
Retrieve the text from a control, such as a Text box or Label, etc. | |
Return a window handle for a given control. | |
Remove a control from a dialog. | |
Send a message to a control. | |
Set the keyboard focus to a given control. If the control is a button, it receives keyboard focus. If the control is a text box, the caret is placed in the text box to allow the user to edit the text. | |
Select a font to be used for a particular control. | |
Change the image on an image button or image control. Also see CONTROL SET IMAGEX. | |
Change the size of a control. | |
Change the location of a control within its parent dialog. | |
Place new text into a control. Any existing text in the control is replaced. | |
Returns the Control ID for a given control. | |
Returns the handle of a controls parent. |
For a more comprehensive list of DDT statements and functions, See the Command Summary for DDT. |
See Also