home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CNRBAS.ZIP / COMMON.C < prev    next >
Text File  |  1993-01-01  |  7KB  |  161 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.     return;
  108. }
  109.  
  110. /**********************************************************************/
  111. /*------------------------------- Msg --------------------------------*/
  112. /*                                                                    */
  113. /*  DISPLAY A MESSAGE TO THE USER.                                    */
  114. /*                                                                    */
  115. /*  INPUT: a message in printf format with its parms                  */
  116. /*                                                                    */
  117. /*  1. Format the message using vsprintf.                             */
  118. /*  2. Sound a warning sound.                                         */
  119. /*  3. Display the message in a message box.                          */
  120. /*                                                                    */
  121. /*  OUTPUT: nothing                                                   */
  122. /*                                                                    */
  123. /*--------------------------------------------------------------------*/
  124. /**********************************************************************/
  125.  
  126. #define MESSAGE_SIZE 1024
  127.  
  128. VOID Msg( PSZ szFormat,... )
  129. {
  130.     PSZ     szMsg;
  131.     va_list argptr;
  132.  
  133.     if( (szMsg = (PSZ) malloc( MESSAGE_SIZE )) == NULL )
  134.     {
  135.         DosBeep( 1000, 1000 );
  136.  
  137.         return;
  138.     }
  139.  
  140.     va_start( argptr, szFormat );
  141.  
  142.     vsprintf( szMsg, szFormat, argptr );
  143.  
  144.     va_end( argptr );
  145.  
  146.     szMsg[ MESSAGE_SIZE - 1 ] = 0;
  147.  
  148.     (void) WinAlarm( HWND_DESKTOP, WA_WARNING );
  149.  
  150.     (void) WinMessageBox(  HWND_DESKTOP, HWND_DESKTOP, szMsg,
  151.                            PROGRAM_TITLE, 1, MB_OK | MB_MOVEABLE );
  152.  
  153.     free( szMsg );
  154.  
  155.     return;
  156. }
  157.  
  158. /*************************************************************************
  159.  *                     E N D     O F     S O U R C E                     *
  160.  *************************************************************************/
  161.