home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / WINDLG.ZIP / MSGMAP.H < prev    next >
C/C++ Source or Header  |  1993-04-16  |  3KB  |  89 lines

  1. /*----------------------------------------------*/
  2. /*-- msgmap.h                                 --*/
  3. /*----------------------------------------------*/
  4. /*-- prototypes and macros for apps that use  --*/
  5. /*-- MSG_MAP to operate                       --*/
  6. /*----------------------------------------------*/
  7.  
  8. #if !defined(OS2_INCLUDED)
  9. #define INCL_PM
  10. #include <os2.h>
  11. #endif
  12.  
  13. #ifdef _DEBUG
  14. #define DebugBox(text, title) \
  15.      WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, \
  16.                       (PSZ)text, (PSZ)title, 0, \
  17.                       MB_OK|MB_INFORMATION|MB_MOVEABLE)
  18. #endif
  19.  
  20. #define dim(x) (sizeof(x) / sizeof(x[0]))
  21.  
  22. typedef struct {
  23.   ULONG code;
  24.   MRESULT (*Fn)(HWND, ULONG, MPARAM, MPARAM);
  25. } MSGMAP;
  26.  
  27. #define HM12 HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2
  28. #define callHM12 hWnd, msg, mp1, mp2
  29.  
  30. /*-- message map #defines --*/
  31. #define MSGMAP_BEGIN(_msgtype) \
  32.   MSGMAP _msgtype[] = {
  33.  
  34. #define MSGMAP_END(_msgtype, _wndproc, _defproc) \
  35.   { 0L, NULL }, \
  36. }; \
  37. MRESULT EXPENTRY _export _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { \
  38.   INT i; \
  39.   for(i = 0; i < dim(_msgtype); i++) { \
  40.     if(msg == _msgtype[i].code) \
  41.       return((*_msgtype[i].Fn)(hWnd, msg, mp1, mp2));\
  42.   }\
  43.   return(_defproc(hWnd, msg, mp1, mp2));\
  44. }
  45.  
  46. /*-- command map #defines --*/
  47. #define CMDMAP_BEGIN(_cmdtype) \
  48.   MSGMAP _cmdtype[] = {
  49.  
  50. #define CMDMAP_END(_cmdtype, _cmdproc) \
  51.   { 0L, NULL }, \
  52. }; \
  53. MRESULT _cmdproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { \
  54.   INT i; \
  55.   for(i = 0; i < dim(_cmdtype); i++) { \
  56.     if(SHORT1FROMMP(mp1) == _cmdtype[i].code) \
  57.       return((*_cmdtype[i].Fn)(hWnd, msg, mp1, mp2));\
  58.   }\
  59.   return((MRESULT)0L);\
  60. }
  61.  
  62. BOOL InitApp(VOID);
  63. BOOL InitHelp(VOID);
  64. VOID ExitProc(USHORT);
  65. VOID TerminateApp(VOID);
  66.  
  67. /*----------------------------------------------*/
  68. /*-- prototypes for event procs that          --*/
  69. /*-- are included with every application      --*/
  70. /*----------------------------------------------*/
  71. /*-- normal window event procs                --*/
  72. /*----------------------------------------------*/
  73. MRESULT WMCreate(HM12);
  74. MRESULT WMPaint(HM12);
  75. MRESULT WMShow(HM12);
  76. MRESULT WMMove(HM12);
  77. MRESULT WMSize(HM12);
  78. MRESULT WMEraseBkgnd(HM12);
  79. MRESULT WMClose(HM12);
  80. MRESULT WMCommand(HM12);
  81. MRESULT WMHelp(HM12);
  82. /*----------------------------------------------*/
  83. /*-- procs for apps that have dialog box main --*/
  84. /*-- windows                                  --*/
  85. /*----------------------------------------------*/
  86. MRESULT WMInitDlg(HM12);
  87. MRESULT WMControl(HM12);
  88.  
  89.