HWND GetNextDlgGroupItem(hwndDlg, hwndCtrl, fPrevious) | |||||
HWND hwndDlg; | /* handle of dialog box | */ | |||
HWND hwndCtrl; | /* handle of control, */ | ||||
BOOL fPrevious; | /* direction flag, */ |
The GetNextDlgGroupItem function searches for the previous (or next) control within a group of controls in a dialog box. A group of controls begins with a control with the WS_GROUP style and ends with the last control that does not contain a WS_GROUP style.
hwndDlg
Identifies the dialog box to be searched.
hwndCtrl
Identifies the control to be used as the starting point for the search.
fPrevious
Specifies how the function is to search the group of controls in the dialog box. If this parameter is TRUE, the function searches for the previous control in the group. If this parameter is FALSE, the function searches for the next control in the group.
The return value is the window handle of the previous (or next) control in the group, if the function is successful.
If the hwndCtrl parameter identifies the last control in the group and the fPrevious parameter is FALSE, the GetNextDlgGroupItem function returns the window handle of the first control in the group. If hwndCtrl identifies the first control in the group and fPrevious is TRUE, GetNextDlgGroupItem returns the window handle of the last control in the group.
The following example sets the check state of a group of radio buttons. It is assumed that the group contains only radio buttons and no other type of control:
HWND hwndStart, hwndCurrent;
case WM_COMMAND:
switch (HIWORD(lParam)) {
case BN_CLICKED:
/*
* If a radio button was clicked, clear the current
* selection and select the one that was clicked.
*/
hwndStart = GetDlgItem(hdlg, wParam);
if (LOWORD(GetWindowLong(hwndStart,
GWL_STYLE) == BS_RADIOBUTTON)) {
hwndCurrent = hwndStart;
do {
hwndCurrent = GetNextDlgGroupItem(hdlg,
hwndCurrent, TRUE);
SendMessage(hwndCurrent, BM_SETCHECK,
hwndCurrent == hwndStart, 0L);
} while (hwndCurrent != hwndStart);
}
.
. /* Process other notification codes. */
.
}