Thread: Splash Screen

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    26

    Splash Screen

    My program is getting rather large and it it has to itialize alot in WM_CREATE(it includes a database it has to get info from and different fonts to make). I want to create a splash screen to show while my program is loading. I already have the bitmap created but can't figure out how to acturally incorporate it into my program. Do I need to just basically double up WINMAIN and put in two showwindow commands? SHould I create a child window the very beginning of WM_CREATE? Won't that mean the the main window will be displayed in the background of the splash?

  2. #2
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    No, it's much simpler than that. You can draw right on the destop window.
    Code:
    HDC DesktopDC = GetDC(0); // get the dc of the destop window
    // use DesktopDC just like it was the dc to your own window
    Don't quote me on that... ...seriously

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    I would put that in WinMain right before CreateWindow correct?

  4. #4
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Well, if the time is being taken up during WM_CREATE then I would put it at the start of WM_CREATE.
    Don't quote me on that... ...seriously

  5. #5
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    vrek, I would recommend against Brad0407's suggestion (Sorry brad, its not personal). The reason is, programs normaly load while the splash screen is up, and that could take a while on slow computers, in which case, the desktop its self is going to be drawing over your stuff! Even if you constantly draw, there will be an annoying flickering.

    I would say create another window, it really isn't that hard, then simply close the window when its done with its timer loop and loading.

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Using the normal method of displaying bitmaps I need the size of the window I am copying to but I only want the image centered in the the middle of the screen. How can I do this?

  7. #7
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    vrek, I have to bring you down to earth on Queatrix's suggestion. You see, most splash screen tend to be poorly designed from a graphics stand point as Queatrix pointed out about mine. It can easily be drawn over and you'd never see it again. It's possible to make it update. One way is to redraw it constantly and as Queatrix said, it would cause an annoying flicker. Creating another window in essence does nothing more than my suggestion. It will draw on the screen. I'm assuming that you declared WS_POPUP. Then the second a window is moved over it, your beautiful background will go bye bye and you'll probably an unupdated window. Why? The window never handles it's WM_PAINT message because it's busy loading your fun things. How do you get around it? My vote is multithreading. Make a separate thread to handle the temporary window's messages. But the point is that if you want your splash screen to not get drawn over, neither of our previous ideas will work as they are.

    [edit]GetClientRect or GetWindowRect using 0 as your HWND[/edit]
    Don't quote me on that... ...seriously

  8. #8
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    I ended up taking the easy way out and using this: Splash Screen Class
    It does everything I wanted and worked perfectly out of the box.

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, 04:56 PM
  3. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10: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 not centered
    By BianConiglio in forum Windows Programming
    Replies: 5
    Last Post: 04-11-2004, 01:41 PM