home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12720.ZIP / BASE.C < prev    next >
C/C++ Source or Header  |  1990-08-10  |  4KB  |  136 lines

  1. /*  base code for PM applications  */
  2.  
  3. #define INCL_WIN
  4. #define INCL_GPI
  5. #include <os2.h>
  6. #include "base.h"
  7.  
  8. MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM);
  9. MRESULT EXPENTRY AboutDlgProc  (HWND, USHORT, MPARAM, MPARAM);
  10.  
  11. HWND   hwndFrame, hwndClient;
  12.  
  13. int main (void)
  14.    {
  15.    static CHAR  szClientClass [] = "base";
  16.    static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU    |
  17.                                FCF_SIZEBORDER    | FCF_MINMAX     |
  18.                                FCF_SHELLPOSITION | FCF_TASKLIST   |
  19.                                FCF_MENU          | FCF_ACCELTABLE |
  20.                                FCF_ICON ;
  21.    HAB    hab;
  22.    HMQ    hmq;
  23.  
  24.    QMSG   qmsg;
  25.  
  26.    hab = WinInitialize (0);
  27.    hmq = WinCreateMsgQueue (hab, 0);
  28.  
  29.    WinRegisterClass (
  30.                  hab,             // Anchor Block handle
  31.                  szClientClass,   // Name of class being registered
  32.                  ClientWndProc,   // Window procedure for class
  33.                  CS_SIZEREDRAW,   // Class style
  34.                  0);              // Extra bytes to reserve
  35.  
  36.    hwndFrame = WinCreateStdWindow (
  37.                  HWND_DESKTOP,    // Parent of Window handle
  38.                  WS_VISIBLE,      // Style of frame window
  39.                  &flFrameFlags,   // Pointer to control data
  40.                  szClientClass,   // Client window class name
  41.                  NULL,            // Title bar text
  42.                  0L,              // Style of Client Window
  43.                  (HMODULE) NULL,  // Module of handle for resources
  44.                  ID_RESOURCE,     // ID of resources
  45.                  &hwndClient);    // Pointer to client window handle
  46.  
  47.    WinSetWindowText (hwndFrame, "Base Code for PM Apps");
  48.  
  49.  
  50.    while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
  51.       WinDispatchMsg (hab, &qmsg);
  52.  
  53.    WinDestroyWindow (hwndFrame);
  54.    WinDestroyMsgQueue (hmq);
  55.    WinTerminate (hab);
  56.    return 0;
  57.    }
  58.  
  59. /********************** ClientWndProc **************************/
  60.  
  61. MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  62.    {
  63.    HPS    hps;
  64.    RECTL  rcl;
  65.    HWND   hwndMinMax;
  66.  
  67.    switch (msg)
  68.      {
  69.      case WM_COMMAND:
  70.         switch (COMMANDMSG(&msg)->cmd)
  71.            {
  72.            case IDM_MENU1:
  73.  
  74.              /*
  75.               *  Get window handle of minmax buttons, and destroy it.
  76.               */
  77.  
  78.              hwndMinMax = WinWindowFromID (hwndFrame, FID_MINMAX);
  79.  
  80.              if ( hwndMinMax == NULL )
  81.                 break;
  82.  
  83.              WinDestroyWindow (hwndMinMax);
  84.  
  85.              /*
  86.               *  need to send update frame message to update the internal
  87.               *  swp structures for the frame.
  88.               */
  89.  
  90.              WinSendMsg (hwndFrame, WM_UPDATEFRAME, MPFROM2SHORT(FCF_MINMAX, 0), 0L);
  91.              break;
  92.  
  93.            case IDM_ABOUT:
  94.               WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, (HMODULE) NULL, IDD_ABOUT, NULL);
  95.               break;
  96.            }
  97.         break;
  98.      case WM_PAINT:
  99.         hps = WinBeginPaint (hwnd, NULL, NULL);
  100.         GpiErase (hps);
  101.         WinQueryWindowRect (hwnd, &rcl);
  102.         WinEndPaint (hps);
  103.         return 0;
  104.  
  105.      case WM_HELP:
  106.         WinMessageBox (HWND_DESKTOP, hwnd, "Help Message Box", "PM Base Code",
  107.                        0, MB_OK | MB_ICONASTERISK );
  108.         break;
  109.      case WM_DESTROY:
  110.         return 0;
  111.      }
  112.    return WinDefWindowProc (hwnd, msg, mp1, mp2);
  113.    }
  114.  
  115. MRESULT EXPENTRY AboutDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  116.    {
  117.  
  118.    switch (msg)
  119.      {
  120.      case WM_COMMAND:
  121.         switch (COMMANDMSG(&msg)->cmd)
  122.            {
  123.            case DID_OK:
  124.            case DID_CANCEL:
  125.               WinDismissDlg (hwnd, TRUE);
  126.               break;
  127.  
  128.            }
  129.         break;
  130.  
  131.      default:
  132.         return (WinDefDlgProc (hwnd, msg, mp1, mp2));
  133.  
  134.      }
  135.    }
  136.