CPoint point;
GetCursorPos(&point);//獲得滑鼠點擊的位置
g_pTreeCtrl->ScreenToClient(&point);//轉化為客戶坐標
UINT uFlags;
HTREEITEM CurrentItem;
CurrentItem = g_pTreeCtrl->HitTest(point, &uFlags);//獲
如上代碼,針對CTreeCtrl使用HitTest獲得滑鼠點擊項,可是總是回傳NULL,什么原因,不得其解
uj5u.com熱心網友回復:
CPoint pt=pMsg->pt;
// convert to client
ScreenToClient(&pt);
// convert to tree
MapWindowPoints((CWnd*)&m_TreeOEM,&pt, 1); // to tree
UINT flag=TVHT_ONITEM;
HTREEITEM hItem=m_TreeOEM.HitTest(pt,&flag);
MapWindowPoints((CWnd*)&m_TreeOEM,&pt, 1); // to tree
UINT flag=TVHT_ONITEM;
uj5u.com熱心網友回復:
還是空,還有MapWindowPoints((CWnd*)&m_TreeOEM,&pt, 1)這條編譯不過,出現error C2660: 'MapWindowPoints' : function does not take 3 arguments錯誤uj5u.com熱心網友回復:
CWnd::MapWindowPointsvoid MapWindowPoints( CWnd* pwndTo, LPRECT lpRect ) const;
void MapWindowPoints( CWnd* pwndTo, LPPOINT lpPoint, UINT nCount ) const;
Parameters
pwndTo
Identifies the window to which points are converted. If this parameter is NULL, the points are converted to screen coordinates.
lpRect
Specifies the rectangle whose points are to be converted. The first version of this function is available only for Windows 3.1 and later.
lpPoint
A pointer to an array of POINT structures that contain the set of points to be converted.
nCount
Specifies the number of POINT structures in the array pointed to by lpPoint.
Remarks
Converts (maps) a set of points from the coordinate space of the CWnd to the coordinate space of another window.
uj5u.com熱心網友回復:
不知道void MapWindowPoints( CWnd* pwndTo, LPPOINT lpPoint, UINT nCount ) const與int MapWindowPoints(HWND hWndFrom, HWND hWndTo,LPPOINT lpPoints, UINT cPoints)有什么區別。專案中能夠使用后者。uj5u.com熱心網友回復:
MapWindowPointsThe MapWindowPoints function converts (maps) a set of points from a coordinate space relative to one window to a coordinate space relative to another window.
int MapWindowPoints(
HWND hWndFrom, // handle of window to be mapped from
HWND hWndTo, // handle to window to be mapped to
LPPOINT lpPoints, // pointer to array with points to map
UINT cPoints // number of structures in array
);
一樣的,這是 winApi (:: MapWindowPoints)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/88155.html
標籤:界面
上一篇:vc呼叫idl
