窗口ID,句柄,指针三者相互转换函数

//窗口ID,句柄,指针三者相互转换函数
//ID--HANDLE--HWND三者之间的互相转换

long id;
CWnd *pWnd;
HWND hWnd;

//id->句柄
hWnd = ::GetDlgItem(hParentWnd,id);

//id->指针
CWnd::GetDlgItem();

//句柄->id
id = GetWindowLong(hWnd,GWL_ID);

//句柄->指针
CWnd *pWnd=CWnd::FromHandle(hWnd);

//指针->ID
id = GetWindowLong(pWnd->GetSafeHwnd,GWL_ID);

//指针->句柄
hWnd=cWnd.GetSafeHandle() or mywnd->m_hWnd;

 

你可能感兴趣的:(VC/C++)