Problem:
This demo shows how to create a splash screen window for your Dialog System application.
Resolution:
INTRODUCTION
==========
This demo shows how to create a splash screen window for your Dialog System application. A 16-color bitmap was used on a dialog box as the splash screen. The bitmap is stored in a resource dll (bmp.dll). See the Dialog System Help, Contents tab, "Bitmaps, Icons and Mouse Pointers", "Adding Your Own Bitmaps" section to see how to do this. 256-color bitmaps cannot be placed within a dll and used by Dialog System. However, you can load the bitmap into Microsoft Paint and do a "Save As", where you can change the "Save as type" to 16-color bitmap. Dialog System is able to use the bitmap by way of the resource dll through the use of a bitmap/icon sidefile. This is a text file that you can create and specify in the Dialog System Options menu, Resource files...,Icon/Bitmap file. Be sure not to specify a drive letter or path here (only the file name) or you may have a problem when you move the application and DS looks in the wrong place for it. See the DS Help, Contents tab,"Bitmaps, Icons and Mouse Pointers", "Bitmap Side File" on how to create it. Resource dlls can be handy when you have many bitmaps and icons that you want to keep in a single file. The alternative is to leave the bitmap on the hard drive as a separate file (and set the MFDSSW=/B1 environment variable if it's 256-color).
The bitmap is placed on a dialog box that is sized just a little bit bigger than the bitmap itself. This allows you to easily select the window to get at the properties. You'll want to set the options in the properties for the dialog box so that there is not titlebar, system menu, or relative positioning, and the type can be set to modeless. Take into account that your application may be running on machines with different resolutions, so you should probably use a fairly small bitmap and dialog box (for lower resolutions).
The trick to make this work is for you to specify the splashscreen (dialog box) as the first window by selecting the Dialog System Screenset menu, First Window..., and choosing the dialog box.
To center the splash screen, I use a subprogram (CenterWin.cbl) and the Dialog Sytem "dsmovsz" extension (see the DS Help, Contents tab, Dialog System Extensions, Dsmovsz on how to use it). The Program-Initialize section in DSSplash.cbl has calls to PANELS2 in order to get the desktop resolution and convert pixels to panels2 coordinates (because dsmovsz uses panels2 coordinates). The centerWin.cbl subprogram calculates the centered position for a window. The CALLOUT function is used in the Global Dialog SCREENSET-INITIALIZED event to call dsmovsz and the centerWin subprogram. There is a problem if you enable Dynamic Window Sizing (CALLOUT to dsrtcfg with a config-flag value of 9 and config-value of 4). Under different resolutions, the splash screen dialog box can get resized and the bitmap may not appear in whole. To counter this problem, you can CALLOUT to dsmovsz with the "siza" function set to resize the dialog to the original design-time size. You can check the design-time size by selecting the dialog box in the Dialog System screen painter and noticing the dimension numbers at the far right lower corner across from the Type and Style dropdowns.
To unshow the after a specific amount of time, you can set a flag (WHAT-TO-DO field set to "S" in this example) in the WINDOW-CREATED event of the dialog box. You then do a RETC back to the COBOL program which checks the flag and calls the Win32 Sleep function. When the Sleep function returns, you can use the UNSHOW-WINDOW DS function to unshow the splash screen and set focus on your application's main window.
Another method of unshowing the splash screen is to use the DS TIMEOUT function, but you can encounter a problem where the window won't unshow if the user is constantly clicking on it since the window is handling click events.
If you want to run this app from the release directory outside of NetExpress, be sure to copy the bmp.icn (bitmap side file) and bmp.dll (bitmap resource file) there. Dialog System Extensions such as dsmovsz can be linked with your application executable by specifying dsmovsz.obj in the build settings, link options advanced category, link with these OBJs.
SOURCE FILES:
==========
Program Files Description
------------------------ -----------------------------------------------------------
DSSplashscreen.app Net Express project
DSSplash.cbl Main COBOL source code
DSSplash.cpb Dialog System datablock copyfile center
Win.cbl COBOL subprogram source for centering a window
DSSplash.gs Dialog System screenset
bmp.icn Dialog System bitmap sidefile
bmp.dll Resource DLL containing bitmap
bmp.rc Resource definition file
bmp.res Output from resource compiler
cobolrocks.bmp Splash screen bitmap
cobolrocks16.bmp Splash screen bitmap (16-color)
OPERATION:
========
Build and run the project. A splash screen with the "Micro Focus COBOL Rocks" bitmap will appear for a few seconds and then unshow and set focus to the main application window.
==========================================================
Keywords: demonstration, sample, example, demo, Dialog System, dssplash.zip
demo.ex
demo.ne