home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / DISPATCH.H < prev    next >
Text File  |  1995-08-29  |  10KB  |  363 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Dispatch functions (crackers) to crack a Windows message and pass control
  6. //   to a member function via a pointer (pmf).
  7. //----------------------------------------------------------------------------
  8. #if !defined(OWL_DISPATCH_H)
  9. #define OWL_DISPATCH_H
  10.  
  11. #if !defined(OWL_OWLDEFS_H)
  12. # include <owl/owldefs.h>
  13. #endif
  14.  
  15. //
  16. // class GENERIC
  17. // ----- -------
  18. // generic class for casting pointer to objects and pointer to member functions
  19. //
  20. class _OWLFASTTHIS GENERIC;   // conditionally define to correct calling model
  21.  
  22. //
  23. // typedef TAnyPMF
  24. // ------- -------
  25. // generic pointer to member function
  26. //
  27. typedef void (GENERIC::*TAnyPMF)();
  28.  
  29. //
  30. // typedef TAnyDispatcher
  31. // ------- --------------
  32. // all message dispatcher functions take four parameters:
  33. // - reference to an object
  34. // - pointer to member function (signature varies according to the cracking
  35. //   that the function performs)
  36. // - wParam
  37. // - lParam
  38. //
  39. typedef int32 _OWLFUNC (*TAnyDispatcher)(GENERIC&, TAnyPMF, uint, int32);
  40.  
  41. //
  42. // LEGEND: in order to keep dispatcher names from getting too long, the
  43. //         following abbreviations are used. The names are based on the data
  44. //         sizes passed & returned, & which param they come from.
  45. //
  46. // - v   (void return)
  47. // - i   (int)
  48. // - U   (uint)
  49. // - H   (HANDLE) (requires special cracking, uint size)
  50. // - I32 (int32)
  51. // - POINT (TPoint&) (TPoint object constructed)
  52. // - POINTER (void*) (model ambient size)
  53. //
  54. // Possible future cracker encoding
  55. //  Which param:
  56. //  - 1  wParam
  57. //  - 2  lParam
  58. //    How cracked (default to no processing, size of param):
  59. //    - U Ambient size uint (squashed lParam in 16bit land)
  60. //    - L Low 16bit word
  61. //    - H high 16bit word
  62. //
  63. // Custom message crackers are named based on the message they crack
  64. //
  65.  
  66. //----------------------------------------------------------------------------
  67.  
  68. //
  69. // passes lParam as an int32 and returns an int result
  70. //
  71. int32 _OWLFUNC
  72. i_LPARAM_Dispatch(GENERIC& generic,
  73.                   int     (GENERIC::*pmf)(int32),
  74.                   uint     wParam,
  75.                   int32    lParam);
  76.  
  77. //
  78. // passes wParam as a uint and returns an int result
  79. //
  80. int32 _OWLFUNC
  81. i_WPARAM_Dispatch(GENERIC& generic,
  82.                   int     (GENERIC::*pmf)(uint),
  83.                   uint     wParam,
  84.                   int32    lParam);
  85.  
  86. //----------------------------------------------------------------------------
  87.  
  88. //
  89. // passes nothing and returns an int32 result
  90. //
  91. int32 _OWLFUNC
  92. I32_Dispatch(GENERIC& generic,
  93.              uint32  (GENERIC::*pmf)(),
  94.              uint,
  95.              int32);
  96.  
  97. //
  98. // passes lParam as an int32 and returns an int32 result
  99. //
  100. int32 _OWLFUNC
  101. I32_LPARAM_Dispatch(GENERIC& generic,
  102.                     int32   (GENERIC::*pmf)(int32),
  103.                     uint,
  104.                     int32    lParam);
  105.  
  106. //
  107. // passes lParam as a uint and returns an int32 result
  108. //
  109. int32 _OWLFUNC
  110. I32_U_Dispatch(GENERIC& generic,
  111.                int32   (GENERIC::*pmf)(uint),
  112.                uint,
  113.                int32    lParam);
  114.  
  115. //
  116. // passes wParam as a uint and lParam as an int32 and returns an int32 result
  117. //
  118. int32 _OWLFUNC
  119. I32_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  120.                            int32   (GENERIC::*pmf)(uint, int32),
  121.                            uint     wParam,
  122.                            int32    lParam);
  123.  
  124. //----------------------------------------------------------------------------
  125.  
  126. //
  127. // passes no arguments and returns a uint result
  128. //
  129. int32 _OWLFUNC
  130. U_Dispatch(GENERIC& generic,
  131.            uint    (GENERIC::*pmf)(),
  132.            uint     wParam,
  133.            int32    lParam);
  134.  
  135. //
  136. // passes lParam as an int32 and returns a uint result
  137. //
  138. int32 _OWLFUNC
  139. U_LPARAM_Dispatch(GENERIC& generic,
  140.                   uint    (GENERIC::*pmf)(int32),
  141.                   uint     wParam,
  142.                   int32    lParam);
  143.  
  144. //
  145. // passes lParam as a TPoint& and returns a uint result
  146. //
  147. int32 _OWLFUNC
  148. U_POINT_Dispatch(GENERIC& generic,
  149.                  uint    (GENERIC::*pmf)(TPoint&),
  150.                  uint,
  151.                  int32    lParam);
  152.  
  153. //
  154. // passes lParam as a void* and returns a uint result 
  155. //
  156. int32 _OWLFUNC
  157. U_POINTER_Dispatch(GENERIC& generic,
  158.                    uint    (GENERIC::*pmf)(void*),
  159.                    uint,
  160.                    int32    lParam);
  161.  
  162. //
  163. // passes lParam as a uint and returns a uint result
  164. //
  165. int32 _OWLFUNC
  166. U_U_Dispatch(GENERIC& generic,
  167.              uint    (GENERIC::*pmf)(uint),
  168.              uint,
  169.              int32    lParam);
  170.  
  171. //
  172. // passes wParam as a uint, lParam.lo as a uint, and lParam.hi as a uint
  173. //
  174. int32 _OWLFUNC
  175. U_U_U_U_Dispatch(GENERIC& generic,
  176.                  uint    (GENERIC::*pmf)(uint, uint, uint),
  177.                  uint     wParam,
  178.                  int32    lParam);
  179.  
  180. //
  181. // passes wParam as a uint and lParam as an int32 and returns a uint result
  182. //
  183. int32 _OWLFUNC
  184. U_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  185.                          uint    (GENERIC::*pmf)(uint, int32),
  186.                          uint     wParam,
  187.                          int32    lParam);
  188.  
  189. //----------------------------------------------------------------------------
  190.  
  191. //
  192. // passes nothing and always returns 0
  193. //
  194. int32 _OWLFUNC
  195. v_Dispatch(GENERIC& generic,
  196.            void    (GENERIC::*pmf)(),
  197.            uint,
  198.            int32);
  199.  
  200. //
  201. // passes lParam as an int32 and always returns 0
  202. //
  203. int32 _OWLFUNC
  204. v_LPARAM_Dispatch(GENERIC& generic,
  205.                   void    (GENERIC::*pmf)(int32),
  206.                   uint,
  207.                   int32    lParam);
  208.  
  209. //
  210. // passes lParam as a TPoint& and always returns 0
  211. //
  212. int32 _OWLFUNC
  213. v_POINT_Dispatch(GENERIC& generic,
  214.                  void    (GENERIC::*pmf)(TPoint&),
  215.                  uint,
  216.                  int32    lParam);
  217.  
  218. //
  219. // passes lParam as a void* and always returns 0
  220. //
  221. int32 _OWLFUNC
  222. v_POINTER_Dispatch(GENERIC& generic,
  223.                    void    (GENERIC::*pmf)(void*),
  224.                    uint,
  225.                    int32    lParam);
  226.  
  227. //
  228. // passes lParam as a uint and always returns 0
  229. //
  230. int32 _OWLFUNC
  231. v_U_Dispatch(GENERIC& generic,
  232.              void    (GENERIC::*pmf)(uint),
  233.              uint,
  234.              int32    lParam);
  235.  
  236. //
  237. // passes wParam as a uint and lParam as a TPoint& and always returns 0
  238. //
  239. int32 _OWLFUNC
  240. v_U_POINT_Dispatch(GENERIC& generic,
  241.                    void    (GENERIC::*pmf)(uint, TPoint&),
  242.                    uint     wParam,
  243.                    int32    lParam);
  244.  
  245. //
  246. // passes wParam as a uint and lParam as a uint and always returns 0
  247. //
  248. int32 _OWLFUNC
  249. v_U_U_Dispatch(GENERIC& generic,
  250.                void    (GENERIC::*pmf)(uint, uint),
  251.                uint     wParam,
  252.                int32    lParam);
  253.  
  254. //
  255. // passes wParam as a uint, lParam.lo as a uint, and lParam.hi as a uint and
  256. // always returns 0
  257. //
  258. int32 _OWLFUNC
  259. v_U_U_U_Dispatch(GENERIC& generic,
  260.                  void    (GENERIC::*pmf)(uint, uint, uint),
  261.                  uint     wParam,
  262.                  int32    lParam);
  263.  
  264. //
  265. // passes wParam as a uint and always returns 0
  266. //
  267. int32 _OWLFUNC
  268. v_WPARAM_Dispatch(GENERIC& generic,
  269.                   void    (GENERIC::*pmf)(uint),
  270.                   uint     wParam,
  271.                   int32    lParam);
  272.  
  273. //
  274. // passes wParam as a uint and lParam as an int32 and always returns 0
  275. //
  276. int32 _OWLFUNC
  277. v_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  278.                          void    (GENERIC::*pmf)(uint, int32),
  279.                          uint     wParam,
  280.                          int32    lParam);
  281.  
  282.  
  283. //----------------------------------------------------------------------------
  284. // Semi-custom crackers
  285.  
  286. //
  287. // passes a uint, Handle, and uint and returns an int result
  288. // 32-bit: wParam.lo, lParam,    wParam.hi
  289. // 16-bit: wParam,    lParam.lo, lParam.hi
  290. //
  291. int32 _OWLFUNC
  292. i_U_W_U_Dispatch(GENERIC& generic,
  293.                  int     (GENERIC::*pmf)(uint, uint, uint),
  294.                  uint     wParam,
  295.                  int32    lParam);
  296.  
  297. //
  298. // passes two uints and a HANDLE and always returns 0
  299. // 32-bit passes: wParam.lo, wParam.hi, lParam
  300. // 16-bit passes: wParam,    lParam.lo, lParam.hi (same as v_U_U_U)
  301. //
  302. int32 _OWLFUNC
  303. v_U_U_W_Dispatch(GENERIC& generic,
  304.                  void    (GENERIC::*pmf)(uint, uint, uint),
  305.                  uint     wParam,
  306.                  int32    lParam);
  307.  
  308. //----------------------------------------------------------------------------
  309. // message-specific crackers
  310.  
  311. //
  312. // cracker for WM_ACTIVATE
  313. // passes a uint, a bool, and an HWND and always returns 0
  314. //
  315. int32 _OWLFUNC
  316. v_Activate_Dispatch(GENERIC& generic,
  317.                     void    (GENERIC::*pmf)(uint, uint, uint),
  318.                     uint     wParam,
  319.                     int32    lParam);
  320.  
  321. //
  322. // cracker for WM_MDIACTIVATE
  323. // passes two HWNDs and always returns 0
  324. //
  325. int32 _OWLFUNC
  326. v_MdiActivate_Dispatch(GENERIC& generic,
  327.                        void    (GENERIC::*pmf)(uint, uint),
  328.                        uint     wParam,
  329.                        int32    lParam);
  330.  
  331.  
  332. //
  333. // cracker for WM_PARENTNOTIFY
  334. // passes two uints and an HWND and returns a 32bit result
  335. //
  336. int32 _OWLFUNC
  337. I32_MenuChar_Dispatch(GENERIC& generic,
  338.                       int32   (GENERIC::*pmf)(uint, uint, uint),
  339.                       uint     wParam,
  340.                       int32    lParam);
  341.  
  342. //
  343. // cracker for WM_PARENTNOTIFY
  344. // passes three uints and always returns 0
  345. //
  346. int32 _OWLFUNC
  347. v_ParentNotify_Dispatch(GENERIC& generic,
  348.                         void    (GENERIC::*pmf)(uint, uint, uint),
  349.                         uint     wParam,
  350.                         int32    lParam);
  351.  
  352.  
  353. //----------------------------------------------------------------------------
  354. // Aliases for compatibility
  355.  
  356. #define HBRUSH_HDC_W_U_Dispatch  U_U_U_U_Dispatch
  357. #define LRESULT_U_U_W_Dispatch   I32_MenuChar_Dispatch
  358. #define LRESULT_WPARAM_LPARAM_Dispatch I32_WPARAM_LPARAM_Dispatch
  359. #define v_U_B_W_Dispatch         v_Activate_Dispatch
  360. #define v_W_W_Dispatch           v_MdiActivate_Dispatch
  361.  
  362. #endif  // OWL_DISPATCH_H
  363.