将窗口的置顶与取消

Posted on 2015-11-25 13:20  赤子踏浪  阅读(1844)  评论(0)    收藏  举报

 CString str;
 GetDlgItemTextW(IDC_ZD,str);//IDC_ZD为控件按钮,按钮的文字为置顶
 CRect rect;
 GetWindowRect(&rect);//获取窗口位置
 if( str == "置顶")
 {
    SetWindowPos( &wndTopMost, rect.left,rect.top,rect.right ,rect.bottom, SWP_NOMOVE||SWP_NOSIZE);  //置顶
    SetDlgItemTextW(IDC_ZD,L"取消");
 }
 else
 {
    this->SetWindowPos(&wndNoTopMost, rect.left,rect.top,rect.right ,rect.bottom, SWP_NOSIZE);
    SetDlgItemTextW(IDC_ZD,L"置顶");//取消置顶
 }

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3