1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
struct ERGB_Data
{
RECT* pRectGroup;
WNDENUMPROC lpEnumFunc;
LPARAM lParam;
};
BOOL CALLBACK ERGB_EnumChildProc(HWND hwnd, LPARAM lParam)
{
BOOL ret = TRUE;
ERGB_Data* pData = (ERGB_Data*)lParam;
RECT rectCtrl = {0};
GetWindowRect(hwnd, &rectCtrl);
POINT pointTL = {rectCtrl.left, rectCtrl.top};
POINT pointBR = {rectCtrl.right, rectCtrl.bottom};
if( PtInRect(pData->pRectGroup, pointTL)
&& PtInRect(pData->pRectGroup, pointBR) )
{
TCHAR className[256] = {0};
GetClassName(hwnd, className, _countof(className));
DWORD styles = GetWindowLongPtr(hwnd, GWL_STYLE);
DWORD buttonType = (styles & BS_TYPEMASK);
if( (0 == _tcsicmp(className, _T("Button")))
&& ( (BS_RADIOBUTTON == buttonType)
|| (BS_AUTORADIOBUTTON == buttonType) ) )
{
ret = (*(pData->lpEnumFunc))(hwnd, pData->lParam);
}
}
return ret;
}
BOOL EnumRadioButtonsInGroup(HWND hwndGroup, WNDENUMPROC lpEnumFunc, LPARAM lParam)
{
HWND hwndDlg = GetParent(hwndGroup);
RECT rectGroup = {0};
GetWindowRect(hwndGroup, &rectGroup);
ERGB_Data data = {&rectGroup, lpEnumFunc, lParam};
return EnumChildWindows(hwndDlg, ERGB_EnumChildProc, (LPARAM)&data);
}
|