home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cnrbas.zip / COMMON.C < prev    next >
Text File  |  1992-10-10  |  7KB  |  157 lines

  1. /*********************************************************************
  2.  *                                                                   *
  3.  * MODULE NAME :  common.c               AUTHOR:  Rick Fishman       *
  4.  * DATE WRITTEN:  10-09-92                                           *
  5.  *                                                                   *
  6.  * DESCRIPTION:                                                      *
  7.  *                                                                   *
  8.  *  This module is part of CNRBASE.EXE. It contains common functions *
  9.  *  used by all modules in the EXE.                                  *
  10.  *                                                                   *
  11.  * CALLABLE FUNCTIONS:                                               *
  12.  *                                                                   *
  13.  *  VOID SetWindowTitle( HWND hwndClient, PSZ szFormat, ... );       *
  14.  *  VOID Msg           ( PSZ szFormat, ... );                        *
  15.  *                                                                   *
  16.  * HISTORY:                                                          *
  17.  *                                                                   *
  18.  *  10-09-92 - Program coded                                         *
  19.  *                                                                   *
  20.  *  Rick Fishman                                                     *
  21.  *  Code Blazers, Inc.                                               *
  22.  *  4113 Apricot                                                     *
  23.  *  Irvine, CA. 92720                                                *
  24.  *  CIS ID: 72251,750                                                *
  25.  *                                                                   *
  26.  *********************************************************************/
  27.  
  28. #pragma strings(readonly)   // used for debug version of memory mgmt routines
  29.  
  30. /*********************************************************************/
  31. /*------- Include relevant sections of the OS/2 header files --------*/
  32. /*********************************************************************/
  33.  
  34. #define  INCL_WINFRAMEMGR
  35. #define  INCL_WINSTDCNR
  36. #define  INCL_WINWINDOWMGR
  37.  
  38. /**********************************************************************/
  39. /*----------------------------- INCLUDES -----------------------------*/
  40. /**********************************************************************/
  41.  
  42. #include <os2.h>
  43. #include <stdarg.h>
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #include "cnrbase.h"
  48.  
  49. /*********************************************************************/
  50. /*------------------- APPLICATION DEFINITIONS -----------------------*/
  51. /*********************************************************************/
  52.  
  53. /**********************************************************************/
  54. /*---------------------------- STRUCTURES ----------------------------*/
  55. /**********************************************************************/
  56.  
  57. /**********************************************************************/
  58. /*----------------------- FUNCTION PROTOTYPES ------------------------*/
  59. /**********************************************************************/
  60.  
  61. /**********************************************************************/
  62. /*------------------------ GLOBAL VARIABLES --------------------------*/
  63. /**********************************************************************/
  64.  
  65. /**********************************************************************/
  66. /*-------------------------- SetWindowTitle --------------------------*/
  67. /*                                                                    */
  68. /*  SET THE FRAME WINDOW'S TITLEBAR TEXT.                             */
  69. /*                                                                    */
  70. /*  INPUT: client window handle,                                      */
  71. /*         a message in printf format with its parms                  */
  72. /*                                                                    */
  73. /*  1. Format the message using vsprintf.                             */
  74. /*  2. Set the text into the titlebar.                                */
  75. /*                                                                    */
  76. /*  OUTPUT: nothing                                                   */
  77. /*                                                                    */
  78. /*--------------------------------------------------------------------*/
  79. /**********************************************************************/
  80.  
  81. #define TITLEBAR_TEXTLEN (CCHMAXPATH + 50)
  82.  
  83. VOID SetWindowTitle( HWND hwndClient, PSZ szFormat,... )
  84. {
  85.     PSZ     szMsg;
  86.     va_list argptr;
  87.  
  88.     if( (szMsg = (PSZ) malloc( TITLEBAR_TEXTLEN )) == NULL )
  89.     {
  90.         DosBeep( 1000, 1000 );
  91.  
  92.         return;
  93.     }
  94.  
  95.     va_start( argptr, szFormat );
  96.  
  97.     vsprintf( szMsg, szFormat, argptr );
  98.  
  99.     va_end( argptr );
  100.  
  101.     szMsg[ TITLEBAR_TEXTLEN - 1 ] = 0;
  102.  
  103.     (void) WinSetWindowText( PARENT( hwndClient ), szMsg );
  104.  
  105.     free( szMsg );
  106. }
  107.  
  108. /**********************************************************************/
  109. /*------------------------------- Msg --------------------------------*/
  110. /*                                                                    */
  111. /*  DISPLAY A MESSAGE TO THE USER.                                    */
  112. /*                                                                    */
  113. /*  INPUT: a message in printf format with its parms                  */
  114. /*                                                                    */
  115. /*  1. Format the message using vsprintf.                             */
  116. /*  2. Sound a warning sound.                                         */
  117. /*  3. Display the message in a message box.                          */
  118. /*                                                                    */
  119. /*  OUTPUT: nothing                                                   */
  120. /*                                                                    */
  121. /*--------------------------------------------------------------------*/
  122. /**********************************************************************/
  123.  
  124. #define MESSAGE_SIZE 1024
  125.  
  126. VOID Msg( PSZ szFormat,... )
  127. {
  128.     PSZ     szMsg;
  129.     va_list argptr;
  130.  
  131.     if( (szMsg = (PSZ) malloc( MESSAGE_SIZE )) == NULL )
  132.     {
  133.         DosBeep( 1000, 1000 );
  134.  
  135.         return;
  136.     }
  137.  
  138.     va_start( argptr, szFormat );
  139.  
  140.     vsprintf( szMsg, szFormat, argptr );
  141.  
  142.     va_end( argptr );
  143.  
  144.     szMsg[ MESSAGE_SIZE - 1 ] = 0;
  145.  
  146.     (void) WinAlarm( HWND_DESKTOP, WA_WARNING );
  147.  
  148.     (void) WinMessageBox(  HWND_DESKTOP, HWND_DESKTOP, szMsg,
  149.                            PROGRAM_TITLE, 1, MB_OK | MB_MOVEABLE );
  150.  
  151.     free( szMsg );
  152. }
  153.  
  154. /*************************************************************************
  155.  *                     E N D     O F     S O U R C E                     *
  156.  *************************************************************************/
  157.