home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / WINDLG.ZIP / DLGAPP.CPP next >
Text File  |  1993-04-17  |  3KB  |  95 lines

  1. /*----------------------------------------------*/
  2. /*-- DLGAPP.CPP                               --*/
  3. /*-- template for an application with a       --*/
  4. /*-- dialog box as its main window            --*/
  5. /*----------------------------------------------*/
  6. /*-- Author:                                  --*/
  7. /*-- Kelly Schrock                            --*/
  8. /*-- 4.15.93                                  --*/
  9. /*----------------------------------------------*/
  10.  
  11. #define  INCL_PM
  12. #define  INCL_WINDIALOGS
  13. #define  INCL_WINWINDOWMGR
  14. #include <os2.h>
  15. #include <msgmap.h>
  16.  
  17. #pragma hdrstop
  18. #include "dlgapp.h"
  19.  
  20.  
  21. HAB hab;           /*-- anchor block handle --*/
  22. HMQ hmQ;           /*-- msg cue handle      --*/
  23. HWND hMainDlg;     /*-- main window handle  --*/
  24. SWCNTRL sw;        /*-- for switch list     --*/
  25. PID     pid;       /*-- process ID          --*/
  26. HSWITCH hSwitch;
  27.  
  28. /*-- global names, etc. --*/
  29. PSZ pszShortAppName = "DlgApp";
  30. PSZ pszLongAppName  = "Dialog App";
  31.  
  32. MSGMAP_BEGIN(messages)
  33.   { WM_INITDLG,         WMInitDlg     },
  34.   { WM_COMMAND,         WMCommand     },
  35. MSGMAP_END(messages, MainDlgProc, WinDefDlgProc)
  36.  
  37. CMDMAP_BEGIN(commands)
  38.   /*-- you would normally put control IDs here --*/
  39.   /*-- and the addresses of functions that     --*/
  40.   /*-- respond to them here, like this:        --*/
  41.   /*
  42.   { DID_BUTTON1,    DoButton1 },
  43.   
  44.   DoButton1 would be defined as 
  45.   #pragma argsused
  46.   MRESULT DoButton1(HM12) {
  47.     
  48.     return((MRESULT)whatever);
  49.   }
  50.   */
  51. CMDMAP_END(commands, WMCommand)
  52.  
  53. #pragma argsused
  54. INT main(INT argc, char *argv[]) {
  55.   QMSG qMsg;
  56.   ULONG ulFrameStyle;
  57.  
  58.   hab = WinInitialize(0);
  59.   hmQ = WinCreateMsgQueue (hab, 0) ;
  60.   hMainDlg = WinLoadDlg(HWND_DESKTOP,
  61.                        HWND_DESKTOP,
  62.                        (PFNWP)MainDlgProc,
  63.                        (HMODULE)0,
  64.                        IDW_MAIN,
  65.                        NULL) ;
  66.  
  67.   WinProcessDlg(hMainDlg) ;
  68.  
  69.   WinDestroyMsgQueue(hmQ) ;
  70.   WinTerminate (hab) ;
  71.   return(0);
  72. }
  73.  
  74. #pragma argsused
  75. MRESULT WMInitDlg(HM12) {
  76.   WinSetWindowULong(hWnd, QWL_USER, (ULONG)mp2) ;
  77.  
  78.   /* --- add to task switch list --- */
  79.   WinQueryWindowProcess(hWnd, &pid, NULL);
  80.   sw.hwnd = hWnd;
  81.   sw.hwndIcon = WinLoadPointer(HWND_DESKTOP, 0L, IDW_MAIN);
  82.   sw.hprog = 0L;
  83.   sw.idProcess = pid;
  84.   sw.idSession = 0;
  85.   sw.uchVisibility = SWL_VISIBLE;
  86.   sw.fbJump = SWL_JUMPABLE;
  87.   WinQueryWindowText(hWnd, sizeof(sw.szSwtitle),
  88.                            (PSZ)sw.szSwtitle);
  89.   hSwitch = WinAddSwitchEntry(&sw);
  90.  
  91.   return (MRESULT)0;
  92. }
  93.  
  94.  
  95.