Category : Files from Magazines
Archive   : JUN92.ZIP
Filename : 3N06043A

 
Output of file : 3N06043A contained in archive : JUN92.ZIP
/* Listing 3 */

/*****************************************************
File Name: C_W_DEMO.C
Expanded Name: Center Window Demo
Description: Center Window Demo Program
Program List: C_W_DEMO.C CNTR_WND.C
Global Function List: CenterWindow
Static Function List: CenterWindowDialog
Local Macro List:
Global Data:
Static Data: _hInstance _hWnd
Portability: MS Windows, Any memory model,
Any windows compatable C Compiler
******************************************************/
/* MS Windows */
#include

/* Types and Prototypes */
#include

/* Own */
#include

/* Prototypes of functions called only by windows. */
LONG FAR PASCAL CenterWindowDemoProc(
HWND hWnd, WORD iMessage, WORD wParam,
LONG lParam );

BOOL FAR PASCAL CenterWindowDialogProc(
HWND hDlg, WORD iMessage, WORD wParam,
LONG lParam );

/* static data */
static HWND _hWnd;
static HANDLE _hInstance;

/*****************************************************
Name: WinMain
Description: Program entry point.
*****************************************************/
int PASCAL WinMain( HANDLE hInstance,
HANDLE hPrevInstance, LPSTR lpszCmdParam,
int nCmdShow )
{

MSG Message;
WNDCLASS WndClass;
char *CenterWindowDemoName = "CenterWindowDemo";

_hInstance = hInstance;

if ( !hPrevInstance )
{
WndClass.style = CS_HREDRAW | CS_VREDRAW;
WndClass.lpfnWndProc = CenterWindowDemoProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = _hInstance;
WndClass.hIcon = LoadIcon( _hInstance,
CenterWindowDemoName );
WndClass.hCursor =
LoadCursor( NULL, IDC_ARROW );
WndClass.hbrBackground = COLOR_WINDOW + 1;
WndClass.lpszMenuName =
CenterWindowDemoName;
WndClass.lpszClassName =
CenterWindowDemoName;
if ( RegisterClass( &WndClass ) == FALSE )
{
MessageBeep( 0 );
return ( FALSE );
}
}

/* Create the window with default pos. and size */
_hWnd = CreateWindow( CenterWindowDemoName,
"Center Window Demo",
WS_OVERLAPPEDWINDOW | WS_VISIBLE |
WS_VSCROLL | WS_HSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, _hInstance, NULL );

if ( _hWnd == NULL )
{
/* If window could not be created, return. */
MessageBeep( 0 );
return ( FALSE );
}

ShowWindow( _hWnd, nCmdShow );
UpdateWindow( _hWnd );

while ( GetMessage( &Message, NULL, NULL, NULL ) )
{
TranslateMessage( &Message );
DispatchMessage( &Message );
}

return ( (int)Message.wParam );

} /* function WinMain */


/*****************************************************
Name: CenterWindowDemoProc
Description: Window Procedure for center window demo
program. This is called by Windows only.
*****************************************************/
long FAR PASCAL CenterWindowDemoProc( HWND hWnd,
WORD iMessage, WORD wParam, LONG lParam )
{
switch ( iMessage )
{
case WM_CREATE:
{
CenterWindow( NULL, hWnd, FALSE );
break;
}
case WM_COMMAND:
{
switch ( wParam )
{
case IDM_CENTER_MAIN:
{
CenterWindow( NULL, hWnd,
TRUE );
break;
}
case IDM_DIALOG:
{
FARPROC lpfCenterWindowDialog;

lpfCenterWindowDialog =
MakeProcInstance(
CenterWindowDialogProc,
_hInstance );
DialogBox( _hInstance,
"CenterWindowDialog",
hWnd,
lpfCenterWindowDialog );
FreeProcInstance(
lpfCenterWindowDialog );
break;
}
case IDM_EXIT:
{
SendMessage( hWnd,
WM_CLOSE, 0, 0L );
break;
}
default:
{
break;
}
}
break;
}
case WM_DESTROY:
{
PostQuitMessage( 0 );
break;
}
default:
{
return ( DefWindowProc( hWnd, iMessage,
wParam, lParam ) );
}
} /* switch iMessage */

return ( FALSE );

} /* function CenterWindowDemoProc */


/*****************************************************
Name: CenterWindow
Description: Dialog Procedure for center window demo.
Processes commands to center the dialog
box within the parent window or within
the desktop. This function is called
by Windows only.
*****************************************************/
BOOL FAR PASCAL CenterWindowDialogProc( HWND hDlg,
WORD Message, WORD wParam, LONG lParam )
{

switch ( Message )
{
case WM_INITDIALOG:
{
CenterWindow( _hWnd, hDlg, FALSE );
return ( TRUE );
}
case WM_COMMAND:
{
switch ( wParam )
{
default:
{
break;
}
case IDCANCEL:
case IDOK:
{
EndDialog( hDlg, FALSE );
return ( TRUE );
}
case IDD_PARENT:
{
CenterWindow( _hWnd, hDlg,
TRUE );
break;
}
case IDD_DESKTOP:
{
CenterWindow( NULL, hDlg,
TRUE );
break;
}
} /* switch wParam */
break;
}
default:
{
break;
}
} /* switch message */

return ( FALSE );

} /* function CenterWindowDialogProc */


  3 Responses to “Category : Files from Magazines
Archive   : JUN92.ZIP
Filename : 3N06043A

  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/