在MFC中沒找到,難道靠目測,靠網格,呵呵。
原來MFC所有控件都是窗口,都有CRect
在對話框的OnInit()里添加如下代碼:
CRect rect;
m_listCtrl.GetWindowRect(rect); // ListCtrl矩形
// m_listCtrl.GetClientRect(rect); // 對話框客戶區矩形
ScreenToClient(rect); // 屏幕坐標轉換為客戶區坐標
// 取得原來的矩形,在此基礎上修改。這里我直接設置個坐標
rect.top = 10;
rect.left = 10;
rect.right = rect.left + 100;
rect.bottom = rect.top + 100;
m_listCtrl.MoveWindow(rect);
// m_listCtrl.SetWindowPos(this,10,10,150,110,SWP_NOZORDER);
m_listCtrl.GetWindowRect(rect); // ListCtrl矩形
// m_listCtrl.GetClientRect(rect); // 對話框客戶區矩形
ScreenToClient(rect); // 屏幕坐標轉換為客戶區坐標
// 取得原來的矩形,在此基礎上修改。這里我直接設置個坐標
rect.top = 10;
rect.left = 10;
rect.right = rect.left + 100;
rect.bottom = rect.top + 100;
m_listCtrl.MoveWindow(rect);
// m_listCtrl.SetWindowPos(this,10,10,150,110,SWP_NOZORDER);
C++很麻煩,但是太強大了,直接使用Windows API
不知道我理解得到位不到位。
url: http://greatverve.cnblogs.com/archive/2012/11/17/mfc-top-left-width-height.html