home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
CNRBAS.ZIP
/
COMMON.C
< prev
next >
Wrap
Text File
|
1993-01-01
|
7KB
|
161 lines
/*********************************************************************
* *
* MODULE NAME : common.c AUTHOR: Rick Fishman *
* DATE WRITTEN: 10-09-92 *
* *
* DESCRIPTION: *
* *
* This module is part of CNRBASE.EXE. It contains common functions *
* used by all modules in the EXE. *
* *
* CALLABLE FUNCTIONS: *
* *
* VOID SetWindowTitle( HWND hwndClient, PSZ szFormat, ... ); *
* VOID Msg ( PSZ szFormat, ... ); *
* *
* HISTORY: *
* *
* 10-09-92 - Program coded *
* *
* Rick Fishman *
* Code Blazers, Inc. *
* 4113 Apricot *
* Irvine, CA. 92720 *
* CIS ID: 72251,750 *
* *
*********************************************************************/
#pragma strings(readonly) // used for debug version of memory mgmt routines
/*********************************************************************/
/*------- Include relevant sections of the OS/2 header files --------*/
/*********************************************************************/
#define INCL_WINFRAMEMGR
#define INCL_WINSTDCNR
#define INCL_WINWINDOWMGR
/**********************************************************************/
/*----------------------------- INCLUDES -----------------------------*/
/**********************************************************************/
#include <os2.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cnrbase.h"
/*********************************************************************/
/*------------------- APPLICATION DEFINITIONS -----------------------*/
/*********************************************************************/
/**********************************************************************/
/*---------------------------- STRUCTURES ----------------------------*/
/**********************************************************************/
/**********************************************************************/
/*----------------------- FUNCTION PROTOTYPES ------------------------*/
/**********************************************************************/
/**********************************************************************/
/*------------------------ GLOBAL VARIABLES --------------------------*/
/**********************************************************************/
/**********************************************************************/
/*-------------------------- SetWindowTitle --------------------------*/
/* */
/* SET THE FRAME WINDOW'S TITLEBAR TEXT. */
/* */
/* INPUT: client window handle, */
/* a message in printf format with its parms */
/* */
/* 1. Format the message using vsprintf. */
/* 2. Set the text into the titlebar. */
/* */
/* OUTPUT: nothing */
/* */
/*--------------------------------------------------------------------*/
/**********************************************************************/
#define TITLEBAR_TEXTLEN (CCHMAXPATH + 50)
VOID SetWindowTitle( HWND hwndClient, PSZ szFormat,... )
{
PSZ szMsg;
va_list argptr;
if( (szMsg = (PSZ) malloc( TITLEBAR_TEXTLEN )) == NULL )
{
DosBeep( 1000, 1000 );
return;
}
va_start( argptr, szFormat );
vsprintf( szMsg, szFormat, argptr );
va_end( argptr );
szMsg[ TITLEBAR_TEXTLEN - 1 ] = 0;
(void) WinSetWindowText( PARENT( hwndClient ), szMsg );
free( szMsg );
return;
}
/**********************************************************************/
/*------------------------------- Msg --------------------------------*/
/* */
/* DISPLAY A MESSAGE TO THE USER. */
/* */
/* INPUT: a message in printf format with its parms */
/* */
/* 1. Format the message using vsprintf. */
/* 2. Sound a warning sound. */
/* 3. Display the message in a message box. */
/* */
/* OUTPUT: nothing */
/* */
/*--------------------------------------------------------------------*/
/**********************************************************************/
#define MESSAGE_SIZE 1024
VOID Msg( PSZ szFormat,... )
{
PSZ szMsg;
va_list argptr;
if( (szMsg = (PSZ) malloc( MESSAGE_SIZE )) == NULL )
{
DosBeep( 1000, 1000 );
return;
}
va_start( argptr, szFormat );
vsprintf( szMsg, szFormat, argptr );
va_end( argptr );
szMsg[ MESSAGE_SIZE - 1 ] = 0;
(void) WinAlarm( HWND_DESKTOP, WA_WARNING );
(void) WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, szMsg,
PROGRAM_TITLE, 1, MB_OK | MB_MOVEABLE );
free( szMsg );
return;
}
/*************************************************************************
* E N D O F S O U R C E *
*************************************************************************/