HWND mIDHWnd,mChildHWnd; //mIDHWnd返回的控件句柄,mChildHWnd是主窗口的子窗口句柄
HWND GetChildHWnd(HWND mHwnd, int ID) //mHwnd是主窗口句柄,ID是控件的ID
{
while (mHwnd)
{
int id=0;
id=::GetDlgCtrlID(mHwnd);
if (id==ID)
{
mIDHWnd=mHwnd;
break;
}
if (mChildHWnd=::GetWindow(mHwnd,GW_CHILD))
{
GetChildHWnd(mChildHWnd,ID);
}
mHwnd=::GetWindow(mHwnd,GW_HWNDNEXT);
}
return mIDHWnd;
}