home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12717.ZIP / BASE.C < prev    next >
C/C++ Source or Header  |  1990-09-27  |  5KB  |  129 lines

  1. /**************************************************************************\
  2.  *                                                                        *
  3.  * Base.c                                                                 *
  4.  *                                                                        *
  5.  * This application does the following:                                   *
  6.  *                                                                        *
  7.  *      1. Changes the system menu icon to the child system icon.         *
  8.  *                                                                        *
  9.  *      2. Changes the system menu item's mnemonics to use CTRL+ key      *
  10.  *         combinations rather than the usual ALT+ key combinations.      *
  11.  *                                                                        *
  12.  * Author: Petrus Wong                                                    *
  13.  *                                                                        *
  14.  * History: created 7-10-90                                               *
  15.  *                                                                        *
  16.  **************************************************************************/
  17. #define INCL_WIN
  18. #include <os2.h>
  19. #include "base.h"
  20.  
  21. MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
  22.  
  23. int main (void)
  24.      {
  25.      static CHAR  szClientClass [] = "Base" ;
  26.      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
  27.                                  FCF_SIZEBORDER    | FCF_MINMAX  |
  28.                                  FCF_SHELLPOSITION | FCF_TASKLIST|
  29.                                  FCF_ACCELTABLE ;
  30.      HAB          hab ;
  31.      HMQ          hmq ;
  32.      HWND         hwndFrame, hwndClient, hwndSysMenu ;
  33.      QMSG         qmsg ;
  34.      HBITMAP      hbmChildSysMenu ;
  35.      ULONG        flStyle ;
  36.  
  37.      hab = WinInitialize (0) ;
  38.      hmq = WinCreateMsgQueue (hab, 0) ;
  39.  
  40.      WinRegisterClass (
  41.                     hab,                // Anchor block handle.
  42.                     szClientClass,      // Name of class being registered.
  43.                     ClientWndProc,      // Window procedure for class.
  44.                     CS_SIZEREDRAW,      // Class style.
  45.                     0) ;                // Extra bytes to reserve.
  46.  
  47.      hwndFrame = WinCreateStdWindow (
  48.                     HWND_DESKTOP,       // Parent window handle.
  49.                     0L,                 // Style of frame window.
  50.                     &flFrameFlags,      // Pointer to control data.
  51.                     szClientClass,      // Client window class name.
  52.                     NULL,               // Title bar text.
  53.                     0L,                 // Style of client window.
  54.                     NULL,               // Module handle for resources.
  55.                     IDR_DOC,            // ID of resources.
  56.                     &hwndClient) ;      // Pointer to client window handle.
  57.  
  58.      WinSendMsg (hwndFrame, WM_SETICON,
  59.                  WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
  60.                  NULL) ;
  61.  
  62.     /*
  63.      * Get the child system bitmap and then
  64.      * load in the document window's system menu.
  65.      */
  66.      hbmChildSysMenu = WinGetSysBitmap(HWND_DESKTOP, SBMP_CHILDSYSMENU);
  67.      hwndSysMenu = WinLoadMenu(hwndFrame, (HMODULE)NULL, IDM_DOCSYSMENU);
  68.  
  69.     /*
  70.      * Make it look like a normal system menu to the frame manager so
  71.      * that it gets formatted correctly.
  72.      */
  73.      flStyle = WinQueryWindowULong(hwndSysMenu, QWL_STYLE);
  74.      WinSetWindowULong(hwndSysMenu, QWL_STYLE, flStyle | MS_TITLEBUTTON);
  75.      WinSetWindowUShort(hwndSysMenu, QWS_ID, FID_SYSMENU);
  76.  
  77.     /*
  78.      * Set the bitmap to the SBMP_CHILDSYSMENU bitmap.
  79.      */
  80.      WinSendMsg(hwndSysMenu, MM_SETITEMHANDLE, (MPARAM)SC_DOCSYSMENU,
  81.             (MPARAM)hbmChildSysMenu);
  82.  
  83.      WinShowWindow(hwndFrame, TRUE);
  84.  
  85.      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
  86.           WinDispatchMsg (hab, &qmsg) ;
  87.  
  88.      WinDestroyWindow (hwndFrame) ;
  89.      WinDestroyMsgQueue (hmq) ;
  90.      WinTerminate (hab) ;
  91.      return 0 ;
  92.      }
  93.  
  94. MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  95.      {
  96.      static CHAR szText [] = "Note the system menu icon and its mnemonics have changed" ;
  97.      HPS         hps;
  98.      RECTL       rcl ;
  99.  
  100.      switch (msg)
  101.       {
  102.           case WM_CREATE:
  103.                DosBeep (261, 100) ;
  104.                DosBeep (330, 100) ;
  105.                DosBeep (392, 100) ;
  106.                DosBeep (523, 500) ;
  107.                return 0 ;
  108.  
  109.           case WM_PAINT:
  110.                hps = WinBeginPaint (hwnd, NULL, NULL) ;
  111.  
  112.                WinQueryWindowRect (hwnd, &rcl) ;
  113.  
  114.                WinDrawText (hps, -1, szText, &rcl, CLR_NEUTRAL, CLR_BACKGROUND,
  115.                             DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
  116.  
  117.                WinEndPaint (hps) ;
  118.                return 0 ;
  119.  
  120.           case WM_DESTROY:
  121.                DosBeep (523, 100) ;
  122.                DosBeep (392, 100) ;
  123.                DosBeep (330, 100) ;
  124.                DosBeep (261, 500) ;
  125.                return 0 ;
  126.           }
  127.      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
  128.      }
  129.