1. Rule of Thumb - DO NOT hard code any screen coordinates. Try to lay all child windows/ dialog items relative to the client area
2. Handle WM_SETTINGCHANGE message in the WindowProc to Recalculate all the positions.

Here is a simple example. We have a screen with a bitmap which is initialized to be at the centre of the screen.

Init()
{
....................
....................

    //
    // Create child windows
    //
    GetClientRect(m_hWnd, &rc);
    m_hBmpLogo = SHLoadImageResource ( g_hInst, IDB_GIF_BRANDLOGO );

    //
    // Find the bitmap's size
    //
    if ( m_hBmpLogo )
    {
        int nRet = GetObject( m_hBmpLogo, sizeof(m_bmp), &m_bmp );
    }

    //
    // Create Window for Bitmap - align it to the center of the screen
    //
    rcBitmap.left = (rc.right/2) - (m_bmp.bmWidth/2);
    rcBitmap.right = m_bmp.bmWidth;
    rcBitmap.top = (rc.bottom/2) - (m_bmp.bmHeight/2);
    rcBitmap.bottom = m_bmp.bmHeight;

    m_hwndBrandingLogo = CreateWindow( L"Static", szTitle,
WS_VISIBLE | SS_BITMAP, rcBitmap.left, rcBitmap.top, rcBitmap.right, rcBitmap.bottom, m_hWnd, NULL, g_hInst, (LPVOID)IDB_GIF_BRANDLOGO );


    ::SendMessage( m_hwndBrandingLogo, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)m_hBmpLogo );

................
................
}

When you switch to landscape mode, the screen orientation changes. To make sure that the bitmap window remains in the center of the screen, you will have to handle the WM_SETTINGCHANGE message in Window Proc.

            //
            // Handle Orientation/SIP change on PPC
            //
          case WM_SETTINGCHANGE:
            RealignWindows();
            break;

 

void RealignWindows()
{
    RECT rc = {0}, rcBitmap = {0};

    GetClientRect(m_hWnd, &rc);

    //
    // Realign Bitmap Window
    //
    rcBitmap.left = (rc.right/2) - (m_bmp.bmWidth/2);
    rcBitmap.right = m_bmp.bmWidth;
    rcBitmap.top = (rc.bottom/2) - (m_bmp.bmHeight/2);
    rcBitmap.bottom = m_bmp.bmHeight;

    UINT uFlags =  SWP_NOZORDER | SWP_SHOWWINDOW;

    ::SetWindowPos(
        m_hwndBrandingLogo,
        NULL,
        rcBitmap.left,
        rcBitmap.top,
        rcBitmap.right, // Wdth
        rcBitmap.bottom, // Ht
        uFlags
        );


}

Disclaimer : This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm