Dialog items are control windows and, as such, can be manipulated using standard window-management function calls. The window handle is obtained for each dialog item by calling the WinWindowFromID function and passing the window handle for the dialog window and the window identifier for the dialog item as defined in the dialog template. Include the following Resource Compiler source-code fragment in your dialog template:
DLGTEMPLATE IDD_ABOUT BEGIN DIALOG "", IDD_ABOUT, 80, 92, 126, 130, FS_DLGBORDER, 0 BEGIN PUSHBUTTON "My Button", ITEMID_MYBUTTON, 37, 107, 56, 12 /* Other item definitions ... */ END END
Based on this code fragment, your application will receive the button-item handle by initiating the following call to WinWindowFromID:
hwndItem = WinWindowFromID(hwndDialog, ITEMID_MYBUTTON);
Applications often change the contents, enabled state, or position of dialog items at run time. For example, in a dialog window that contains a list box of file names and an Open button, the Open button should be disabled until the user selects a file from the list. To do this, define the button as disabled in the dialog resource so that it is disabled when the dialog window first is displayed. At run time, the dialog procedure receives a notification message from the list box when the user selects a file. At that time, the dialog procedure should call the WinEnableWindow function to enable the Open button.
Applications also can change the text in static dialog items and buttons by calling the WinSetWindowText function and using the window handle of a particular dialog item.