none
Bottom RIght RRS feed

  • Question

  • T want to set a small dialog box at the bottom right of the screen.

    I am using GetSystemMetrics() to get the x and y coordinates of the screen.

    But I can't figure out how to make the dialog box appear perfectly on the bottom right unless I hard-code it, which is of course a non-starter due to the differing screen sizes.

    This won't work --

    <tt>1
    2
    3
    4
    5
    6
    7
    8
    9
    </tt>
    cx=GetSystemMetrics(hwnd, SM_CXSCREEN);
    cy=GetSystemMetrics(hwnd, SM_CYSCREEN);
    
    GetWindowRect(hwnd, &rc);
    
    cx=cx-rc.right;
    cy=cy-rc.bottom
    
    SetWindowPos(hwnd, NULL, cx, cy, NULL, NULL, SWP_NOSIZE


    As I said, this will NOT work.

    I know I'm missing something simple, but I don't know what.
    Lamblion
    Saturday, May 7, 2011 10:52 PM

Answers

  • try this, In OnInitDialog, Add follow code:

    BOOL CXXDialog::OnInitDialog()
    {
    ....
     RECT rc = {0};
     if(SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0))
     {
      CRect rect;
      GetWindowRect(&rect);
      int nWidth = rect.Width();
      int nHeight = rect.Height();
      rect.bottom = rc.bottom;
      rect.top = rect.bottom - nHeight;
      rect.right = rc.right;
      rect.left = rect.right - nWidth;
      MoveWindow(rect);
     }
    ....
    }


    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
    Monday, May 9, 2011 1:03 AM

All replies

  • Well, I used SystemParametersInfo() and it seems to work. I just wonder if this is the normal way it should be done.
    Lamblion
    Saturday, May 7, 2011 11:59 PM
  • try this, In OnInitDialog, Add follow code:

    BOOL CXXDialog::OnInitDialog()
    {
    ....
     RECT rc = {0};
     if(SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0))
     {
      CRect rect;
      GetWindowRect(&rect);
      int nWidth = rect.Width();
      int nHeight = rect.Height();
      rect.bottom = rc.bottom;
      rect.top = rect.bottom - nHeight;
      rect.right = rc.right;
      rect.left = rect.right - nWidth;
      MoveWindow(rect);
     }
    ....
    }


    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
    Monday, May 9, 2011 1:03 AM