csdnzengchihe 2018-02-10 03:37 采纳率: 78%
浏览 2262
已采纳

MFC运行初始如何对话框就能出现在右边位置(而不是居中)

MFC运行初始如何对话框就能出现在右边位置(而不是居中)??

  • 写回答

1条回答 默认 最新

  • gdhk189 2018-02-10 03:51
    关注

    // 对话框靠右
    ShowWindow(SW_NORMAL);

    CRect rtDesk;

    CRect rtDlg;

    ::GetWindowRect(::GetDesktopWindow(), &rtDesk);

    GetWindowRect(&rtDlg);

    int iXpos = rtDesk.Width() - rtDlg.Width();

    int iYpos = rtDesk.Height() / 2 - rtDlg.Height() / 2;

    SetWindowPos(NULL, iXpos, iYpos, 0, 0, SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?