Microsoft KB Archive/190350

= How to create a top-level splash screen with no TaskBar icon =

Article ID: 190350

Article Last Modified on 12/7/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 9.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q190350



SUMMARY
In Visual FoxPro, you now have the ability to make a top-level form that displays, but does not appear in the Windows taskbar. The primary reason for doing this is to create a splash screen that displays when an application starts.

You can create a top-level form that does not show in the Windows Taskbar by setting the following form properties:

Desktop = .T.  ShowWindow = 2 TitleBar = 0



MORE INFORMATION
The following code example demonstrates how to implement a splash screen. The splash form displays until just after the main form displays. The splash form then automatically releases. The SetAll method call in the Init method of the splash form, sets the MousePointer property of all objects contained in the splash form to the form's MousePointer setting. In this case, you set it to the hourglass. The splash form also contains an image control that displays a bitmap, and a label with the splash screen's caption. Code is added to the main form Init method that causes the form to take some time to display, so the splash form remains visible for a few moments. This allows you to see the effect. If the main form is complex, the form load itself provides the interval for the splash form to display. Otherwise, you could use a timer to provide the interval for the splash form to remain visible.

Steps to Demonstrate Behavior
  Run the following code from a program (.prg) file within Visual FoxPro, or add the program to a project and build it into an executable (.exe) file that you can run outside of Visual FoxPro. If you build an EXE, be sure to create a Config.fpw file with the line SCREEN=OFF in it and add it to your project. This causes the Visual FoxPro desktop to remain hidden. Sample Code ---

#DEFINE MOUSE_HOURGLASS   11       && 11 = Hourglass, from FoxPro.h      LOCAL loSplash, loMain loSplash = NEWOBJECT("splashform")  && Create splash form loSplash.SHOW                     && Show splash form loMain = NEWOBJECT('mainform')      && Create main form loMain.SHOW                       && Show main form RELEASE loSplash                    && Release splash form READ EVENTS

DEFINE CLASS splashform AS FORM ALWAYSONTOP = .T.  && Make splash form remain on top AUTOCENTER = .T.        WIDTH = 263 NAME = "Form1" * Next 3 properties required for splash form to not show in        * TaskBar SHOWWINDOW = 2 DESKTOP = .T.        TITLEBAR = 0

BORDERSTYLE = 2 MOUSEPOINTER = MOUSE_HOURGLASS

ADD OBJECT lbl1 AS LABEL WITH ; TOP = 225, ; LEFT = 10, ; CAPTION = 'My Splash Screen Caption', ; FONTSIZE = 14, ; FONTBOLD = .T., ; FONTNAME = 'Arial', ; AUTOSIZE = .T.

ADD OBJECT img1 AS IMAGE WITH ; PICTURE = HOME(2)+'Servers\Gopher\WTHOT.BMP', ; TOP = 0, ; LEFT = 0

PROCEDURE INIT * Set mouse cursor to hourglass. THIS.SETALL('MOUSEPOINTER', THIS.MOUSEPOINTER) ENDPROC ENDDEFINE

DEFINE CLASS mainform AS FORM CAPTION = "Application Main Form - Click CloseBox to Quit" SHOWWINDOW = 2 AUTOCENTER = .T.        WIDTH = 500 HEIGHT = 400 PROCEDURE INIT DECLARE integer Sleep IN WIN32API integer Sleep(2000) && This adjusts load time, time is in milliseconds. CLEAR DLLS Sleep ENDPROC

PROCEDURE QUERYUNLOAD CLEAR EVENTS ENDPROC ENDDEFINE 

Points to Note
 For the duration of the splash form's display, its icon does not appear in the Windows Taskbar or in the Windows list of running applications displayed with the ALT+TAB key combination. The main form displays behind the splash form just before the splash form is released. The AlwaysOnTop = .T. setting for the splash form ensures that it remains in front of forms displayed subsequently. The oMainform.Show is called before oSplash is released. If the splash form is released before the main form Show, the main form window does not receive the focus. The ordering used in the example avoids this behavior.  If you are using forms rather than form classes, you can still achieve the behavior described earlier. Assuming your splash form is called splashform.scx, and your main form is called mainform.scx, the following code demonstrates this: LOCAL loSplash, loMain DO FORM splashform NAME loSplash LINKED DO FORM mainform NAME loSplash LINKED RELEASE loSplash READ EVENTS </ul>

NOTE: Remember that the appropriate property settings for splashform must be made to ensure that it does not show in the Taskbar and the form remains on top.

<div class="references_section">