Category : Windows 3.X Files
Archive   : WPRO2.ZIP
Filename : EXAMINIT.C

 
Output of file : EXAMINIT.C contained in archive : WPRO2.ZIP
/* file : Examinit.c


Created: Mon Jun 19 15:21:52 1989

Description: Initialization routines for Example2
These routines are in a separate segment and may be discarded
after the first instance is initialized.

Skeleton by: WINPRO2, a product from Louis J. Cutrona, Jr.
Skeleton version 2.01

*/

#include "windows.h"

#include "Examrc.h"
#include "Examgbl.h"

/* -----------------------------------
globals referenced in this module:
char * gbl_pszStrings[ CSTRINGS ];
HCURSOR gbl_curArrow;
HCURSOR gbl_curWait;
HANDLE gbl_hAccelTable;
HBRUSH gbl_hbrBlack;
HWND gbl_hWnd;
HINST gbl_hInst;
-------------------------------------- */

/* I N I T S T R I N G S */ /* Get all text strings from the resource file */
BOOL far InitStrings( hInstance )
HANDLE hInstance;
{
HANDLE hStrings;
char * pch;
int cchRemaining;
int i;
int cch;

hStrings = LocalAlloc( LMEM_FIXED, (WORD) (cchRemaining = CCHSTRINGS) );
if( !( pch = (char *) hStrings ) )
return( FALSE );
for( i = IDS_FIRSTSTRING; i < IDS_FIRSTSTRING + CSTRINGS; i++ )
{
cch = 1 + LoadString( hInstance, i, (LPSTR) pch, cchRemaining );
gbl_pszStrings[ i - IDS_FIRSTSTRING ] = pch;
pch += cch;
cchRemaining -= cch;
}
LocalReAlloc( hStrings, (WORD) (CCHSTRINGS - cchRemaining), LMEM_FIXED );
}


/* E X A M P L E 2 R E G I S T E R */ /* Register the window classes we need */
BOOL far Example2Register( hInstance )
HANDLE hInstance;
{
WNDCLASS Class;
BOOL b;

/* Set up for and register the window class */
Class.hCursor = gbl_curArrow = LoadCursor( NULL, IDC_ARROW );
Class.hIcon = LoadIcon( hInstance, (LPSTR) Example2 );
Class.lpszMenuName = (LPSTR) Example2 ;
Class.lpszClassName = (LPSTR) gbl_psz( IDS_NAME );
Class.hbrBackground = NULL;
Class.hInstance = hInstance;
Class.style = CS_VREDRAW | CS_HREDRAW;
Class.lpfnWndProc = Example2WndProc;
Class.cbClsExtra = 0;
Class.cbWndExtra = 0;

b = RegisterClass( (LPWNDCLASS) &Class );
if( b )
{
gbl_hAccelTable = LoadAccelerators(hInstance, (LPSTR) Example2 );
}
return b;
}


/* E X A M P L E 2 I N I T */ /* Procedure called when the application is loaded */
BOOL far Example2Init( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
HANDLE hInstance;
HANDLE hPrevInstance;
LPSTR lpszCmdLine;
int cmdShow;
{
HMENU hMenu;

/* Load strings from string table */
InitStrings( hInstance );

if( hPrevInstance == NULL )
{
if( ! Example2Register( hInstance ) )
return( FALSE );
else
{
/* set up some default brushes */
gbl_hbrBlack = (HBRUSH)GetStockObject( BLACK_BRUSH );

gbl_curWait = LoadCursor( NULL, IDC_WAIT );
gbl_curArrow = LoadCursor( NULL, IDC_ARROW );
}
}
else
{
GetInstanceData( hPrevInstance, (PSTR)&gbl_hbrBlack, sizeof(gbl_hbrBlack) );
GetInstanceData( hPrevInstance, (PSTR)&gbl_hAccelTable, sizeof(gbl_hAccelTable) );

GetInstanceData( hPrevInstance, (PSTR)&gbl_curWait, sizeof(HCURSOR));
GetInstanceData( hPrevInstance, (PSTR)&gbl_curArrow, sizeof(HCURSOR));
}

gbl_hWnd = CreateWindow(
(LPSTR) gbl_psz( IDS_NAME ),
(LPSTR) gbl_psz( IDS_TITLE ),
WS_OVERLAPPEDWINDOW | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
CW_USEDEFAULT,
cmdShow, /* first overlapped window created by Example2 */
CW_USEDEFAULT,
0,
(HWND) NULL,
(HMENU) NULL,
(HANDLE) hInstance,
(LPSTR) NULL
);

gbl_hInst = hInstance;

#ifdef NO_MENU_DEFINED
/* Add separator and "About" to system menu */
hMenu = GetSystemMenu( gbl_hWnd, FALSE );
ChangeMenu( hMenu, 0, NULL, 999, MF_APPEND | MF_SEPARATOR );
ChangeMenu( hMenu, 0, (LPSTR) gbl_psz( IDS_ABOUT ), ABOUT, MF_APPEND | MF_STRING );
#endif

ShowWindow( gbl_hWnd, cmdShow );
UpdateWindow( gbl_hWnd );

return( TRUE );
}



/* E N D O F E X A M I N I T . C */


  3 Responses to “Category : Windows 3.X Files
Archive   : WPRO2.ZIP
Filename : EXAMINIT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/