home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rwp15.zip / MISC.C < prev    next >
C/C++ Source or Header  |  1993-03-24  |  3KB  |  108 lines

  1. /* --------------------------------------------------------------------
  2.                          Miscellaneous Program
  3.                               Chapter 15
  4.  
  5.                     Real World Programming for OS/2
  6.              Copyright (c) 1993 Blain, Delimon, and English
  7. -------------------------------------------------------------------- */
  8.  
  9. #define INCL_WIN
  10. #define INCL_GPI
  11.  
  12. #include <os2.h>
  13. #include "misc.h"
  14. #include "pibtib.h"
  15. #include "drives.h"
  16. #include "filesrch.h"
  17. #include "sysinfo.h"
  18. #include "..\common\about.h"
  19.  
  20. /* Window and Dialog Functions      */
  21. MRESULT EXPENTRY ClientWndProc  (HWND,ULONG,MPARAM,MPARAM);
  22.  
  23. /* Global Variables                 */
  24. HAB      hab;
  25. HWND     hWndFrame, 
  26.          hWndClient;
  27. CHAR     szTitle[64];
  28.  
  29. int main()
  30. {
  31.     HMQ   hmq;
  32.     QMSG  qmsg;
  33.     ULONG flFrameFlags    = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
  34.                             FCF_MINMAX   | FCF_SHELLPOSITION | FCF_TASKLIST |
  35.                             FCF_ICON     | FCF_MENU;
  36.     CHAR  szClientClass[] = "CLIENT";
  37.  
  38.     hab = WinInitialize (0);
  39.     hmq = WinCreateMsgQueue (hab, 0);
  40.  
  41.     WinRegisterClass (hab, szClientClass, ClientWndProc, 0, 0);
  42.     WinLoadString (hab, 0, ID_APPNAME, sizeof(szTitle), szTitle);
  43.  
  44.     /* Create the main application window */
  45.     hWndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
  46.         &flFrameFlags, szClientClass, szTitle, 0, 0, ID_APPNAME, &hWndClient);
  47.  
  48.     while (WinGetMsg (hab, &qmsg, 0, 0, 0))
  49.         WinDispatchMsg (hab, &qmsg);
  50.  
  51.     WinDestroyWindow (hWndFrame);
  52.     WinDestroyMsgQueue (hmq);
  53.     WinTerminate (hab);
  54.     return (0);
  55. }
  56.  
  57. /* ----------------------- Window Function ----------------------- */
  58.  
  59. MRESULT EXPENTRY ClientWndProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  60. {
  61.     BOOL    bHandled = TRUE;
  62.     MRESULT mReturn  = 0;
  63.  
  64.     switch (msg)
  65.     {
  66.         case WM_ERASEBACKGROUND:
  67.             mReturn = MRFROMLONG(1L);
  68.             break;
  69.  
  70.           case WM_COMMAND:
  71.               switch (LOUSHORT(mp1))
  72.             {
  73.                 case IDM_PIBTIB:
  74.                     WinDlgBox (HWND_DESKTOP, hWnd, PIBTIBDlgProc,
  75.                             0L, IDD_PIBTIB, NULL);
  76.                     break;
  77.  
  78.                 case IDM_DRIVES:
  79.                     WinDlgBox (HWND_DESKTOP, hWnd, DrivesDlgProc,
  80.                             0L, IDD_DRIVES, NULL);
  81.                     break;
  82.  
  83.                 case IDM_FILESEARCH:
  84.                     DoFileSearch (hWnd);
  85.                     break;
  86.  
  87.                 case IDM_SYSINFO:
  88.                     WinDlgBox (HWND_DESKTOP, hWnd, SysInfoDlgProc,
  89.                             0L, IDD_SYSINFO, NULL);
  90.                     break;
  91.  
  92.                 case IDM_ABOUT:
  93.                     DisplayAbout (hWnd, szTitle);
  94.                     break;
  95.             }
  96.             break;
  97.  
  98.         default:
  99.             bHandled = FALSE;
  100.             break;
  101.     }
  102.  
  103.     if (!bHandled)
  104.         mReturn = WinDefWindowProc (hWnd,msg,mp1,mp2);
  105.  
  106.     return (mReturn);
  107. }
  108.