Splash Screen not centered

This is a discussion on Splash Screen not centered within the Windows Programming forums, part of the Platform Specific Boards category; Hi!! I'm trying to create a splash screen and i created that window Code: hwnd = CreateWindowEx (0,szClassName, "Splash Screen",WS_OVERLAPPED,CW_USEDEFAULT, ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    161

    Splash Screen not centered

    Hi!! I'm trying to create a splash screen and i created that window

    Code:
        hwnd = CreateWindowEx (0,szClassName,
                              "Splash Screen",WS_OVERLAPPED,CW_USEDEFAULT,
                              CW_USEDEFAULT,400,200,HWND_DESKTOP,
                              NULL,hThisInstance,NULL);
    It works but

    1) The splash screen is randomly positionated and i want it centered

    2) It appears the windows title and i want only the 400x200 bmp

    any suggestion ?

    (i'm using dev cpp)
    Last edited by BianConiglio; 03-30-2004 at 11:05 AM.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    1. Use GetSystemMetrics to retrieve the screen dimensions and use that to set the x,y,nWidth and nHeight parameters of CreateWindowEx. Where you don't already know the dimensions of the bitmap use GetObject to determine them at runtime.

    2. Change the style bits to WS_POPUP.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    Code:
    hwnd = CreateWindowEx (0,szClassName,
                           "Splash screen",
                           WS_POPUP,
    (GetSystemMetrics(SM_CXFULLSCREEN) - 400) / 2,
    (GetSystemMetrics(SM_CYFULLSCREEN) - 200) / 2,
                           400,200,HWND_DESKTOP,
                           NULL,hThisInstance,NULL);
    WORKING

  4. #4
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    You may also be interested in the following to center your window in the usable space (work area) of the client area:

    GetSystemMetrics:
    http://msdn.microsoft.com/library/en...temmetrics.asp
    states for SM_CXFULLSCREEN, SM_CYFULLSCREEN: "Width and height of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value."

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    winuser.h contains a style for dialogs

    DS_CENTER
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    8

    Lightbulb

    I have made a function to center windows (#include <windows.h>):
    Code:
    void CenterWindow(HWND hwnd)
    {
      RECT rc;
      int W;
      int H;
      GetWindowRect(hwnd, &rc);
      W = rc.right - rc.left;
      H = rc.bottom - rc.top;
      int SX = GetSystemMetrics(SM_CXSCREEN);
      int SY = GetSystemMetrics(SM_CYSCREEN);
      SetWindowPos(hwnd, HWND_DESKTOP, (SX / 2) - (W / 2), (SY / 2) - (H / 2), W, H, 0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with splash screen
    By h3ro in forum Windows Programming
    Replies: 13
    Last Post: 08-31-2008, 10:16 AM
  2. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 03:56 PM
  3. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 09:18 PM
  4. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  5. Splash Screen in C++
    By Perica in forum C++ Programming
    Replies: 7
    Last Post: 10-04-2002, 05:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21