CRect x,y;
GetWindowRect(y);
TBBUTTON button;
button.idCommand=nID;
button.fsState=TBSTATE_ENABLED;
button.fsStyle=TBSTYLE_CHECK;
GetToolBarCtrl().InsertButton(index,&button);
GetToolBarCtrl().GetItemRect(CommandToIndex(nID),&x);
CString cs,cs2;
GetToolBarCtrl().ClientToScreen(&x);
cs.Format("%d",x.left);
cs2.Format("%d",y.right);
AfxMessageBox(cs+" "+cs2);
if(x.left>(1284*2))SetButtonStyle(CommandToIndex(nID),GetButtonStyle(CommandToIndex(nID))|TBBS_WRAPPED);
GetWindowRect(y)是想获得屏幕右坐标或者是工具栏右坐标。
1284是我给定的坐标值,而我通过对话框看到(按钮)GetItemRect获得后,X.RIGHT高达3000多象素。很菜的问题,谁能帮我一下啊。谢谢
GetWindowRect(y);
TBBUTTON button;
button.idCommand=nID;
button.fsState=TBSTATE_ENABLED;
button.fsStyle=TBSTYLE_CHECK;
GetToolBarCtrl().InsertButton(index,&button);
GetToolBarCtrl().GetItemRect(CommandToIndex(nID),&x);
CString cs,cs2;
GetToolBarCtrl().ClientToScreen(&x);
cs.Format("%d",x.left);
cs2.Format("%d",y.right);
AfxMessageBox(cs+" "+cs2);
if(x.left>(1284*2))SetButtonStyle(CommandToIndex(nID),GetButtonStyle(CommandToIndex(nID))|TBBS_WRAPPED);
GetWindowRect(y)是想获得屏幕右坐标或者是工具栏右坐标。
1284是我给定的坐标值,而我通过对话框看到(按钮)GetItemRect获得后,X.RIGHT高达3000多象素。很菜的问题,谁能帮我一下啊。谢谢
void DI::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CRect rect;
CEdit * wnd;
GetClientRect(rect); //获取客户区大小
wnd=(CEdit *)GetDlgItem(IDC_EDIT1); //获取其上控件的指针,是个编辑框
if(wnd)wnd->MoveWindow(rect);
}
可能还会用到这些函数获取别的控件的位置
GetWindowRect(&rect); //屏幕绝对坐标
GetClientRect(rect);
GetWindowRect(y);
*********************
CClientDC dc(this);
**********************
TBBUTTON button;
button.idCommand=nID;
button.fsState=TBSTATE_ENABLED;
button.fsStyle=TBSTYLE_CHECK;
GetToolBarCtrl().InsertButton(index,&button);
GetToolBarCtrl().GetItemRect(CommandToIndex(nID),&x);GetToolBarCtrl().ClientToScreen(&x);
*****************
dc.DPtoLP(&x);
**********************
if(x.left>1284)SetButtonStyle(CommandToIndex(nID),GetButtonStyle(CommandToIndex(nID))|TBBS_WRAPPED);