Advertisement
Kitomas

most stuff from kit_w32 as of 2024-02-18

Feb 16th, 2024
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 86.63 KB | None | 0 0
  1. /* I'M TOO TIED TO DO SEPARATE SOURCE FILES THIS WEEK,
  2. SO I'LL BE SHOWING MOST OF THEM IN ONE BIG PASTE!!!! */
  3.  
  4.  
  5. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\_kit_globals.hpp */
  6.  
  7. #ifndef __KIT_GLOBALS_HPP
  8. #define __KIT_GLOBALS_HPP
  9.  
  10. #include <Windows.h>
  11.  
  12. #if defined(_DEBUG)
  13. #include <stdio.h>
  14. #define loghere printf("line %4i: (%s)\n",__LINE__,__FILE__);
  15. #else
  16. #define loghere ; /* do {} while(0); */
  17. #endif /* _DEBUG */
  18.  
  19. //used for Window and Bitmap
  20. #define KIT_INITIAL_STRETCH_MODE COLORONCOLOR
  21.  
  22.  
  23. //class type ID numbers
  24. #define KIT_CONTAINS_OPAQUE (0x80000000)
  25. #define KIT_CLASSTYPE_NULL        (0)
  26. #define KIT_CLASSTYPE_MUTEXSIMPLE (1 | KIT_CONTAINS_OPAQUE)
  27. #define KIT_CLASSTYPE_WINDOW      (2 | KIT_CONTAINS_OPAQUE)
  28. #define KIT_CLASSTYPE_BITMAP      (3 | KIT_CONTAINS_OPAQUE)
  29.  
  30.  
  31. namespace kit {
  32.  
  33.  
  34.  
  35.  
  36. /*++++++++++*/
  37. /*+kit_main+*/
  38. /*++++++++++*/
  39.  
  40. namespace w32 {
  41.  
  42.  
  43.  
  44. extern HINSTANCE hThisInst;
  45. extern HINSTANCE hPrevInst;
  46. extern LPSTR     lpszArg;
  47. extern int       nCmdShow;
  48.  
  49. extern LARGE_INTEGER ticksPerSecond; //used in time::getTicksPerSecond()
  50.  
  51.  
  52.  
  53. };
  54.  
  55. /*++++++++++*/
  56. /*+kit_main+*/
  57. /*++++++++++*/
  58.  
  59.  
  60.  
  61.  
  62. };
  63.  
  64.  
  65. #endif /* __KIT_GLOBALS_HPP */
  66.  
  67.  
  68. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\_kit_globals.hpp */
  69.  
  70.  
  71.  
  72.  
  73. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Window\_kit_Window.hpp */
  74.  
  75. #ifndef _KIT_WINDOW__KIT_WINDOW_HPP
  76. #define _KIT_WINDOW__KIT_WINDOW_HPP
  77.  
  78. #include "../_kit_globals.hpp"
  79.  
  80. #define KIT_LOCK_SPINCOUNT (2048)
  81.  
  82.  
  83. namespace kit {
  84.  
  85.  
  86.  
  87.  
  88. static inline shape::rect ConvertToKitRect(RECT& rectIn){
  89.   shape::rect rectOut;
  90.   rectOut.x = rectIn.left;
  91.   rectOut.y = rectIn.top;
  92.   rectOut.w = rectIn.right  - rectIn.left;
  93.   rectOut.h = rectIn.bottom - rectIn.top;
  94.   return rectOut;
  95. }
  96.  
  97.  
  98.  
  99. static inline RECT ConvertFromKitRect(shape::rect& rectIn){
  100.   RECT rectOut;
  101.   rectOut.left   = rectIn.x;
  102.   rectOut.top    = rectIn.y;
  103.   rectOut.right  = rectIn.x + rectIn.w;
  104.   rectOut.bottom = rectIn.y + rectIn.h;
  105.   return rectOut;
  106. }
  107.  
  108.  
  109.  
  110.  
  111. //assumes window is without a menu
  112. static inline shape::point CalculateWindowSize(u32 innerWidth, u32 innerHeight,
  113.                                                u32 flags,      u32 flagsEx)
  114. {
  115.   RECT winSize;
  116.   winSize.left   = 0;
  117.   winSize.top    = 0;
  118.   winSize.right  = innerWidth;
  119.   winSize.bottom = innerHeight;
  120.   AdjustWindowRectEx(&winSize, flags, false, flagsEx);
  121.  
  122.   shape::point winSizeAdjusted;
  123.   winSizeAdjusted.x = winSize.right  - winSize.left;
  124.   winSizeAdjusted.y = winSize.bottom - winSize.top;
  125.   return winSizeAdjusted;
  126. }
  127.  
  128.  
  129.  
  130.  
  131. /*++++++++++++*/
  132. /*+kit_Window+*/
  133. /*++++++++++++*/
  134.  
  135. namespace w32 {
  136.   extern size_t      winCount; //number of existing kit::Window instances
  137.   extern const char  winClassName[];
  138.   extern WNDCLASSEXA winClass;
  139.   extern ATOM        winClassAtom;
  140. };
  141.  
  142.  
  143.  
  144. struct _WindowOpaque { //intentionally excluded from w32 namespace
  145.   CRITICAL_SECTION lock;
  146.  
  147.   HWND        winHandle;
  148.   shape::rect winRect; //contains both window position, and window size
  149.   u32         winIndex;
  150.   bool        winResizable;
  151.   bool        winDestroyed;
  152.  
  153.   BITMAPINFO   canvasInfo;
  154.   HBITMAP      canvas;
  155.   color::ARGB* canvasPixels;
  156.   shape::point canvasSize;
  157.   HDC          canvasDevCtx;
  158.   s32          canvasStretchMode;
  159.   bool         canvasStretch; //if false, canvas is resized alongside window
  160. };
  161.  
  162. /*------------*/
  163. /*-kit_Window-*/
  164. /*------------*/
  165.  
  166.  
  167.  
  168.  
  169. /*++++++++++++++++*/
  170. /*+kit_WindowProc+*/
  171. /*++++++++++++++++*/
  172.  
  173. namespace w32 {
  174.  
  175.  
  176.  
  177. extern LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
  178.  
  179.  
  180.  
  181. };
  182.  
  183. /*----------------*/
  184. /*-kit_WindowProc-*/
  185. /*----------------*/
  186.  
  187.  
  188.  
  189.  
  190. };
  191.  
  192. #endif /* _KIT_WINDOW__KIT_WINDOW_HPP */
  193.  
  194.  
  195. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Window\_kit_Window.hpp */
  196.  
  197.  
  198.  
  199.  
  200. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Bitmap\_kit_Bitmap.hpp */
  201.  
  202. #ifndef _KIT_BITMAP__KIT_BITMAP_HPP
  203. #define _KIT_BITMAP__KIT_BITMAP_HPP
  204.  
  205. #include "../_kit_globals.hpp"
  206.  
  207.  
  208. namespace kit {
  209.  
  210.  
  211.  
  212.  
  213. /*++++++++++++*/
  214. /*+kit_Bitmap+*/
  215. /*++++++++++++*/
  216.  
  217. struct _BitmapOpaque {
  218.   BITMAPINFO   bmpInfo;
  219.   HBITMAP      bmp;
  220.   color::ARGB* bmpPixels;
  221.   shape::point bmpSize;
  222.   HDC          bmpDevCtx;
  223.   s32          bmpStretchMode;
  224.   bool         bmpDirectAccess; //false for
  225. };
  226.  
  227. /*------------*/
  228. /*-kit_Bitmap-*/
  229. /*------------*/
  230.  
  231.  
  232.  
  233.  
  234. };
  235.  
  236. #endif /* _KIT_BITMAP__KIT_BITMAP_HPP */
  237.  
  238.  
  239. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Bitmap\_kit_Bitmap.hpp */
  240.  
  241.  
  242.  
  243.  
  244. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\video.hpp */
  245.  
  246. #ifndef _KIT_VIDEO_HPP
  247. #define _KIT_VIDEO_HPP
  248.  
  249. #include "commondef.hpp"
  250. #include "_video/misc.hpp"
  251. #include "_video/Window.hpp"
  252. #include "_video/Bitmap.hpp"
  253.  
  254.  
  255. #endif /* _KIT_VIDEO_HPP */
  256.  
  257.  
  258. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\video.hpp */
  259.  
  260.  
  261.  
  262.  
  263. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\misc.hpp */
  264.  
  265. #ifndef _KIT_MISC_HPP
  266. #define _KIT_MISC_HPP
  267.  
  268. #include "commondef.hpp"
  269. #include "_misc/Mutex.hpp"
  270. #include "_misc/time.hpp"
  271.  
  272. #endif /* _KIT_MISC_HPP */
  273.  
  274.  
  275. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\misc.hpp */
  276.  
  277.  
  278.  
  279.  
  280. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\commondef.hpp */
  281.  
  282. #ifndef _KIT_COMMONDEF_HPP
  283. #define _KIT_COMMONDEF_HPP
  284.  
  285. namespace kit {
  286.  
  287.  
  288.  
  289.  
  290. #ifndef   MIN
  291. #define   MIN(a,b) ( ((a)<(b)) ? (a) : (b) )
  292. #endif /* MIN(a,b) */
  293.  
  294. #ifndef   MAX
  295. #define   MAX(a,b) ( ((a)>(b)) ? (a) : (b) )
  296. #endif /* MAX(a,b) */
  297.  
  298. #ifndef   CLAMP
  299. #define   CLAMP(n, mn, mx) MIN(MAX(n,mn),mx)
  300. #endif /* CLAMP(n, mn, mx) */
  301.  
  302.  
  303.  
  304. // integer bounds
  305. #define KIT_U8_MAX  (0xff)
  306. #define KIT_U16_MAX (0xffff)
  307. #define KIT_U32_MAX (0xffffffff)
  308. #define KIT_U64_MAX (0xffffffffffffffff)
  309.  //
  310. #define KIT_S8_MIN  (-0x80)
  311. #define KIT_S8_MAX  ( 0x7f)
  312. #define KIT_S16_MIN (-0x8000)
  313. #define KIT_S16_MAX ( 0x7fff)
  314. #define KIT_S32_MIN (-0x80000000)
  315. #define KIT_S32_MAX ( 0x7fffffff)
  316. #define KIT_S64_MIN (-0x8000000000000000)
  317. #define KIT_S64_MAX ( 0x7fffffffffffffff)
  318.  
  319.  
  320. // most significant bits/Bytes
  321. #define KIT_MSb_8  (0x80)
  322. #define KIT_MSb_16 (0x8000)
  323. #define KIT_MSb_32 (0x80000000)
  324. #define KIT_MSb_64 (0x8000000000000000)
  325.  //
  326. #define KIT_MSB_8  (0xff)
  327. #define KIT_MSB_16 (0xff00)
  328. #define KIT_MSB_32 (0xff000000)
  329. #define KIT_MSB_64 (0xff00000000000000)
  330.  
  331.  
  332.  
  333.  
  334. #if defined(SDL_h_)
  335. typedef Uint8  u8 ;
  336. typedef Uint16 u16;
  337. typedef Uint32 u32;
  338. typedef Uint64 u64;
  339. typedef Sint8  s8 ;
  340. typedef Sint16 s16;
  341. typedef Sint32 s32;
  342. typedef Sint64 s64;
  343.  
  344. #elif defined(_STDINT) || defined(_CSTDINT_)
  345. typedef uint8_t  u8 ;
  346. typedef uint16_t u16;
  347. typedef uint32_t u32;
  348. typedef uint64_t u64;
  349. typedef int8_t  s8 ;
  350. typedef int16_t s16;
  351. typedef int32_t s32;
  352. typedef int64_t s64;
  353.  
  354. #else
  355. typedef unsigned char      u8 ;
  356. typedef unsigned short     u16;
  357. typedef unsigned int       u32;
  358. typedef unsigned long long u64;
  359. typedef signed char      s8 ;
  360. typedef signed short     s16;
  361. typedef signed int       s32;
  362. typedef signed long long s64;
  363.  
  364. #endif
  365.  
  366. // for consistency
  367. typedef float  f32;
  368. typedef double f64;
  369.  
  370.  
  371.  
  372. typedef void* _GenericOpaquePtr;
  373.  
  374.  
  375.  
  376. };
  377.  
  378. #endif /* _KIT_COMMONDEF_HPP */
  379.  
  380.  
  381. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\commondef.hpp */
  382.  
  383.  
  384.  
  385.  
  386. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\all.hpp */
  387.  
  388. #ifndef _KIT_ALL_HPP
  389. #define _KIT_ALL_HPP
  390.  
  391. #include "commondef.hpp"
  392. #include "misc.hpp"
  393. #include "video.hpp"
  394.  
  395. #endif /* _KIT_ALL_HPP */
  396.  
  397.  
  398. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\all.hpp */
  399.  
  400.  
  401.  
  402.  
  403. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\WindowEvent.hpp */
  404.  
  405. #ifndef _KIT__VIDEO_WINDOWEVENT_HPP
  406. #define _KIT__VIDEO_WINDOWEVENT_HPP
  407.  
  408. #include "../commondef.hpp"
  409.  
  410.  
  411. namespace kit {
  412.  
  413.  
  414.  
  415.  
  416. enum WindowEventEnum {
  417.   WINEVENT_NULL   = 0,
  418.   WINEVENT_COMMON = 1,
  419. };
  420.  
  421.  
  422.  
  423.  
  424. struct WindowEvent_Common {
  425.   u32 type;
  426.   u32 winIndex;
  427.   u64 timestamp;
  428. };
  429.  
  430.  
  431.  
  432.  
  433. union WindowEvent {
  434.   u32 type;
  435.   WindowEvent_Common common;
  436. };
  437.  
  438.  
  439.  
  440.  
  441. };
  442.  
  443. #endif /* _KIT__VIDEO_WINDOWEVENT_HPP */
  444.  
  445.  
  446. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\WindowEvent.hpp */
  447.  
  448.  
  449.  
  450.  
  451. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\Window.hpp */
  452.  
  453. #ifndef _KIT__VIDEO_WINDOW_HPP
  454. #define _KIT__VIDEO_WINDOW_HPP
  455.  
  456. #include "../commondef.hpp"
  457. #include "misc.hpp"
  458. #include "WindowEvent.hpp"
  459.  
  460.  
  461. namespace kit {
  462.  
  463.  
  464.  
  465.  
  466. enum WindowPositionEnum {
  467.   WINPOS_UNDEFINED = 0xC0000000,
  468.   WINPOS_CENTERED  = 0xC0000001,
  469. };
  470.  
  471.  
  472. enum WindowFlagEnum {
  473.   WINFLAG_HIDDEN     = 0x01, // window is not visible
  474.   WINFLAG_BORDERLESS = 0x02, // window lacks any decoration
  475.   WINFLAG_RESIZABLE  = 0x04, // window can be resized
  476.   WINFLAG_MINIMIZED  = 0x08, // window is minimized
  477.   WINFLAG_MAXIMIZED  = 0x10, // window is maximized
  478.   WINFLAG_FOCUS      = 0x20, // window has grabbed input focus
  479.   WINFLAG_FULLSCREEN = 0x40, // window is in fullscreen mode (non-exclusive)
  480.   //WINFLAG_CAPTURE_DESTROY = 0x80,
  481. };
  482.  
  483.  
  484.  
  485.  
  486. class Bitmap;
  487. struct _WindowOpaque;
  488.  
  489.  
  490.  
  491.  
  492. class Window {
  493.   u32 _type;
  494.   u32 _padding32;
  495.   _WindowOpaque* _opaque = nullptr;
  496.   bool _constructing = true;
  497.   bool _valid = false;
  498.   char _title[256];
  499.  
  500.  
  501. public:
  502.   _WindowOpaque* _accessOpaque(){ return _opaque; }; //don't touch this, seriously
  503.  
  504.   Window(const char* windowTitle,
  505.          u32 windowWidth, u32 windowHeight,
  506.          u32 windowFlags = 0,
  507.          s32 windowX = WINPOS_UNDEFINED,
  508.          s32 windowY = WINPOS_UNDEFINED,
  509.          u32 canvasWidth = 0, u32 canvasHeight = 0);
  510.  
  511.   ~Window();
  512.  
  513.  
  514.   bool isConstructing(){ return _constructing; }
  515.   bool isValid(){ return _valid; }
  516.   bool isDestroyed();
  517.  
  518.   const char* getTitle(){ return _title; }
  519.   shape::rect  getWindowRect();
  520.   shape::point getCanvasSize();
  521.   color::ARGB* getPixels();
  522.  
  523.   bool pollEvent(WindowEvent* event_p);
  524.  
  525.   void lock(bool locked = true);
  526.   void unlock(){ lock(false); }
  527.  
  528.   void present();
  529.   void clear(color::ARGB color = 0x00000000);
  530.   void tblitns(Bitmap* bmp, s32 x, s32 y, color::ARGB transparency);
  531. };
  532.  
  533.  
  534.  
  535.  
  536. };
  537.  
  538. #endif /* _KIT__VIDEO_WINDOW_HPP */
  539.  
  540.  
  541. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\Window.hpp */
  542.  
  543.  
  544.  
  545.  
  546. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\misc.hpp */
  547.  
  548. #ifndef _KIT__VIDEO_MISC_HPP
  549. #define _KIT__VIDEO_MISC_HPP
  550.  
  551. #include "../commondef.hpp"
  552.  
  553.  
  554. namespace kit {
  555.  
  556.  
  557.  
  558.  
  559. namespace color {
  560.  
  561.   //what GDI uses (save for the alpha channel)
  562.   union ARGB { //4B; 0xAARRGGBB
  563.     u32 v; //entire color [v]alue
  564.     struct {
  565.       u8 b;
  566.       u8 g;
  567.       u8 r;
  568.       u8 a;
  569.     };
  570.  
  571.     ARGB() : v(0) {}
  572.     ARGB(u32 _v) : v(_v) {}
  573.     ARGB(u8 _r, u8 _g,
  574.          u8 _b, u8 _a) : r(_r), g(_g), b(_b), a(_a) {}
  575.   };
  576.  
  577.  
  578.   union ABGR { //4B; 0xAABBGGRR
  579.     u32 v; //entire color [v]alue
  580.     struct {
  581.       u8 r;
  582.       u8 g;
  583.       u8 b;
  584.       u8 a;
  585.     };
  586.  
  587.     ABGR() : v(0) {}
  588.     ABGR(u32 _v) : v(_v) {}
  589.     ABGR(u8 _r, u8 _g,
  590.          u8 _b, u8 _a) : r(_r), g(_g), b(_b), a(_a) {}
  591.   };
  592.  
  593. };
  594.  
  595.  
  596.  
  597.  
  598. namespace shape {
  599.  
  600.   struct point { //8B
  601.     s32 x, y;
  602.     point() : x(0), y(0) {}
  603.     point(s32 _x, s32 _y) : x(_x), y(_y) {}
  604.   };
  605.  
  606.   struct rect { //16B
  607.     s32 x, y; //x & y position of the rectangle's top-left corner
  608.     s32 w, h; //the rectangle's width & height
  609.     rect() : x(0), y(0), w(0), h(0) {}
  610.     rect(s32 _x, s32 _y) : x(_x), y(_y) {}
  611.     rect(s32 _x, s32 _y,
  612.          s32 _w, s32 _h) : x(_x), y(_y), w(_w), h(_h) {}
  613.   };
  614.  
  615.   struct line { //16B
  616.     s32 x0, y0;
  617.     s32 x1, y1;
  618.     line() : x0(0), y0(0), x1(0), y1(0) {}
  619.     line(s32 _x0, s32 _y0,
  620.          s32 _x1, s32 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
  621.   };
  622.  
  623.  
  624.  
  625.   struct fpoint { //8B
  626.     f32 x, y;
  627.     fpoint() : x(0.0f), y(0.0f) {}
  628.     fpoint(f32 _x, f32 _y) : x(_x), y(_y) {}
  629.   };
  630.  
  631.   struct frect { //16B
  632.     f32 x, y; //x & y position of rectangle's top-left corner
  633.     f32 w, h; //the rectangle's width & height
  634.     frect() : x(0.0f), y(0.0f), w(0.0f), h(0.0f) {}
  635.     frect(f32 _x, f32 _y) : x(_x), y(_y) {}
  636.     frect(f32 _x, f32 _y,
  637.           f32 _w, f32 _h) : x(_x), y(_y), w(_w), h(_h) {}
  638.   };
  639.  
  640.   struct fline { //16B
  641.     f32 x0, y0;
  642.     f32 x1, y1;
  643.     fline() : x0(0.0f), y0(0.0f), x1(0.0f), y1(0.0f) {}
  644.     fline(f32 _x0, f32 _y0,
  645.           f32 _x1, f32 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
  646.   };
  647.  
  648.  
  649.  
  650.   struct dpoint { //16B
  651.     f64 x, y;
  652.     dpoint() : x(0.0), y(0.0) {}
  653.     dpoint(f64 _x, f64 _y) : x(_x), y(_y) {}
  654.   };
  655.  
  656.   struct drect { //32B
  657.     f64 x, y; //x & y position of rectangle's top-left corner
  658.     f64 w, h; //the rectangle's width & height
  659.     drect() : x(0.0), y(0.0), w(0.0), h(0.0) {}
  660.     drect(f64 _x, f64 _y) : x(_x), y(_y) {}
  661.     drect(f64 _x, f64 _y,
  662.           f64 _w, f64 _h) : x(_x), y(_y), w(_w), h(_h) {}
  663.   };
  664.  
  665.   struct dline { //32B
  666.     f64 x0, y0;
  667.     f64 x1, y1;
  668.     dline() : x0(0.0), y0(0.0), x1(0.0), y1(0.0) {}
  669.     dline(f64 _x0, f64 _y0,
  670.           f64 _x1, f64 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
  671.   };
  672.  
  673. };
  674.  
  675.  
  676.  
  677.  
  678. };
  679.  
  680. #endif /* _KIT__VIDEO_MISC_HPP */
  681.  
  682.  
  683. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\misc.hpp */
  684.  
  685.  
  686.  
  687.  
  688. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\Bitmap.hpp */
  689.  
  690. #ifndef _KIT__VIDEO_BITMAP_HPP
  691. #define _KIT__VIDEO_BITMAP_HPP
  692.  
  693. #include "../commondef.hpp"
  694. #include "misc.hpp"
  695.  
  696.  
  697. namespace kit {
  698.  
  699.  
  700.  
  701.  
  702. class Window; //from Window.hpp
  703. struct _BitmapOpaque;
  704.  
  705.  
  706.  
  707.  
  708. class Bitmap {
  709.   u32 _type;
  710.   u32 _padding32;
  711.   _BitmapOpaque* _opaque = nullptr;
  712.   bool _valid = false;
  713.  
  714.  
  715. public:
  716.   _BitmapOpaque* _accessOpaque(){ return _opaque; }
  717.   u32 getType(){ return _type; }
  718.  
  719.  
  720.   //loads from memory
  721.   Bitmap(const color::ARGB* pixelData,
  722.          u32 width, u32 height,
  723.          bool directAccess = false);
  724.  
  725.   //loads from file
  726.   Bitmap(const char* fileName,
  727.          u32 width, u32 height,
  728.          bool directAccess = false);
  729.  
  730.   ~Bitmap();
  731.  
  732.  
  733. };
  734.  
  735.  
  736.  
  737.  
  738. };
  739.  
  740. #endif /* _KIT__VIDEO_BITMAP_HPP */
  741.  
  742.  
  743. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_video\Bitmap.hpp */
  744.  
  745.  
  746.  
  747.  
  748. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_misc\time.hpp */
  749.  
  750. #ifndef _KIT__MISC_TIME_HPP
  751. #define _KIT__MISC_TIME_HPP
  752.  
  753. #include "../commondef.hpp"
  754.  
  755.  
  756. namespace kit {
  757.  
  758.  
  759. namespace time {
  760.  
  761.  
  762. u64 getTicks();
  763. u64 getTicksPerSecond();
  764. f64 getUptime();
  765.  
  766. void sleep(u32 milliseconds);
  767.  
  768.  
  769. };
  770.  
  771.  
  772. };
  773.  
  774. #endif /* _KIT__MISC_TIME_HPP */
  775.  
  776.  
  777. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_misc\time.hpp */
  778.  
  779.  
  780.  
  781.  
  782. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_misc\Mutex.hpp */
  783.  
  784. #ifndef _KIT__MISC_MUTEX_HPP
  785. #define _KIT__MISC_MUTEX_HPP
  786.  
  787. #include "../commondef.hpp"
  788.  
  789.  
  790. namespace kit {
  791.  
  792.  
  793.  
  794.  
  795. //this mutex is non-blocking within the same thread!
  796.  //(that means you can lock multiple times in one thread
  797.  // as long as you unlock it the same number of times)
  798. class MutexSimple {
  799.   u32 _type;
  800.   u32 _spinCount;
  801.   _GenericOpaquePtr _mutex_ptr = nullptr;
  802.  
  803. public:
  804.   MutexSimple(u32 spinCount = -1);
  805.   ~MutexSimple();
  806.  
  807.   void setSpinCount(u32 spinCount);
  808.   u32 getSpinCount(){ return _spinCount; }
  809.  
  810.   void lock(bool locked = true);
  811.   void unlock(){ lock(false); }
  812.   bool tryLock(); //returns true if locked successfully
  813.  
  814. };
  815.  
  816.  
  817.  
  818.  
  819. };
  820.  
  821.  
  822. #endif /* _KIT__MISC_MUTEX_HPP */
  823.  
  824.  
  825. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\include\kit\_misc\Mutex.hpp */
  826.  
  827.  
  828.  
  829.  
  830. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\kit_time.cpp */
  831.  
  832. #include <kit/_misc/time.hpp>
  833. #include "_kit_globals.hpp"
  834.  
  835. #include <Windows.h>
  836.  
  837.  
  838. namespace kit {
  839.  
  840.  
  841.  
  842.  
  843. u64 time::getTicks(){
  844.   LARGE_INTEGER ticks;
  845.   QueryPerformanceCounter(&ticks);
  846.   return ticks.QuadPart;
  847. }
  848.  
  849.  
  850.  
  851. u64 time::getTicksPerSecond(){
  852.   return w32::ticksPerSecond.QuadPart;
  853. }
  854.  
  855.  
  856.  
  857. f64 time::getUptime(){
  858.   return (f64)time::getTicks()/w32::ticksPerSecond.QuadPart;
  859. }
  860.  
  861.  
  862.  
  863.  
  864. void time::sleep(u32 milliseconds){
  865.   Sleep(milliseconds);
  866. }
  867.  
  868.  
  869.  
  870.  
  871. }; /* namespace kit */
  872.  
  873.  
  874. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\kit_time.cpp */
  875.  
  876.  
  877.  
  878.  
  879. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\kit_main.cpp */
  880.  
  881. #include "_kit_globals.hpp"
  882.  
  883. using namespace kit;
  884.  
  885.  
  886. HINSTANCE w32::hThisInst = nullptr;
  887. HINSTANCE w32::hPrevInst = nullptr;
  888. LPSTR     w32::lpszArg   = nullptr;
  889. int       w32::nCmdShow  = SW_HIDE;
  890.  
  891. LARGE_INTEGER w32::ticksPerSecond;
  892.  
  893.  
  894.  
  895.  
  896. //get first and last char of string, excluding leading or trailing whitespace
  897.  //(whitespace as in ' '; i'm not going to bother with '\t', '\n', etc.)
  898. static inline char* _getFirstCharPtr(char* start){
  899.   if(*start == 0) return start;
  900.   while(*start == ' ') ++start;
  901.   return start;
  902. }
  903.  
  904. static inline char* _getLastCharPtr(char* start){
  905.   if(*start == 0) return start;
  906.   char* end = start;
  907.   while(*(end+1) != 0 ) ++end; //go to null terminator
  908.   while(*end == ' ') --end; //go back until a non-whitespace char is found
  909.   return end;
  910. }
  911.  
  912.  
  913.  
  914.  
  915. //provided by the user
  916. extern int main(int argc, char** argv);
  917.  
  918.  
  919. //converts lpszArg to how argv normally behaves,
  920.  //before calling a user-defined main() function
  921. int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
  922.                    LPSTR     lpszArg,   int       nCmdShow)
  923. {
  924.   //assign some global values
  925.   w32::hThisInst = hThisInst;
  926.   w32::hPrevInst = hPrevInst;
  927.   w32::lpszArg   = lpszArg;
  928.   w32::nCmdShow  = nCmdShow;
  929.  
  930.   QueryPerformanceFrequency(&w32::ticksPerSecond);
  931.  
  932.  
  933.   char*      p = (char*)lpszArg;
  934.   int    _argc = 1; //should always contain path to executable
  935.   char** _argv = nullptr;
  936.  
  937.    //parse for the number of arguments (assuming space as delimiter)
  938.   char* first = _getFirstCharPtr(p);
  939.   char* last  = _getLastCharPtr(p);
  940.   int Arg_len = (int)(last-first) + ((*first!=0) ? 1 : 0);
  941.  
  942.   if(Arg_len > 0) ++_argc;
  943.   for(p=first; p<=last; ++p){
  944.     if(*p == ' ') ++_argc;
  945.   }
  946.  
  947.    //create and fill in _argv
  948.   _argv = (char**)CoTaskMemAlloc( sizeof(char*) * _argc );
  949.   if(_argv == nullptr) return ERROR_NOT_ENOUGH_MEMORY;
  950.  
  951.   char filepath[MAX_PATH]; //path to current process
  952.   if(GetModuleFileNameA(NULL, filepath, MAX_PATH) == 0)
  953.     return ERROR_INSUFFICIENT_BUFFER;
  954.   _argv[0] = filepath;
  955.  
  956.   if(Arg_len > 0){
  957.     int i = 1;
  958.     _argv[i++] = first;
  959.     for(p=first; p<=last; ++p){
  960.       if(*p == ' '){
  961.         *p = 0; //set delimiter to null
  962.         _argv[i++] = p+1; //+1 as in +sizeof(char*)
  963.       }
  964.     }
  965.     *p = 0; //make sure last arg has null terminator
  966.   }
  967.  
  968.  
  969.   int returnCode = main(_argc,_argv);
  970.   CoTaskMemFree(_argv);
  971.   return returnCode;
  972. }
  973.  
  974.  
  975.  
  976. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\kit_main.cpp */
  977.  
  978.  
  979.  
  980.  
  981. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\kit_Mutex.cpp */
  982.  
  983. #include <kit/_misc/Mutex.hpp>
  984. #include "_kit_globals.hpp"
  985.  
  986. #include <Windows.h>
  987.  
  988. #define KIT_MUTEX_NULLPTR _kit_mutex_nullptr
  989.  
  990.  
  991. using namespace kit;
  992.  
  993. static const char _kit_mutex_nullptr[] = "internal mutex = nullptr";
  994.  
  995.  
  996.  
  997.  
  998. MutexSimple::MutexSimple(u32 spinCount){
  999.   _type = KIT_CLASSTYPE_MUTEXSIMPLE;
  1000.  
  1001.   _mutex_ptr = new CRITICAL_SECTION;
  1002.  
  1003.   if(spinCount == -1){
  1004.     InitializeCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  1005.     //to my knowledge, there is no GetCriticalSectionSpinCount,
  1006.      //so i need to probe for it with a "Set" before setting it back
  1007.      //(also, i tried to grab the SpinCount member of the critical section
  1008.      // directly, but that seemed to result in undefined behavior for some reason!!!)
  1009.     _spinCount = SetCriticalSectionSpinCount((CRITICAL_SECTION*)_mutex_ptr, 0);
  1010.     SetCriticalSectionSpinCount((CRITICAL_SECTION*)_mutex_ptr, _spinCount);
  1011.  
  1012.   } else {
  1013.     InitializeCriticalSectionAndSpinCount((CRITICAL_SECTION*)_mutex_ptr, spinCount);
  1014.     _spinCount = spinCount;
  1015.  
  1016.   }
  1017. }
  1018.  
  1019.  
  1020.  
  1021. MutexSimple::~MutexSimple(){
  1022.   if(_mutex_ptr == nullptr) return;
  1023.   DeleteCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  1024.   delete _mutex_ptr;
  1025.   _mutex_ptr = nullptr;
  1026. }
  1027.  
  1028.  
  1029.  
  1030.  
  1031. void MutexSimple::setSpinCount(u32 spinCount){
  1032.   if(_mutex_ptr == nullptr) throw KIT_MUTEX_NULLPTR;
  1033.   SetCriticalSectionSpinCount((CRITICAL_SECTION*)_mutex_ptr, spinCount);
  1034.   _spinCount = spinCount;
  1035. }
  1036.  
  1037.  
  1038.  
  1039.  
  1040. void MutexSimple::lock(bool locked){
  1041.   if(_mutex_ptr == nullptr) throw KIT_MUTEX_NULLPTR;
  1042.   if(locked) EnterCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  1043.   else       LeaveCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  1044. }
  1045.  
  1046.  
  1047.  
  1048. bool MutexSimple::tryLock(){
  1049.   if(_mutex_ptr == nullptr) throw KIT_MUTEX_NULLPTR;
  1050.   return TryEnterCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  1051. }
  1052.  
  1053.  
  1054. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\kit_Mutex.cpp */
  1055.  
  1056.  
  1057.  
  1058.  
  1059. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Window\kit_WindowProc.cpp */
  1060.  
  1061. #include <kit/_video/Window.hpp>
  1062. #include "_kit_Window.hpp"
  1063.  
  1064. #include <stdio.h>
  1065.  
  1066.  
  1067. using namespace kit;
  1068.  
  1069.  
  1070.  
  1071.  
  1072. #if defined(_DEBUG)
  1073. static void printMessage(HWND, UINT, WPARAM, LPARAM);
  1074. #endif /* _DEBUG */
  1075.  
  1076. LRESULT CALLBACK w32::WindowProc(HWND winHandle, UINT message,
  1077.                                  WPARAM wParam, LPARAM lParam)
  1078. {
  1079. #if defined(_DEBUG)
  1080.   //printMessage(winHandle, message, wParam, lParam);
  1081. #endif /* _DEBUG */
  1082.  
  1083.   Window* window = (Window*)GetWindowLongPtrA(winHandle, GWLP_USERDATA);
  1084.   if(window == nullptr){
  1085.     if(message == WM_CREATE){
  1086.       //set userdata to a pointer to the associated kit::Window
  1087.       CREATESTRUCT* cs = (CREATESTRUCT*)lParam;
  1088.       SetWindowLongPtrA(winHandle, GWLP_USERDATA, (LONG_PTR)cs->lpCreateParams);
  1089.       return 0;
  1090.     } else {
  1091.       goto _dwp; //lol
  1092.     }
  1093.   } else if(!window->isValid() && !window->isConstructing()){
  1094.     _dwp: return DefWindowProcA(winHandle, message, wParam, lParam);
  1095.   }
  1096.  
  1097.  
  1098.   _WindowOpaque* opaque = window->_accessOpaque();
  1099.   EnterCriticalSection(&opaque->lock);
  1100.   LRESULT returnResult = 0;
  1101.  
  1102.   switch(message){
  1103.     case WM_QUIT:
  1104.     case WM_DESTROY:
  1105.     {
  1106.       //delete canvas and and any of its allocated memory
  1107.       if(opaque->canvas != nullptr){
  1108.         DeleteObject(opaque->canvas);
  1109.         opaque->canvas = nullptr;
  1110.       }
  1111.       opaque->winDestroyed = true;
  1112.     } break;
  1113.  
  1114.  
  1115.     case WM_PAINT:
  1116.     {
  1117.       if(opaque->canvas == nullptr) break; //just in case
  1118.       static PAINTSTRUCT  paint;
  1119.       static HDC          winDevCtx; //window device context
  1120.       static RECT         rectO; //[O]riginal
  1121.       static shape::rect  rectW; //[W]indow
  1122.       static shape::point sizeF; //[F]rame
  1123.  
  1124.       //prepare window for painting
  1125.       winDevCtx = BeginPaint(winHandle, &paint);
  1126.       rectO = paint.rcPaint;
  1127.       rectW = ConvertToKitRect(rectO);
  1128.       sizeF = opaque->canvasSize;
  1129.  
  1130.       //copy canvas bitmap to window
  1131.       SetStretchBltMode(winDevCtx, opaque->canvasStretchMode);
  1132.       StretchBlt(winDevCtx, rectW.x,rectW.y, rectW.w,rectW.h,
  1133.                  opaque->canvasDevCtx,  0,0, sizeF.x,sizeF.y, SRCCOPY);
  1134.  
  1135.       EndPaint(winHandle, &paint);
  1136.  
  1137.     } break;
  1138.  
  1139.  
  1140.     case WM_SIZE:
  1141.     {
  1142.       //window resized; adjust canvas size accordingly
  1143.       opaque->winRect.w = LOWORD(lParam);
  1144.       opaque->winRect.h = HIWORD(lParam);
  1145.  
  1146.       if(opaque->canvasStretch){
  1147.         //create initial canvas bitmap, before binding the canvas device context to it
  1148.         if(opaque->canvas == nullptr){
  1149.           opaque->canvas = CreateDIBSection(nullptr, &opaque->canvasInfo, DIB_RGB_COLORS,
  1150.                                             (void**)&opaque->canvasPixels, nullptr, 0);
  1151.           SelectObject(opaque->canvasDevCtx, opaque->canvas);
  1152.         }
  1153.  
  1154.  
  1155.       } else {
  1156.         //calculate new canvas size
  1157.         opaque->canvasSize.x = LOWORD(lParam);
  1158.         opaque->canvasSize.y = HIWORD(lParam);
  1159.         opaque->canvasInfo.bmiHeader.biWidth  = LOWORD(lParam);
  1160.         opaque->canvasInfo.bmiHeader.biHeight = HIWORD(lParam);
  1161.  
  1162.         //create new canvas bitmap, before binding the canvas device context to it
  1163.         if(opaque->canvas != nullptr) DeleteObject(opaque->canvas);
  1164.         opaque->canvas = CreateDIBSection(nullptr, &opaque->canvasInfo, DIB_RGB_COLORS,
  1165.                                           (void**)&opaque->canvasPixels, nullptr, 0);
  1166.         SelectObject(opaque->canvasDevCtx, opaque->canvas);
  1167.       }
  1168.  
  1169.       window->present(); //blit canvas to the window to reflect its new size
  1170.  
  1171.     } break;
  1172.  
  1173.  
  1174.     case WM_GETMINMAXINFO:
  1175.     {
  1176.       //enforce minimum window size if canvas does not scale with the window
  1177.       if(opaque->canvasStretch){
  1178.         u32 winStyleCurrent   = GetWindowLongA(winHandle, GWL_STYLE  );
  1179.         u32 winStyleExCurrent = GetWindowLongA(winHandle, GWL_EXSTYLE);
  1180.         shape::point winSizeAdjusted = CalculateWindowSize(opaque->canvasSize.x,
  1181.                                                            opaque->canvasSize.y,
  1182.                                                            winStyleCurrent,
  1183.                                                            winStyleExCurrent);
  1184.  
  1185.         MINMAXINFO* mmi = (MINMAXINFO*)lParam;
  1186.         mmi->ptMinTrackSize.x = winSizeAdjusted.x;
  1187.         mmi->ptMinTrackSize.y = winSizeAdjusted.y;
  1188.       }
  1189.  
  1190.     } break;
  1191.  
  1192.  
  1193.     default: returnResult = DefWindowProcA(winHandle, message, wParam, lParam);
  1194.   }
  1195.  
  1196.  
  1197.   LeaveCriticalSection(&opaque->lock);
  1198.   return returnResult;
  1199. }
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208. //these are for enabling and disabling what messages are printed
  1209.  //simply comment these out to disable them
  1210.  
  1211. #define KIT_PM_WM_NULL                           //0x0000
  1212. #define KIT_PM_WM_CREATE                         //0x0001
  1213. #define KIT_PM_WM_DESTROY                        //0x0002
  1214. #define KIT_PM_WM_MOVE                           //0x0003
  1215. #define KIT_PM_WM_SIZE                           //0x0005
  1216. #define KIT_PM_WM_ACTIVATE                       //0x0006
  1217. #define KIT_PM_WM_SETFOCUS                       //0x0007
  1218. #define KIT_PM_WM_KILLFOCUS                      //0x0008
  1219. #define KIT_PM_WM_ENABLE                         //0x000A
  1220. #define KIT_PM_WM_SETREDRAW                      //0x000B
  1221. #define KIT_PM_WM_SETTEXT                        //0x000C
  1222. //#define KIT_PM_WM_GETTEXT                        //0x000D
  1223. //#define KIT_PM_WM_GETTEXTLENGTH                  //0x000E
  1224. #define KIT_PM_WM_PAINT                          //0x000F
  1225. #define KIT_PM_WM_CLOSE                          //0x0010
  1226. #define KIT_PM_WM_QUERYENDSESSION                //0x0011
  1227. #define KIT_PM_WM_QUIT                           //0x0012
  1228. #define KIT_PM_WM_QUERYOPEN                      //0x0013
  1229. #define KIT_PM_WM_ERASEBKGND                     //0x0014
  1230. #define KIT_PM_WM_SYSCOLORCHANGE                 //0x0015
  1231. #define KIT_PM_WM_ENDSESSION                     //0x0016
  1232. #define KIT_PM_WM_SHOWWINDOW                     //0x0018
  1233. #define KIT_PM_WM_SETTINGCHANGE                  //0x001A
  1234. #define KIT_PM_WM_DEVMODECHANGE                  //0x001B
  1235. #define KIT_PM_WM_ACTIVATEAPP                    //0x001C
  1236. #define KIT_PM_WM_FONTCHANGE                     //0x001D
  1237. #define KIT_PM_WM_TIMECHANGE                     //0x001E
  1238. #define KIT_PM_WM_CANCELMODE                     //0x001F
  1239. //#define KIT_PM_WM_SETCURSOR                      //0x0020
  1240. #define KIT_PM_WM_MOUSEACTIVATE                  //0x0021
  1241. #define KIT_PM_WM_CHILDACTIVATE                  //0x0022
  1242. #define KIT_PM_WM_QUEUESYNC                      //0x0023
  1243. #define KIT_PM_WM_GETMINMAXINFO                  //0x0024
  1244. #define KIT_PM_WM_PAINTICON                      //0x0026
  1245. #define KIT_PM_WM_ICONERASEBKGND                 //0x0027
  1246. #define KIT_PM_WM_NEXTDLGCTL                     //0x0028
  1247. #define KIT_PM_WM_SPOOLERSTATUS                  //0x002A
  1248. #define KIT_PM_WM_DRAWITEM                       //0x002B
  1249. #define KIT_PM_WM_MEASUREITEM                    //0x002C
  1250. #define KIT_PM_WM_DELETEITEM                     //0x002D
  1251. #define KIT_PM_WM_VKEYTOITEM                     //0x002E
  1252. #define KIT_PM_WM_CHARTOITEM                     //0x002F
  1253. #define KIT_PM_WM_SETFONT                        //0x0030
  1254. #define KIT_PM_WM_GETFONT                        //0x0031
  1255. #define KIT_PM_WM_SETHOTKEY                      //0x0032
  1256. #define KIT_PM_WM_GETHOTKEY                      //0x0033
  1257. #define KIT_PM_WM_QUERYDRAGICON                  //0x0037
  1258. #define KIT_PM_WM_COMPAREITEM                    //0x0039
  1259. #define KIT_PM_WM_GETOBJECT                      //0x003D
  1260. #define KIT_PM_WM_COMPACTING                     //0x0041
  1261. #define KIT_PM_WM_COMMNOTIFY                     //0x0044
  1262. #define KIT_PM_WM_WINDOWPOSCHANGING              //0x0046
  1263. #define KIT_PM_WM_WINDOWPOSCHANGED               //0x0047
  1264. #define KIT_PM_WM_POWER                          //0x0048
  1265. #define KIT_PM_WM_COPYDATA                       //0x004A
  1266. #define KIT_PM_WM_CANCELJOURNAL                  //0x004B
  1267. #define KIT_PM_WM_NOTIFY                         //0x004E
  1268. #define KIT_PM_WM_INPUTLANGCHANGEREQUEST         //0x0050
  1269. #define KIT_PM_WM_INPUTLANGCHANGE                //0x0051
  1270. #define KIT_PM_WM_TCARD                          //0x0052
  1271. #define KIT_PM_WM_HELP                           //0x0053
  1272. #define KIT_PM_WM_USERCHANGED                    //0x0054
  1273. #define KIT_PM_WM_NOTIFYFORMAT                   //0x0055
  1274. #define KIT_PM_WM_CONTEXTMENU                    //0x007B
  1275. #define KIT_PM_WM_STYLECHANGING                  //0x007C
  1276. #define KIT_PM_WM_STYLECHANGED                   //0x007D
  1277. #define KIT_PM_WM_DISPLAYCHANGE                  //0x007E
  1278. #define KIT_PM_WM_GETICON                        //0x007F
  1279. #define KIT_PM_WM_SETICON                        //0x0080
  1280. #define KIT_PM_WM_NCCREATE                       //0x0081
  1281. #define KIT_PM_WM_NCDESTROY                      //0x0082
  1282. #define KIT_PM_WM_NCCALCSIZE                     //0x0083
  1283. //#define KIT_PM_WM_NCHITTEST                      //0x0084
  1284. #define KIT_PM_WM_NCPAINT                        //0x0085
  1285. #define KIT_PM_WM_NCACTIVATE                     //0x0086
  1286. #define KIT_PM_WM_GETDLGCODE                     //0x0087
  1287. #define KIT_PM_WM_SYNCPAINT                      //0x0088
  1288.  
  1289. //#define KIT_PM_WM_NCMOUSEMOVE                    //0x00A0
  1290. #define KIT_PM_WM_NCLBUTTONDOWN                  //0x00A1
  1291. #define KIT_PM_WM_NCLBUTTONUP                    //0x00A2
  1292. #define KIT_PM_WM_NCLBUTTONDBLCLK                //0x00A3
  1293. #define KIT_PM_WM_NCRBUTTONDOWN                  //0x00A4
  1294. #define KIT_PM_WM_NCRBUTTONUP                    //0x00A5
  1295. #define KIT_PM_WM_NCRBUTTONDBLCLK                //0x00A6
  1296. #define KIT_PM_WM_NCMBUTTONDOWN                  //0x00A7
  1297. #define KIT_PM_WM_NCMBUTTONUP                    //0x00A8
  1298. #define KIT_PM_WM_NCMBUTTONDBLCLK                //0x00A9
  1299. #define KIT_PM_WM_NCXBUTTONDOWN                  //0x00AB
  1300. #define KIT_PM_WM_NCXBUTTONUP                    //0x00AC
  1301. #define KIT_PM_WM_NCXBUTTONDBLCLK                //0x00AD
  1302.  
  1303. #define KIT_PM_WM_INPUT_DEVICE_CHANGE            //0x00FE
  1304. #define KIT_PM_WM_INPUT                          //0x00FF
  1305. #define KIT_PM_WM_KEYDOWN                        //0x0100
  1306. #define KIT_PM_WM_KEYUP                          //0x0101
  1307. #define KIT_PM_WM_CHAR                           //0x0102
  1308. #define KIT_PM_WM_DEADCHAR                       //0x0103
  1309. #define KIT_PM_WM_SYSKEYDOWN                     //0x0104
  1310. #define KIT_PM_WM_SYSKEYUP                       //0x0105
  1311. #define KIT_PM_WM_SYSCHAR                        //0x0106
  1312. #define KIT_PM_WM_SYSDEADCHAR                    //0x0107
  1313. #define KIT_PM_WM_UNICHAR                        //0x0109
  1314. #define KIT_PM_WM_IME_STARTCOMPOSITION           //0x010D
  1315. #define KIT_PM_WM_IME_ENDCOMPOSITION             //0x010E
  1316. #define KIT_PM_WM_IME_COMPOSITION                //0x010F
  1317. #define KIT_PM_WM_INITDIALOG                     //0x0110
  1318. #define KIT_PM_WM_COMMAND                        //0x0111
  1319. #define KIT_PM_WM_SYSCOMMAND                     //0x0112
  1320. #define KIT_PM_WM_TIMER                          //0x0113
  1321. #define KIT_PM_WM_HSCROLL                        //0x0114
  1322. #define KIT_PM_WM_VSCROLL                        //0x0115
  1323. #define KIT_PM_WM_INITMENU                       //0x0116
  1324. #define KIT_PM_WM_INITMENUPOPUP                  //0x0117
  1325. #define KIT_PM_WM_GESTURE                        //0x0119
  1326. #define KIT_PM_WM_GESTURENOTIFY                  //0x011A
  1327. #define KIT_PM_WM_MENUSELECT                     //0x011F
  1328. #define KIT_PM_WM_MENUCHAR                       //0x0120
  1329. #define KIT_PM_WM_ENTERIDLE                      //0x0121
  1330. #define KIT_PM_WM_MENURBUTTONUP                  //0x0122
  1331. #define KIT_PM_WM_MENUDRAG                       //0x0123
  1332. #define KIT_PM_WM_MENUGETOBJECT                  //0x0124
  1333. #define KIT_PM_WM_UNINITMENUPOPUP                //0x0125
  1334. #define KIT_PM_WM_MENUCOMMAND                    //0x0126
  1335. #define KIT_PM_WM_CHANGEUISTATE                  //0x0127
  1336. #define KIT_PM_WM_UPDATEUISTATE                  //0x0128
  1337. #define KIT_PM_WM_QUERYUISTATE                   //0x0129
  1338. #define KIT_PM_WM_CTLCOLORMSGBOX                 //0x0132
  1339. #define KIT_PM_WM_CTLCOLOREDIT                   //0x0133
  1340. #define KIT_PM_WM_CTLCOLORLISTBOX                //0x0134
  1341. #define KIT_PM_WM_CTLCOLORBTN                    //0x0135
  1342. #define KIT_PM_WM_CTLCOLORDLG                    //0x0136
  1343. #define KIT_PM_WM_CTLCOLORSCROLLBAR              //0x0137
  1344. #define KIT_PM_WM_CTLCOLORSTATIC                 //0x0138
  1345. #define KIT_PM_MN_GETHMENU                       //0x01E1
  1346.  
  1347. //#define KIT_PM_WM_MOUSEMOVE                      //0x0200
  1348. #define KIT_PM_WM_LBUTTONDOWN                    //0x0201
  1349. #define KIT_PM_WM_LBUTTONUP                      //0x0202
  1350. #define KIT_PM_WM_LBUTTONDBLCLK                  //0x0203
  1351. #define KIT_PM_WM_RBUTTONDOWN                    //0x0204
  1352. #define KIT_PM_WM_RBUTTONUP                      //0x0205
  1353. #define KIT_PM_WM_RBUTTONDBLCLK                  //0x0206
  1354. #define KIT_PM_WM_MBUTTONDOWN                    //0x0207
  1355. #define KIT_PM_WM_MBUTTONUP                      //0x0208
  1356. #define KIT_PM_WM_MBUTTONDBLCLK                  //0x0209
  1357. #define KIT_PM_WM_MOUSEWHEEL                     //0x020A
  1358. #define KIT_PM_WM_XBUTTONDOWN                    //0x020B
  1359. #define KIT_PM_WM_XBUTTONUP                      //0x020C
  1360. #define KIT_PM_WM_XBUTTONDBLCLK                  //0x020D
  1361.  
  1362. #define KIT_PM_WM_PARENTNOTIFY                   //0x0210
  1363. #define KIT_PM_WM_ENTERMENULOOP                  //0x0211
  1364. #define KIT_PM_WM_EXITMENULOOP                   //0x0212
  1365. #define KIT_PM_WM_NEXTMENU                       //0x0213
  1366. #define KIT_PM_WM_SIZING                         //0x0214
  1367. #define KIT_PM_WM_CAPTURECHANGED                 //0x0215
  1368. #define KIT_PM_WM_MOVING                         //0x0216
  1369. #define KIT_PM_WM_POWERBROADCAST                 //0x0218
  1370. #define KIT_PM_WM_DEVICECHANGE                   //0x0219
  1371. #define KIT_PM_WM_MDICREATE                      //0x0220
  1372. #define KIT_PM_WM_MDIDESTROY                     //0x0221
  1373. #define KIT_PM_WM_MDIACTIVATE                    //0x0222
  1374. #define KIT_PM_WM_MDIRESTORE                     //0x0223
  1375. #define KIT_PM_WM_MDINEXT                        //0x0224
  1376. #define KIT_PM_WM_MDIMAXIMIZE                    //0x0225
  1377. #define KIT_PM_WM_MDITILE                        //0x0226
  1378. #define KIT_PM_WM_MDICASCADE                     //0x0227
  1379. #define KIT_PM_WM_MDIICONARRANGE                 //0x0228
  1380. #define KIT_PM_WM_MDIGETACTIVE                   //0x0229
  1381. #define KIT_PM_WM_MDISETMENU                     //0x0230
  1382. #define KIT_PM_WM_ENTERSIZEMOVE                  //0x0231
  1383. #define KIT_PM_WM_EXITSIZEMOVE                   //0x0232
  1384. #define KIT_PM_WM_DROPFILES                      //0x0233
  1385. #define KIT_PM_WM_MDIREFRESHMENU                 //0x0234
  1386. #define KIT_PM_WM_POINTERDEVICECHANGE            //0x0238
  1387. #define KIT_PM_WM_POINTERDEVICEINRANGE           //0x0239
  1388. #define KIT_PM_WM_POINTERDEVICEOUTOFRANGE        //0x023A
  1389. #define KIT_PM_WM_TOUCH                          //0x0240
  1390. #define KIT_PM_WM_NCPOINTERUPDATE                //0x0241
  1391. #define KIT_PM_WM_NCPOINTERDOWN                  //0x0242
  1392. #define KIT_PM_WM_NCPOINTERUP                    //0x0243
  1393. #define KIT_PM_WM_POINTERUPDATE                  //0x0245
  1394. #define KIT_PM_WM_POINTERDOWN                    //0x0246
  1395. #define KIT_PM_WM_POINTERUP                      //0x0247
  1396. #define KIT_PM_WM_POINTERENTER                   //0x0249
  1397. #define KIT_PM_WM_POINTERLEAVE                   //0x024A
  1398. #define KIT_PM_WM_POINTERACTIVATE                //0x024B
  1399. #define KIT_PM_WM_POINTERCAPTURECHANGED          //0x024C
  1400. #define KIT_PM_WM_TOUCHHITTESTING                //0x024D
  1401. #define KIT_PM_WM_POINTERWHEEL                   //0x024E
  1402. #define KIT_PM_WM_POINTERHWHEEL                  //0x024F
  1403. #define KIT_PM_DM_POINTERHITTEST                 //0x0250
  1404. #define KIT_PM_WM_POINTERROUTEDTO                //0x0251
  1405. #define KIT_PM_WM_POINTERROUTEDAWAY              //0x0252
  1406. #define KIT_PM_WM_POINTERROUTEDRELEASED          //0x0253
  1407. #define KIT_PM_WM_IME_SETCONTEXT                 //0x0281
  1408. #define KIT_PM_WM_IME_NOTIFY                     //0x0282
  1409. #define KIT_PM_WM_IME_CONTROL                    //0x0283
  1410. #define KIT_PM_WM_IME_COMPOSITIONFULL            //0x0284
  1411. #define KIT_PM_WM_IME_SELECT                     //0x0285
  1412. #define KIT_PM_WM_IME_CHAR                       //0x0286
  1413. #define KIT_PM_WM_IME_REQUEST                    //0x0288
  1414. #define KIT_PM_WM_IME_KEYDOWN                    //0x0290
  1415. #define KIT_PM_WM_IME_KEYUP                      //0x0291
  1416. #define KIT_PM_WM_MOUSEHOVER                     //0x02A1
  1417. #define KIT_PM_WM_MOUSELEAVE                     //0x02A3
  1418. #define KIT_PM_WM_NCMOUSEHOVER                   //0x02A0
  1419. #define KIT_PM_WM_NCMOUSELEAVE                   //0x02A2
  1420. #define KIT_PM_WM_WTSSESSION_CHANGE              //0x02B1
  1421. #define KIT_PM_WM_DPICHANGED                     //0x02E0
  1422. #define KIT_PM_WM_DPICHANGED_BEFOREPARENT        //0x02E2
  1423. #define KIT_PM_WM_DPICHANGED_AFTERPARENT         //0x02E3
  1424. #define KIT_PM_WM_GETDPISCALEDSIZE               //0x02E4
  1425. #define KIT_PM_WM_CUT                            //0x0300
  1426. #define KIT_PM_WM_COPY                           //0x0301
  1427. #define KIT_PM_WM_PASTE                          //0x0302
  1428. #define KIT_PM_WM_CLEAR                          //0x0303
  1429. #define KIT_PM_WM_UNDO                           //0x0304
  1430. #define KIT_PM_WM_RENDERFORMAT                   //0x0305
  1431. #define KIT_PM_WM_RENDERALLFORMATS               //0x0306
  1432. #define KIT_PM_WM_DESTROYCLIPBOARD               //0x0307
  1433. #define KIT_PM_WM_DRAWCLIPBOARD                  //0x0308
  1434. #define KIT_PM_WM_PAINTCLIPBOARD                 //0x0309
  1435. #define KIT_PM_WM_VSCROLLCLIPBOARD               //0x030A
  1436. #define KIT_PM_WM_SIZECLIPBOARD                  //0x030B
  1437. #define KIT_PM_WM_ASKCBFORMATNAME                //0x030C
  1438. #define KIT_PM_WM_CHANGECBCHAIN                  //0x030D
  1439. #define KIT_PM_WM_HSCROLLCLIPBOARD               //0x030E
  1440. #define KIT_PM_WM_QUERYNEWPALETTE                //0x030F
  1441. #define KIT_PM_WM_PALETTEISCHANGING              //0x0310
  1442. #define KIT_PM_WM_PALETTECHANGED                 //0x0311
  1443. #define KIT_PM_WM_HOTKEY                         //0x0312
  1444. #define KIT_PM_WM_PRINT                          //0x0317
  1445. #define KIT_PM_WM_PRINTCLIENT                    //0x0318
  1446. #define KIT_PM_WM_APPCOMMAND                     //0x0319
  1447. #define KIT_PM_WM_THEMECHANGED                   //0x031A
  1448. #define KIT_PM_WM_CLIPBOARDUPDATE                //0x031D
  1449. #define KIT_PM_WM_DWMCOMPOSITIONCHANGED          //0x031E
  1450. #define KIT_PM_WM_DWMNCRENDERINGCHANGED          //0x031F
  1451. #define KIT_PM_WM_DWMCOLORIZATIONCOLORCHANGED    //0x0320
  1452. #define KIT_PM_WM_DWMWINDOWMAXIMIZEDCHANGE       //0x0321
  1453. #define KIT_PM_WM_DWMSENDICONICTHUMBNAIL         //0x0323
  1454. #define KIT_PM_WM_DWMSENDICONICLIVEPREVIEWBITMAP //0x0326
  1455. #define KIT_PM_WM_GETTITLEBARINFOEX              //0x033F
  1456. //#define KIT_PM_WM_UNKNOWN                        //0x????
  1457.  
  1458.  
  1459.  
  1460.  
  1461. #if defined(_DEBUG) //this function will do nothing otherwise
  1462. static void printMessage(HWND hwnd, UINT message,
  1463.                          WPARAM wParam, LPARAM lParam)
  1464. {
  1465.   char* messageName = nullptr;
  1466.  
  1467.  
  1468.   switch(message){
  1469. #  ifdef KIT_PM_WM_NULL
  1470.   case WM_NULL                          : messageName = "WM_NULL";              break; //0x0000
  1471. #  endif
  1472.  
  1473. #  ifdef KIT_PM_WM_CREATE
  1474.   case WM_CREATE                        : messageName = "WM_CREATE";            break; //0x0001
  1475. #  endif
  1476.  
  1477. #  ifdef KIT_PM_WM_DESTROY
  1478.   case WM_DESTROY                       : messageName = "WM_DESTROY";           break; //0x0002
  1479. #  endif
  1480.  
  1481. #  ifdef KIT_PM_WM_MOVE
  1482.   case WM_MOVE                          : messageName = "WM_MOVE";              break; //0x0003
  1483. #  endif
  1484.  
  1485. #  ifdef KIT_PM_WM_SIZE
  1486.   case WM_SIZE                          : messageName = "WM_SIZE";              break; //0x0005
  1487. #  endif
  1488.  
  1489. #  ifdef KIT_PM_WM_ACTIVATE
  1490.   case WM_ACTIVATE                      : messageName = "WM_ACTIVATE";          break; //0x0006
  1491. #  endif
  1492.  
  1493. #  ifdef KIT_PM_WM_SETFOCUS
  1494.   case WM_SETFOCUS                      : messageName = "WM_SETFOCUS";          break; //0x0007
  1495. #  endif
  1496.  
  1497. #  ifdef KIT_PM_WM_KILLFOCUS
  1498.   case WM_KILLFOCUS                     : messageName = "WM_KILLFOCUS";         break; //0x0008
  1499. #  endif
  1500.  
  1501. #  ifdef KIT_PM_WM_ENABLE
  1502.   case WM_ENABLE                        : messageName = "WM_ENABLE";            break; //0x000A
  1503. #  endif
  1504.  
  1505. #  ifdef KIT_PM_WM_SETREDRAW
  1506.   case WM_SETREDRAW                     : messageName = "WM_SETREDRAW";         break; //0x000B
  1507. #  endif
  1508.  
  1509. #  ifdef KIT_PM_WM_SETTEXT
  1510.   case WM_SETTEXT                       : messageName = "WM_SETTEXT";           break; //0x000C
  1511. #  endif
  1512.  
  1513. #  ifdef KIT_PM_WM_GETTEXT
  1514.   case WM_GETTEXT                       : messageName = "WM_GETTEXT";           break; //0x000D
  1515. #  endif
  1516.  
  1517. #  ifdef KIT_PM_WM_GETTEXTLENGTH
  1518.   case WM_GETTEXTLENGTH                 : messageName = "WM_GETTEXTLENGTH";     break; //0x000E
  1519. #  endif
  1520.  
  1521. #  ifdef KIT_PM_WM_PAINT
  1522.   case WM_PAINT                         : messageName = "WM_PAINT";             break; //0x000F
  1523. #  endif
  1524.  
  1525. #  ifdef KIT_PM_WM_CLOSE
  1526.   case WM_CLOSE                         : messageName = "WM_CLOSE";             break; //0x0010
  1527. #  endif
  1528.  
  1529. #  ifdef KIT_PM_WM_QUERYENDSESSION
  1530.   case WM_QUERYENDSESSION               : messageName = "WM_QUERYENDSESSION";   break; //0x0011
  1531. #  endif
  1532.  
  1533. #  ifdef KIT_PM_WM_QUIT
  1534.   case WM_QUIT                          : messageName = "WM_QUIT";              break; //0x0012
  1535. #  endif
  1536.  
  1537. #  ifdef KIT_PM_WM_QUERYOPEN
  1538.   case WM_QUERYOPEN                     : messageName = "WM_QUERYOPEN";         break; //0x0013
  1539. #  endif
  1540.  
  1541. #  ifdef KIT_PM_WM_ERASEBKGND
  1542.   case WM_ERASEBKGND                    : messageName = "WM_ERASEBKGND";        break; //0x0014
  1543. #  endif
  1544.  
  1545. #  ifdef KIT_PM_WM_SYSCOLORCHANGE
  1546.   case WM_SYSCOLORCHANGE                : messageName = "WM_SYSCOLORCHANGE";    break; //0x0015
  1547. #  endif
  1548.  
  1549. #  ifdef KIT_PM_WM_ENDSESSION
  1550.   case WM_ENDSESSION                    : messageName = "WM_ENDSESSION";        break; //0x0016
  1551. #  endif
  1552.  
  1553. #  ifdef KIT_PM_WM_SHOWWINDOW
  1554.   case WM_SHOWWINDOW                    : messageName = "WM_SHOWWINDOW";        break; //0x0018
  1555. #  endif
  1556.  
  1557. #  ifdef KIT_PM_WM_SETTINGCHANGE
  1558.   case WM_SETTINGCHANGE                 : messageName = "WM_SETTINGCHANGE";     break; //0x001A
  1559. #  endif
  1560.  
  1561. #  ifdef KIT_PM_WM_DEVMODECHANGE
  1562.   case WM_DEVMODECHANGE                 : messageName = "WM_DEVMODECHANGE";     break; //0x001B
  1563. #  endif
  1564.  
  1565. #  ifdef KIT_PM_WM_ACTIVATEAPP
  1566.   case WM_ACTIVATEAPP                   : messageName = "WM_ACTIVATEAPP";       break; //0x001C
  1567. #  endif
  1568.  
  1569. #  ifdef KIT_PM_WM_FONTCHANGE
  1570.   case WM_FONTCHANGE                    : messageName = "WM_FONTCHANGE";        break; //0x001D
  1571. #  endif
  1572.  
  1573. #  ifdef KIT_PM_WM_TIMECHANGE
  1574.   case WM_TIMECHANGE                    : messageName = "WM_TIMECHANGE";        break; //0x001E
  1575. #  endif
  1576.  
  1577. #  ifdef KIT_PM_WM_CANCELMODE
  1578.   case WM_CANCELMODE                    : messageName = "WM_CANCELMODE";        break; //0x001F
  1579. #  endif
  1580.  
  1581. #  ifdef KIT_PM_WM_SETCURSOR
  1582.   case WM_SETCURSOR                     : messageName = "WM_SETCURSOR";         break; //0x0020
  1583. #  endif
  1584.  
  1585. #  ifdef KIT_PM_WM_MOUSEACTIVATE
  1586.   case WM_MOUSEACTIVATE                 : messageName = "WM_MOUSEACTIVATE";     break; //0x0021
  1587. #  endif
  1588.  
  1589. #  ifdef KIT_PM_WM_CHILDACTIVATE
  1590.   case WM_CHILDACTIVATE                 : messageName = "WM_CHILDACTIVATE";     break; //0x0022
  1591. #  endif
  1592.  
  1593. #  ifdef KIT_PM_WM_QUEUESYNC
  1594.   case WM_QUEUESYNC                     : messageName = "WM_QUEUESYNC";         break; //0x0023
  1595. #  endif
  1596.  
  1597. #  ifdef KIT_PM_WM_GETMINMAXINFO
  1598.   case WM_GETMINMAXINFO                 : messageName = "WM_GETMINMAXINFO";     break; //0x0024
  1599. #  endif
  1600.  
  1601. #  ifdef KIT_PM_WM_PAINTICON
  1602.   case WM_PAINTICON                     : messageName = "WM_PAINTICON";         break; //0x0026
  1603. #  endif
  1604.  
  1605. #  ifdef KIT_PM_WM_ICONERASEBKGND
  1606.   case WM_ICONERASEBKGND                : messageName = "WM_ICONERASEBKGND";    break; //0x0027
  1607. #  endif
  1608.  
  1609. #  ifdef KIT_PM_WM_NEXTDLGCTL
  1610.   case WM_NEXTDLGCTL                    : messageName = "WM_NEXTDLGCTL";        break; //0x0028
  1611. #  endif
  1612.  
  1613. #  ifdef KIT_PM_WM_SPOOLERSTATUS
  1614.   case WM_SPOOLERSTATUS                 : messageName = "WM_SPOOLERSTATUS";     break; //0x002A
  1615. #  endif
  1616.  
  1617. #  ifdef KIT_PM_WM_DRAWITEM
  1618.   case WM_DRAWITEM                      : messageName = "WM_DRAWITEM";          break; //0x002B
  1619. #  endif
  1620.  
  1621. #  ifdef KIT_PM_WM_MEASUREITEM
  1622.   case WM_MEASUREITEM                   : messageName = "WM_MEASUREITEM";       break; //0x002C
  1623. #  endif
  1624.  
  1625. #  ifdef KIT_PM_WM_DELETEITEM
  1626.   case WM_DELETEITEM                    : messageName = "WM_DELETEITEM";        break; //0x002D
  1627. #  endif
  1628.  
  1629. #  ifdef KIT_PM_WM_VKEYTOITEM
  1630.   case WM_VKEYTOITEM                    : messageName = "WM_VKEYTOITEM";        break; //0x002E
  1631. #  endif
  1632.  
  1633. #  ifdef KIT_PM_WM_CHARTOITEM
  1634.   case WM_CHARTOITEM                    : messageName = "WM_CHARTOITEM";        break; //0x002F
  1635. #  endif
  1636.  
  1637. #  ifdef KIT_PM_WM_SETFONT
  1638.   case WM_SETFONT                       : messageName = "WM_SETFONT";           break; //0x0030
  1639. #  endif
  1640.  
  1641. #  ifdef KIT_PM_WM_GETFONT
  1642.   case WM_GETFONT                       : messageName = "WM_GETFONT";           break; //0x0031
  1643. #  endif
  1644.  
  1645. #  ifdef KIT_PM_WM_SETHOTKEY
  1646.   case WM_SETHOTKEY                     : messageName = "WM_SETHOTKEY";         break; //0x0032
  1647. #  endif
  1648.  
  1649. #  ifdef KIT_PM_WM_GETHOTKEY
  1650.   case WM_GETHOTKEY                     : messageName = "WM_GETHOTKEY";         break; //0x0033
  1651. #  endif
  1652.  
  1653. #  ifdef KIT_PM_WM_QUERYDRAGICON
  1654.   case WM_QUERYDRAGICON                 : messageName = "WM_QUERYDRAGICON";     break; //0x0037
  1655. #  endif
  1656.  
  1657. #  ifdef KIT_PM_WM_COMPAREITEM
  1658.   case WM_COMPAREITEM                   : messageName = "WM_COMPAREITEM";       break; //0x0039
  1659. #  endif
  1660.  
  1661.  
  1662. #if(WINVER >= 0x0500)
  1663. #ifndef _WIN32_WCE
  1664. #  ifdef KIT_PM_WM_GETOBJECT
  1665.   case WM_GETOBJECT                     : messageName = "WM_GETOBJECT";         break; //0x003D
  1666. #  endif
  1667. #endif
  1668. #endif /* WINVER >= 0x0500 */
  1669.  
  1670.  
  1671. #  ifdef KIT_PM_WM_COMPACTING
  1672.   case WM_COMPACTING                    : messageName = "WM_COMPACTING";        break; //0x0041
  1673. #  endif
  1674.  
  1675. #  ifdef KIT_PM_WM_COMMNOTIFY
  1676.   case WM_COMMNOTIFY                    : messageName = "WM_COMMNOTIFY";        break; //0x0044
  1677. #  endif
  1678.  
  1679. #  ifdef KIT_PM_WM_WINDOWPOSCHANGING
  1680.   case WM_WINDOWPOSCHANGING             : messageName = "WM_WINDOWPOSCHANGING"; break; //0x0046
  1681. #  endif
  1682.  
  1683. #  ifdef KIT_PM_WM_WINDOWPOSCHANGED
  1684.   case WM_WINDOWPOSCHANGED              : messageName = "WM_WINDOWPOSCHANGED";  break; //0x0047
  1685. #  endif
  1686.  
  1687. #  ifdef KIT_PM_WM_POWER
  1688.   case WM_POWER                         : messageName = "WM_POWER";             break; //0x0048
  1689. #  endif
  1690.  
  1691. #  ifdef KIT_PM_WM_COPYDATA
  1692.   case WM_COPYDATA                      : messageName = "WM_COPYDATA";          break; //0x004A
  1693. #  endif
  1694.  
  1695. #  ifdef KIT_PM_WM_CANCELJOURNAL
  1696.   case WM_CANCELJOURNAL                 : messageName = "WM_CANCELJOURNAL";     break; //0x004B
  1697. #  endif
  1698.  
  1699.  
  1700. #if(WINVER >= 0x0400)
  1701. #  ifdef KIT_PM_WM_NOTIFY
  1702.   case WM_NOTIFY                        : messageName = "WM_NOTIFY";            break; //0x004E
  1703. #  endif
  1704.  
  1705. #  ifdef KIT_PM_WM_INPUTLANGCHANGEREQUEST
  1706.   case WM_INPUTLANGCHANGEREQUEST        : messageName = "WM_INPUTLANGCHANGEREQUEST"; break; //0x0050
  1707. #  endif
  1708.  
  1709. #  ifdef KIT_PM_WM_INPUTLANGCHANGE
  1710.   case WM_INPUTLANGCHANGE               : messageName = "WM_INPUTLANGCHANGE";   break; //0x0051
  1711. #  endif
  1712.  
  1713. #  ifdef KIT_PM_WM_TCARD
  1714.   case WM_TCARD                         : messageName = "WM_TCARD";             break; //0x0052
  1715. #  endif
  1716.  
  1717. #  ifdef KIT_PM_WM_HELP
  1718.   case WM_HELP                          : messageName = "WM_HELP";              break; //0x0053
  1719. #  endif
  1720.  
  1721. #  ifdef KIT_PM_WM_USERCHANGED
  1722.   case WM_USERCHANGED                   : messageName = "WM_USERCHANGED";       break; //0x0054
  1723. #  endif
  1724.  
  1725. #  ifdef KIT_PM_WM_NOTIFYFORMAT
  1726.   case WM_NOTIFYFORMAT                  : messageName = "WM_NOTIFYFORMAT";      break; //0x0055
  1727. #  endif
  1728.  
  1729. #  ifdef KIT_PM_WM_CONTEXTMENU
  1730.   case WM_CONTEXTMENU                   : messageName = "WM_CONTEXTMENU";       break; //0x007B
  1731. #  endif
  1732.  
  1733. #  ifdef KIT_PM_WM_STYLECHANGING
  1734.   case WM_STYLECHANGING                 : messageName = "WM_STYLECHANGING";     break; //0x007C
  1735. #  endif
  1736.  
  1737. #  ifdef KIT_PM_WM_STYLECHANGED
  1738.   case WM_STYLECHANGED                  : messageName = "WM_STYLECHANGED";      break; //0x007D
  1739. #  endif
  1740.  
  1741. #  ifdef KIT_PM_WM_DISPLAYCHANGE
  1742.   case WM_DISPLAYCHANGE                 : messageName = "WM_DISPLAYCHANGE";     break; //0x007E
  1743. #  endif
  1744.  
  1745. #  ifdef KIT_PM_WM_GETICON
  1746.   case WM_GETICON                       : messageName = "WM_GETICON";           break; //0x007F
  1747. #  endif
  1748.  
  1749. #  ifdef KIT_PM_WM_SETICON
  1750.   case WM_SETICON                       : messageName = "WM_SETICON";           break; //0x0080
  1751. #  endif
  1752. #endif /* WINVER >= 0x0400 */
  1753.  
  1754.  
  1755. #  ifdef KIT_PM_WM_NCCREATE
  1756.   case WM_NCCREATE                      : messageName = "WM_NCCREATE";          break; //0x0081
  1757. #  endif
  1758.  
  1759. #  ifdef KIT_PM_WM_NCDESTROY
  1760.   case WM_NCDESTROY                     : messageName = "WM_NCDESTROY";         break; //0x0082
  1761. #  endif
  1762.  
  1763. #  ifdef KIT_PM_WM_NCCALCSIZE
  1764.   case WM_NCCALCSIZE                    : messageName = "WM_NCCALCSIZE";        break; //0x0083
  1765. #  endif
  1766.  
  1767. #  ifdef KIT_PM_WM_NCHITTEST
  1768.   case WM_NCHITTEST                     : messageName = "WM_NCHITTEST";         break; //0x0084
  1769. #  endif
  1770.  
  1771. #  ifdef KIT_PM_WM_NCPAINT
  1772.   case WM_NCPAINT                       : messageName = "WM_NCPAINT";           break; //0x0085
  1773. #  endif
  1774.  
  1775. #  ifdef KIT_PM_WM_NCACTIVATE
  1776.   case WM_NCACTIVATE                    : messageName = "WM_NCACTIVATE";        break; //0x0086
  1777. #  endif
  1778.  
  1779. #  ifdef KIT_PM_WM_GETDLGCODE
  1780.   case WM_GETDLGCODE                    : messageName = "WM_GETDLGCODE";        break; //0x0087
  1781. #  endif
  1782.  
  1783.  
  1784. #ifndef _WIN32_WCE
  1785. #  ifdef KIT_PM_WM_SYNCPAINT
  1786.   case WM_SYNCPAINT                     : messageName = "WM_SYNCPAINT";         break; //0x0088
  1787. #  endif
  1788. #endif
  1789.  
  1790.  
  1791. #  ifdef KIT_PM_WM_NCMOUSEMOVE
  1792.   case WM_NCMOUSEMOVE                   : messageName = "WM_NCMOUSEMOVE";       break; //0x00A0
  1793. #  endif
  1794.  
  1795. #  ifdef KIT_PM_WM_NCLBUTTONDOWN
  1796.   case WM_NCLBUTTONDOWN                 : messageName = "WM_NCLBUTTONDOWN";     break; //0x00A1
  1797. #  endif
  1798.  
  1799. #  ifdef KIT_PM_WM_NCLBUTTONUP
  1800.   case WM_NCLBUTTONUP                   : messageName = "WM_NCLBUTTONUP";       break; //0x00A2
  1801. #  endif
  1802.  
  1803. #  ifdef KIT_PM_WM_NCLBUTTONDBLCLK
  1804.   case WM_NCLBUTTONDBLCLK               : messageName = "WM_NCLBUTTONDBLCLK";   break; //0x00A3
  1805. #  endif
  1806.  
  1807. #  ifdef KIT_PM_WM_NCRBUTTONDOWN
  1808.   case WM_NCRBUTTONDOWN                 : messageName = "WM_NCRBUTTONDOWN";     break; //0x00A4
  1809. #  endif
  1810.  
  1811. #  ifdef KIT_PM_WM_NCRBUTTONUP
  1812.   case WM_NCRBUTTONUP                   : messageName = "WM_NCRBUTTONUP";       break; //0x00A5
  1813. #  endif
  1814.  
  1815. #  ifdef KIT_PM_WM_NCRBUTTONDBLCLK
  1816.   case WM_NCRBUTTONDBLCLK               : messageName = "WM_NCRBUTTONDBLCLK";   break; //0x00A6
  1817. #  endif
  1818.  
  1819. #  ifdef KIT_PM_WM_NCMBUTTONDOWN
  1820.   case WM_NCMBUTTONDOWN                 : messageName = "WM_NCMBUTTONDOWN";     break; //0x00A7
  1821. #  endif
  1822.  
  1823. #  ifdef KIT_PM_WM_NCMBUTTONUP
  1824.   case WM_NCMBUTTONUP                   : messageName = "WM_NCMBUTTONUP";       break; //0x00A8
  1825. #  endif
  1826.  
  1827. #  ifdef KIT_PM_WM_NCMBUTTONDBLCLK
  1828.   case WM_NCMBUTTONDBLCLK               : messageName = "WM_NCMBUTTONDBLCLK";   break; //0x00A9
  1829. #  endif
  1830.  
  1831.  
  1832. #if(_WIN32_WINNT >= 0x0500)
  1833. #  ifdef KIT_PM_WM_NCXBUTTONDOWN
  1834.   case WM_NCXBUTTONDOWN                 : messageName = "WM_NCXBUTTONDOWN";     break; //0x00AB
  1835. #  endif
  1836.  
  1837. #  ifdef KIT_PM_WM_NCXBUTTONUP
  1838.   case WM_NCXBUTTONUP                   : messageName = "WM_NCXBUTTONUP";       break; //0x00AC
  1839. #  endif
  1840.  
  1841. #  ifdef KIT_PM_WM_NCXBUTTONDBLCLK
  1842.   case WM_NCXBUTTONDBLCLK               : messageName = "WM_NCXBUTTONDBLCLK";   break; //0x00AD
  1843. #  endif
  1844. #endif /* _WIN32_WINNT >= 0x0500 */
  1845.  
  1846.  
  1847. #if(_WIN32_WINNT >= 0x0501)
  1848. #  ifdef KIT_PM_WM_INPUT_DEVICE_CHANGE
  1849.   case WM_INPUT_DEVICE_CHANGE           : messageName = "WM_INPUT_DEVICE_CHANGE"; break; //0x00FE
  1850. #  endif
  1851.  
  1852. #  ifdef KIT_PM_WM_INPUT
  1853.   case WM_INPUT                         : messageName = "WM_INPUT";             break; //0x00FF
  1854. #  endif
  1855. #endif /* _WIN32_WINNT >= 0x0501 */
  1856.  
  1857.  
  1858. #  ifdef KIT_PM_WM_KEYDOWN
  1859.   case WM_KEYDOWN                       : messageName = "WM_KEYDOWN";           break; //0x0100
  1860. #  endif
  1861.  
  1862. #  ifdef KIT_PM_WM_KEYUP
  1863.   case WM_KEYUP                         : messageName = "WM_KEYUP";             break; //0x0101
  1864. #  endif
  1865.  
  1866. #  ifdef KIT_PM_WM_CHAR
  1867.   case WM_CHAR                          : messageName = "WM_CHAR";              break; //0x0102
  1868. #  endif
  1869.  
  1870. #  ifdef KIT_PM_WM_DEADCHAR
  1871.   case WM_DEADCHAR                      : messageName = "WM_DEADCHAR";          break; //0x0103
  1872. #  endif
  1873.  
  1874. #  ifdef KIT_PM_WM_SYSKEYDOWN
  1875.   case WM_SYSKEYDOWN                    : messageName = "WM_SYSKEYDOWN";        break; //0x0104
  1876. #  endif
  1877.  
  1878. #  ifdef KIT_PM_WM_SYSKEYUP
  1879.   case WM_SYSKEYUP                      : messageName = "WM_SYSKEYUP";          break; //0x0105
  1880. #  endif
  1881.  
  1882. #  ifdef KIT_PM_WM_SYSCHAR
  1883.   case WM_SYSCHAR                       : messageName = "WM_SYSCHAR";           break; //0x0106
  1884. #  endif
  1885.  
  1886. #  ifdef KIT_PM_WM_SYSDEADCHAR
  1887.   case WM_SYSDEADCHAR                   : messageName = "WM_SYSDEADCHAR";       break; //0x0107
  1888. #  endif
  1889.  
  1890.  
  1891. #if(_WIN32_WINNT >= 0x0501)
  1892. #  ifdef KIT_PM_WM_UNICHAR
  1893.   case WM_UNICHAR                       : messageName = "WM_UNICHAR";           break; //0x0109
  1894. #  endif
  1895. #endif /* _WIN32_WINNT >= 0x0501 */
  1896.  
  1897.  
  1898. #if(WINVER >= 0x0400)
  1899. #  ifdef KIT_PM_WM_IME_STARTCOMPOSITION
  1900.   case WM_IME_STARTCOMPOSITION          : messageName = "WM_IME_STARTCOMPOSITION"; break; //0x010D
  1901. #  endif
  1902.  
  1903. #  ifdef KIT_PM_WM_IME_ENDCOMPOSITION
  1904.   case WM_IME_ENDCOMPOSITION            : messageName = "WM_IME_ENDCOMPOSITION";   break; //0x010E
  1905. #  endif
  1906.  
  1907. #  ifdef KIT_PM_WM_IME_COMPOSITION
  1908.   case WM_IME_COMPOSITION               : messageName = "WM_IME_COMPOSITION";      break; //0x010F
  1909. #  endif
  1910. #endif /* WINVER >= 0x0400 */
  1911.  
  1912.  
  1913. #  ifdef KIT_PM_WM_INITDIALOG
  1914.   case WM_INITDIALOG                    : messageName = "WM_INITDIALOG";        break; //0x0110
  1915. #  endif
  1916.  
  1917. #  ifdef KIT_PM_WM_COMMAND
  1918.   case WM_COMMAND                       : messageName = "WM_COMMAND";           break; //0x0111
  1919. #  endif
  1920.  
  1921. #  ifdef KIT_PM_WM_SYSCOMMAND
  1922.   case WM_SYSCOMMAND                    : messageName = "WM_SYSCOMMAND";        break; //0x0112
  1923. #  endif
  1924.  
  1925. #  ifdef KIT_PM_WM_TIMER
  1926.   case WM_TIMER                         : messageName = "WM_TIMER";             break; //0x0113
  1927. #  endif
  1928.  
  1929. #  ifdef KIT_PM_WM_HSCROLL
  1930.   case WM_HSCROLL                       : messageName = "WM_HSCROLL";           break; //0x0114
  1931. #  endif
  1932.  
  1933. #  ifdef KIT_PM_WM_VSCROLL
  1934.   case WM_VSCROLL                       : messageName = "WM_VSCROLL";           break; //0x0115
  1935. #  endif
  1936.  
  1937. #  ifdef KIT_PM_WM_INITMENU
  1938.   case WM_INITMENU                      : messageName = "WM_INITMENU";          break; //0x0116
  1939. #  endif
  1940.  
  1941. #  ifdef KIT_PM_WM_INITMENUPOPUP
  1942.   case WM_INITMENUPOPUP                 : messageName = "WM_INITMENUPOPUP";     break; //0x0117
  1943. #  endif
  1944.  
  1945.  
  1946. #if(WINVER >= 0x0601)
  1947. #  ifdef KIT_PM_WM_GESTURE
  1948.   case WM_GESTURE                       : messageName = "WM_GESTURE";           break; //0x0119
  1949. #  endif
  1950.  
  1951. #  ifdef KIT_PM_WM_GESTURENOTIFY
  1952.   case WM_GESTURENOTIFY                 : messageName = "WM_GESTURENOTIFY";     break; //0x011A
  1953. #  endif
  1954. #endif /* WINVER >= 0x0601 */
  1955.  
  1956.  
  1957. #  ifdef KIT_PM_WM_MENUSELECT
  1958.   case WM_MENUSELECT                    : messageName = "WM_MENUSELECT";        break; //0x011F
  1959. #  endif
  1960.  
  1961. #  ifdef KIT_PM_WM_MENUCHAR
  1962.   case WM_MENUCHAR                      : messageName = "WM_MENUCHAR";          break; //0x0120
  1963. #  endif
  1964.  
  1965. #  ifdef KIT_PM_WM_ENTERIDLE
  1966.   case WM_ENTERIDLE                     : messageName = "WM_ENTERIDLE";         break; //0x0121
  1967. #  endif
  1968.  
  1969.  
  1970. /* WHY IS THIS SET UP THIS WAY! */
  1971. #if(WINVER >= 0x0500)
  1972. #ifndef _WIN32_WCE
  1973. #  ifdef KIT_PM_WM_MENURBUTTONUP
  1974.   case WM_MENURBUTTONUP                 : messageName = "WM_MENURBUTTONUP";     break; //0x0122
  1975. #  endif
  1976.  
  1977. #  ifdef KIT_PM_WM_MENUDRAG
  1978.   case WM_MENUDRAG                      : messageName = "WM_MENUDRAG";          break; //0x0123
  1979. #  endif
  1980.  
  1981. #  ifdef KIT_PM_WM_MENUGETOBJECT
  1982.   case WM_MENUGETOBJECT                 : messageName = "WM_MENUGETOBJECT";     break; //0x0124
  1983. #  endif
  1984.  
  1985. #  ifdef KIT_PM_WM_UNINITMENUPOPUP
  1986.   case WM_UNINITMENUPOPUP               : messageName = "WM_UNINITMENUPOPUP";   break; //0x0125
  1987. #  endif
  1988.  
  1989. #  ifdef KIT_PM_WM_MENUCOMMAND
  1990.   case WM_MENUCOMMAND                   : messageName = "WM_MENUCOMMAND";       break; //0x0126
  1991. #  endif
  1992. #ifndef _WIN32_WCE
  1993. #if(_WIN32_WINNT >= 0x0500)
  1994. #  ifdef KIT_PM_WM_CHANGEUISTATE
  1995.   case WM_CHANGEUISTATE                 : messageName = "WM_CHANGEUISTATE";     break; //0x0127
  1996. #  endif
  1997.  
  1998. #  ifdef KIT_PM_WM_UPDATEUISTATE
  1999.   case WM_UPDATEUISTATE                 : messageName = "WM_UPDATEUISTATE";     break; //0x0128
  2000. #  endif
  2001.  
  2002. #  ifdef KIT_PM_WM_QUERYUISTATE
  2003.   case WM_QUERYUISTATE                  : messageName = "WM_QUERYUISTATE";      break; //0x0129
  2004. #  endif
  2005. #endif /* _WIN32_WINNT >= 0x0500 */
  2006. #endif
  2007.  
  2008. #endif
  2009. #endif /* WINVER >= 0x0500 */
  2010. /* WHY IS THIS SET UP THIS WAY! */
  2011.  
  2012.  
  2013.  
  2014. #  ifdef KIT_PM_WM_CTLCOLORMSGBOX
  2015.   case WM_CTLCOLORMSGBOX                : messageName = "WM_CTLCOLORMSGBOX";    break; //0x0132
  2016. #  endif
  2017.  
  2018. #  ifdef KIT_PM_WM_CTLCOLOREDIT
  2019.   case WM_CTLCOLOREDIT                  : messageName = "WM_CTLCOLOREDIT";      break; //0x0133
  2020. #  endif
  2021.  
  2022. #  ifdef KIT_PM_WM_CTLCOLORLISTBOX
  2023.   case WM_CTLCOLORLISTBOX               : messageName = "WM_CTLCOLORLISTBOX";   break; //0x0134
  2024. #  endif
  2025.  
  2026. #  ifdef KIT_PM_WM_CTLCOLORBTN
  2027.   case WM_CTLCOLORBTN                   : messageName = "WM_CTLCOLORBTN";       break; //0x0135
  2028. #  endif
  2029.  
  2030. #  ifdef KIT_PM_WM_CTLCOLORDLG
  2031.   case WM_CTLCOLORDLG                   : messageName = "WM_CTLCOLORDLG";       break; //0x0136
  2032. #  endif
  2033.  
  2034. #  ifdef KIT_PM_WM_CTLCOLORSCROLLBAR
  2035.   case WM_CTLCOLORSCROLLBAR             : messageName = "WM_CTLCOLORSCROLLBAR"; break; //0x0137
  2036. #  endif
  2037.  
  2038. #  ifdef KIT_PM_WM_CTLCOLORSTATIC
  2039.   case WM_CTLCOLORSTATIC                : messageName = "WM_CTLCOLORSTATIC";    break; //0x0138
  2040. #  endif
  2041.  
  2042. #  ifdef KIT_PM_MN_GETHMENU
  2043.   case MN_GETHMENU                      : messageName = "MN_GETHMENU";          break; //0x01E1
  2044. #  endif
  2045.  
  2046. #  ifdef KIT_PM_WM_MOUSEMOVE
  2047.   case WM_MOUSEMOVE                     : messageName = "WM_MOUSEMOVE";         break; //0x0200
  2048. #  endif
  2049.  
  2050. #  ifdef KIT_PM_WM_LBUTTONDOWN
  2051.   case WM_LBUTTONDOWN                   : messageName = "WM_LBUTTONDOWN";       break; //0x0201
  2052. #  endif
  2053.  
  2054. #  ifdef KIT_PM_WM_LBUTTONUP
  2055.   case WM_LBUTTONUP                     : messageName = "WM_LBUTTONUP";         break; //0x0202
  2056. #  endif
  2057.  
  2058. #  ifdef KIT_PM_WM_LBUTTONDBLCLK
  2059.   case WM_LBUTTONDBLCLK                 : messageName = "WM_LBUTTONDBLCLK";     break; //0x0203
  2060. #  endif
  2061.  
  2062. #  ifdef KIT_PM_WM_RBUTTONDOWN
  2063.   case WM_RBUTTONDOWN                   : messageName = "WM_RBUTTONDOWN";       break; //0x0204
  2064. #  endif
  2065.  
  2066. #  ifdef KIT_PM_WM_RBUTTONUP
  2067.   case WM_RBUTTONUP                     : messageName = "WM_RBUTTONUP";         break; //0x0205
  2068. #  endif
  2069.  
  2070. #  ifdef KIT_PM_WM_RBUTTONDBLCLK
  2071.   case WM_RBUTTONDBLCLK                 : messageName = "WM_RBUTTONDBLCLK";     break; //0x0206
  2072. #  endif
  2073.  
  2074. #  ifdef KIT_PM_WM_MBUTTONDOWN
  2075.   case WM_MBUTTONDOWN                   : messageName = "WM_MBUTTONDOWN";       break; //0x0207
  2076. #  endif
  2077.  
  2078. #  ifdef KIT_PM_WM_MBUTTONUP
  2079.   case WM_MBUTTONUP                     : messageName = "WM_MBUTTONUP";         break; //0x0208
  2080. #  endif
  2081.  
  2082. #  ifdef KIT_PM_WM_MBUTTONDBLCLK
  2083.   case WM_MBUTTONDBLCLK                 : messageName = "WM_MBUTTONDBLCLK";     break; //0x0209
  2084. #  endif
  2085.  
  2086.  
  2087. #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
  2088. #  ifdef KIT_PM_WM_MOUSEWHEEL
  2089.   case WM_MOUSEWHEEL                    : messageName = "WM_MOUSEWHEEL";        break; //0x020A
  2090. #  endif
  2091. #endif
  2092.  
  2093.  
  2094. #if (_WIN32_WINNT >= 0x0500)
  2095. #  ifdef KIT_PM_WM_XBUTTONDOWN
  2096.   case WM_XBUTTONDOWN                   : messageName = "WM_XBUTTONDOWN";       break; //0x020B
  2097. #  endif
  2098.  
  2099. #  ifdef KIT_PM_WM_XBUTTONUP
  2100.   case WM_XBUTTONUP                     : messageName = "WM_XBUTTONUP";         break; //0x020C
  2101. #  endif
  2102.  
  2103. #  ifdef KIT_PM_WM_XBUTTONDBLCLK
  2104.   case WM_XBUTTONDBLCLK                 : messageName = "WM_XBUTTONDBLCLK";     break; //0x020D
  2105. #  endif
  2106. #endif
  2107.  
  2108.  
  2109. #  ifdef KIT_PM_WM_PARENTNOTIFY
  2110.   case WM_PARENTNOTIFY                  : messageName = "WM_PARENTNOTIFY";      break; //0x0210
  2111. #  endif
  2112.  
  2113. #  ifdef KIT_PM_WM_ENTERMENULOOP
  2114.   case WM_ENTERMENULOOP                 : messageName = "WM_ENTERMENULOOP";     break; //0x0211
  2115. #  endif
  2116.  
  2117. #  ifdef KIT_PM_WM_EXITMENULOOP
  2118.   case WM_EXITMENULOOP                  : messageName = "WM_EXITMENULOOP";      break; //0x0212
  2119. #  endif
  2120.  
  2121.  
  2122. #if(WINVER >= 0x0400)
  2123. #  ifdef KIT_PM_WM_NEXTMENU
  2124.   case WM_NEXTMENU                      : messageName = "WM_NEXTMENU";          break; //0x0213
  2125. #  endif
  2126.  
  2127. #  ifdef KIT_PM_WM_SIZING
  2128.   case WM_SIZING                        : messageName = "WM_SIZING";            break; //0x0214
  2129. #  endif
  2130.  
  2131. #  ifdef KIT_PM_WM_CAPTURECHANGED
  2132.   case WM_CAPTURECHANGED                : messageName = "WM_CAPTURECHANGED";    break; //0x0215
  2133. #  endif
  2134.  
  2135. #  ifdef KIT_PM_WM_MOVING
  2136.   case WM_MOVING                        : messageName = "WM_MOVING";            break; //0x0216
  2137. #  endif
  2138.  
  2139. #  ifdef KIT_PM_WM_POWERBROADCAST
  2140.   case WM_POWERBROADCAST                : messageName = "WM_POWERBROADCAST";    break; //0x0218
  2141. #  endif
  2142.  
  2143. #  ifdef KIT_PM_WM_DEVICECHANGE
  2144.   case WM_DEVICECHANGE                  : messageName = "WM_DEVICECHANGE";      break; //0x0219
  2145. #  endif
  2146. #endif /* WINVER >= 0x0400 */
  2147.  
  2148.  
  2149. #  ifdef KIT_PM_WM_MDICREATE
  2150.   case WM_MDICREATE                     : messageName = "WM_MDICREATE";         break; //0x0220
  2151. #  endif
  2152.  
  2153. #  ifdef KIT_PM_WM_MDIDESTROY
  2154.   case WM_MDIDESTROY                    : messageName = "WM_MDIDESTROY";        break; //0x0221
  2155. #  endif
  2156.  
  2157. #  ifdef KIT_PM_WM_MDIACTIVATE
  2158.   case WM_MDIACTIVATE                   : messageName = "WM_MDIACTIVATE";       break; //0x0222
  2159. #  endif
  2160.  
  2161. #  ifdef KIT_PM_WM_MDIRESTORE
  2162.   case WM_MDIRESTORE                    : messageName = "WM_MDIRESTORE";        break; //0x0223
  2163. #  endif
  2164.  
  2165. #  ifdef KIT_PM_WM_MDINEXT
  2166.   case WM_MDINEXT                       : messageName = "WM_MDINEXT";           break; //0x0224
  2167. #  endif
  2168.  
  2169. #  ifdef KIT_PM_WM_MDIMAXIMIZE
  2170.   case WM_MDIMAXIMIZE                   : messageName = "WM_MDIMAXIMIZE";       break; //0x0225
  2171. #  endif
  2172.  
  2173. #  ifdef KIT_PM_WM_MDITILE
  2174.   case WM_MDITILE                       : messageName = "WM_MDITILE";           break; //0x0226
  2175. #  endif
  2176.  
  2177. #  ifdef KIT_PM_WM_MDICASCADE
  2178.   case WM_MDICASCADE                    : messageName = "WM_MDICASCADE";        break; //0x0227
  2179. #  endif
  2180.  
  2181. #  ifdef KIT_PM_WM_MDIICONARRANGE
  2182.   case WM_MDIICONARRANGE                : messageName = "WM_MDIICONARRANGE";    break; //0x0228
  2183. #  endif
  2184.  
  2185. #  ifdef KIT_PM_WM_MDIGETACTIVE
  2186.   case WM_MDIGETACTIVE                  : messageName = "WM_MDIGETACTIVE";      break; //0x0229
  2187. #  endif
  2188.  
  2189. #  ifdef KIT_PM_WM_MDISETMENU
  2190.   case WM_MDISETMENU                    : messageName = "WM_MDISETMENU";        break; //0x0230
  2191. #  endif
  2192.  
  2193. #  ifdef KIT_PM_WM_ENTERSIZEMOVE
  2194.   case WM_ENTERSIZEMOVE                 : messageName = "WM_ENTERSIZEMOVE";     break; //0x0231
  2195. #  endif
  2196.  
  2197. #  ifdef KIT_PM_WM_EXITSIZEMOVE
  2198.   case WM_EXITSIZEMOVE                  : messageName = "WM_EXITSIZEMOVE";      break; //0x0232
  2199. #  endif
  2200.  
  2201. #  ifdef KIT_PM_WM_DROPFILES
  2202.   case WM_DROPFILES                     : messageName = "WM_DROPFILES";         break; //0x0233
  2203. #  endif
  2204.  
  2205. #  ifdef KIT_PM_WM_MDIREFRESHMENU
  2206.   case WM_MDIREFRESHMENU                : messageName = "WM_MDIREFRESHMENU";    break; //0x0234
  2207. #  endif
  2208.  
  2209.  
  2210. #if(WINVER >= 0x0602)
  2211. #  ifdef KIT_PM_WM_POINTERDEVICECHANGE
  2212.   case WM_POINTERDEVICECHANGE           : messageName = "WM_POINTERDEVICECHANGE";     break; //0x0238
  2213. #  endif
  2214.  
  2215. #  ifdef KIT_PM_WM_POINTERDEVICEINRANGE
  2216.   case WM_POINTERDEVICEINRANGE          : messageName = "WM_POINTERDEVICEINRANGE";    break; //0x0239
  2217. #  endif
  2218.  
  2219. #  ifdef KIT_PM_WM_POINTERDEVICEOUTOFRANGE
  2220.   case WM_POINTERDEVICEOUTOFRANGE       : messageName = "WM_POINTERDEVICEOUTOFRANGE"; break; //0x023A
  2221. #  endif
  2222. #endif /* WINVER >= 0x0602 */
  2223.  
  2224.  
  2225. #if(WINVER >= 0x0601)
  2226. #  ifdef KIT_PM_WM_TOUCH
  2227.   case WM_TOUCH                         : messageName = "WM_TOUCH";             break; //0x0240
  2228. #  endif
  2229. #endif /* WINVER >= 0x0601 */
  2230.  
  2231.  
  2232. #if(WINVER >= 0x0602)
  2233. #  ifdef KIT_PM_WM_NCPOINTERUPDATE
  2234.   case WM_NCPOINTERUPDATE               : messageName = "WM_NCPOINTERUPDATE";   break; //0x0241
  2235. #  endif
  2236.  
  2237. #  ifdef KIT_PM_WM_NCPOINTERDOWN
  2238.   case WM_NCPOINTERDOWN                 : messageName = "WM_NCPOINTERDOWN";     break; //0x0242
  2239. #  endif
  2240.  
  2241. #  ifdef KIT_PM_WM_NCPOINTERUP
  2242.   case WM_NCPOINTERUP                   : messageName = "WM_NCPOINTERUP";       break; //0x0243
  2243. #  endif
  2244.  
  2245. #  ifdef KIT_PM_WM_POINTERUPDATE
  2246.   case WM_POINTERUPDATE                 : messageName = "WM_POINTERUPDATE";     break; //0x0245
  2247. #  endif
  2248.  
  2249. #  ifdef KIT_PM_WM_POINTERDOWN
  2250.   case WM_POINTERDOWN                   : messageName = "WM_POINTERDOWN";       break; //0x0246
  2251. #  endif
  2252.  
  2253. #  ifdef KIT_PM_WM_POINTERUP
  2254.   case WM_POINTERUP                     : messageName = "WM_POINTERUP";         break; //0x0247
  2255. #  endif
  2256.  
  2257. #  ifdef KIT_PM_WM_POINTERENTER
  2258.   case WM_POINTERENTER                  : messageName = "WM_POINTERENTER";      break; //0x0249
  2259. #  endif
  2260.  
  2261. #  ifdef KIT_PM_WM_POINTERLEAVE
  2262.   case WM_POINTERLEAVE                  : messageName = "WM_POINTERLEAVE";      break; //0x024A
  2263. #  endif
  2264.  
  2265. #  ifdef KIT_PM_WM_POINTERACTIVATE
  2266.   case WM_POINTERACTIVATE               : messageName = "WM_POINTERACTIVATE";   break; //0x024B
  2267. #  endif
  2268.  
  2269. #  ifdef KIT_PM_WM_POINTERCAPTURECHANGED
  2270.   case WM_POINTERCAPTURECHANGED         : messageName = "WM_POINTERCAPTURECHANGED"; break; //0x024C
  2271. #  endif
  2272.  
  2273. #  ifdef KIT_PM_WM_TOUCHHITTESTING
  2274.   case WM_TOUCHHITTESTING               : messageName = "WM_TOUCHHITTESTING";   break; //0x024D
  2275. #  endif
  2276.  
  2277. #  ifdef KIT_PM_WM_POINTERWHEEL
  2278.   case WM_POINTERWHEEL                  : messageName = "WM_POINTERWHEEL";      break; //0x024E
  2279. #  endif
  2280.  
  2281. #  ifdef KIT_PM_WM_POINTERHWHEEL
  2282.   case WM_POINTERHWHEEL                 : messageName = "WM_POINTERHWHEEL";     break; //0x024F
  2283. #  endif
  2284.  
  2285. #  ifdef KIT_PM_DM_POINTERHITTEST
  2286.   case DM_POINTERHITTEST                : messageName = "DM_POINTERHITTEST";    break; //0x0250
  2287. #  endif
  2288.  
  2289. #  ifdef KIT_PM_WM_POINTERROUTEDTO
  2290.   case WM_POINTERROUTEDTO               : messageName = "WM_POINTERROUTEDTO";   break; //0x0251
  2291. #  endif
  2292.  
  2293. #  ifdef KIT_PM_WM_POINTERROUTEDAWAY
  2294.   case WM_POINTERROUTEDAWAY             : messageName = "WM_POINTERROUTEDAWAY"; break; //0x0252
  2295. #  endif
  2296.  
  2297. #  ifdef KIT_PM_WM_POINTERROUTEDRELEASED2
  2298.   case WM_POINTERROUTEDRELEASED         : messageName = "WM_POINTERROUTEDRELEASED"; break; //0x0253
  2299. #  endif
  2300. #endif /* WINVER >= 0x0602 */
  2301.  
  2302.  
  2303. #if(WINVER >= 0x0400)
  2304. #  ifdef KIT_PM_WM_IME_SETCONTEXT
  2305.   case WM_IME_SETCONTEXT                : messageName = "WM_IME_SETCONTEXT";    break; //0x0281
  2306. #  endif
  2307.  
  2308. #  ifdef KIT_PM_WM_IME_NOTIFY
  2309.   case WM_IME_NOTIFY                    : messageName = "WM_IME_NOTIFY";        break; //0x0282
  2310. #  endif
  2311.  
  2312. #  ifdef KIT_PM_WM_IME_CONTROL
  2313.   case WM_IME_CONTROL                   : messageName = "WM_IME_CONTROL";       break; //0x0283
  2314. #  endif
  2315.  
  2316. #  ifdef KIT_PM_WM_IME_COMPOSITIONFULL
  2317.   case WM_IME_COMPOSITIONFULL           : messageName = "WM_IME_COMPOSITIONFULL"; break; //0x0284
  2318. #  endif
  2319.  
  2320. #  ifdef KIT_PM_WM_IME_SELECT
  2321.   case WM_IME_SELECT                    : messageName = "WM_IME_SELECT";        break; //0x0285
  2322. #  endif
  2323.  
  2324. #  ifdef KIT_PM_WM_IME_CHAR
  2325.   case WM_IME_CHAR                      : messageName = "WM_IME_CHAR";          break; //0x0286
  2326. #  endif
  2327. #endif /* WINVER >= 0x0400 */
  2328.  
  2329.  
  2330. #if(WINVER >= 0x0500)
  2331. #  ifdef KIT_PM_WM_IME_REQUEST
  2332.   case WM_IME_REQUEST                   : messageName = "WM_IME_REQUEST";       break; //0x0288
  2333. #  endif
  2334. #endif /* WINVER >= 0x0500 */
  2335.  
  2336.  
  2337. #if(WINVER >= 0x0400)
  2338. #  ifdef KIT_PM_WM_IME_KEYDOWN
  2339.   case WM_IME_KEYDOWN                   : messageName = "WM_IME_KEYDOWN";       break; //0x0290
  2340. #  endif
  2341.  
  2342. #  ifdef KIT_PM_WM_IME_KEYUP
  2343.   case WM_IME_KEYUP                     : messageName = "WM_IME_KEYUP";         break; //0x0291
  2344. #  endif
  2345. #endif /* WINVER >= 0x0400 */
  2346.  
  2347.  
  2348. #if((_WIN32_WINNT >= 0x0400) || (WINVER >= 0x0500))
  2349. #  ifdef KIT_PM_WM_MOUSEHOVER
  2350.   case WM_MOUSEHOVER                    : messageName = "WM_MOUSEHOVER";        break; //0x02A1
  2351. #  endif
  2352.  
  2353. #  ifdef KIT_PM_WM_MOUSELEAVE
  2354.   case WM_MOUSELEAVE                    : messageName = "WM_MOUSELEAVE";        break; //0x02A3
  2355. #  endif
  2356. #endif
  2357.  
  2358.  
  2359. #if(WINVER >= 0x0500)
  2360. #  ifdef KIT_PM_WM_NCMOUSEHOVER
  2361.   case WM_NCMOUSEHOVER                  : messageName = "WM_NCMOUSEHOVER";      break; //0x02A0
  2362. #  endif
  2363.  
  2364. #  ifdef KIT_PM_WM_NCMOUSELEAVE
  2365.   case WM_NCMOUSELEAVE                  : messageName = "WM_NCMOUSELEAVE";      break; //0x02A2
  2366. #  endif
  2367. #endif /* WINVER >= 0x0500 */
  2368.  
  2369.  
  2370. #if(_WIN32_WINNT >= 0x0501)
  2371. #  ifdef KIT_PM_WM_WTSSESSION_CHANGE
  2372.   case WM_WTSSESSION_CHANGE             : messageName = "WM_WTSSESSION_CHANGE"; break; //0x02B1
  2373. #  endif
  2374. #endif /* _WIN32_WINNT >= 0x0501 */
  2375.  
  2376.  
  2377. #if(WINVER >= 0x0601)
  2378. #  ifdef KIT_PM_WM_DPICHANGED
  2379.   case WM_DPICHANGED                    : messageName = "WM_DPICHANGED";        break; //0x02E0
  2380. #  endif
  2381. #endif /* WINVER >= 0x0601 */
  2382.  
  2383.  
  2384. #if(WINVER >= 0x0605)
  2385. #  ifdef KIT_PM_WM_DPICHANGED_BEFOREPARENT
  2386.   case WM_DPICHANGED_BEFOREPARENT       : messageName = "WM_DPICHANGED_BEFOREPARENT"; break; //0x02E2
  2387. #  endif
  2388.  
  2389. #  ifdef KIT_PM_WM_DPICHANGED_AFTERPARENT
  2390.   case WM_DPICHANGED_AFTERPARENT        : messageName = "WM_DPICHANGED_AFTERPARENT";  break; //0x02E3
  2391. #  endif
  2392.  
  2393. #  ifdef KIT_PM_WM_GETDPISCALEDSIZE
  2394.   case WM_GETDPISCALEDSIZE              : messageName = "WM_GETDPISCALEDSIZE";  break; //0x02E4
  2395. #  endif
  2396. #endif /* WINVER >= 0x0605 */
  2397.  
  2398.  
  2399. #  ifdef KIT_PM_WM_CUT
  2400.   case WM_CUT                           : messageName = "WM_CUT";               break; //0x0300
  2401. #  endif
  2402.  
  2403. #  ifdef KIT_PM_WM_COPY
  2404.   case WM_COPY                          : messageName = "WM_COPY";              break; //0x0301
  2405. #  endif
  2406.  
  2407. #  ifdef KIT_PM_WM_PASTE
  2408.   case WM_PASTE                         : messageName = "WM_PASTE";             break; //0x0302
  2409. #  endif
  2410.  
  2411. #  ifdef KIT_PM_WM_CLEAR
  2412.   case WM_CLEAR                         : messageName = "WM_CLEAR";             break; //0x0303
  2413. #  endif
  2414.  
  2415. #  ifdef KIT_PM_WM_UNDO
  2416.   case WM_UNDO                          : messageName = "WM_UNDO";              break; //0x0304
  2417. #  endif
  2418.  
  2419. #  ifdef KIT_PM_WM_RENDERFORMAT
  2420.   case WM_RENDERFORMAT                  : messageName = "WM_RENDERFORMAT";      break; //0x0305
  2421. #  endif
  2422.  
  2423. #  ifdef KIT_PM_WM_RENDERALLFORMATS
  2424.   case WM_RENDERALLFORMATS              : messageName = "WM_RENDERALLFORMATS";  break; //0x0306
  2425. #  endif
  2426.  
  2427. #  ifdef KIT_PM_WM_DESTROYCLIPBOARD
  2428.   case WM_DESTROYCLIPBOARD              : messageName = "WM_DESTROYCLIPBOARD";  break; //0x0307
  2429. #  endif
  2430.  
  2431. #  ifdef KIT_PM_WM_DRAWCLIPBOARD
  2432.   case WM_DRAWCLIPBOARD                 : messageName = "WM_DRAWCLIPBOARD";     break; //0x0308
  2433. #  endif
  2434.  
  2435. #  ifdef KIT_PM_WM_PAINTCLIPBOARD
  2436.   case WM_PAINTCLIPBOARD                : messageName = "WM_PAINTCLIPBOARD";    break; //0x0309
  2437. #  endif
  2438.  
  2439. #  ifdef KIT_PM_WM_VSCROLLCLIPBOARD
  2440.   case WM_VSCROLLCLIPBOARD              : messageName = "WM_VSCROLLCLIPBOARD";  break; //0x030A
  2441. #  endif
  2442.  
  2443. #  ifdef KIT_PM_WM_SIZECLIPBOARD
  2444.   case WM_SIZECLIPBOARD                 : messageName = "WM_SIZECLIPBOARD";     break; //0x030B
  2445. #  endif
  2446.  
  2447. #  ifdef KIT_PM_WM_ASKCBFORMATNAME
  2448.   case WM_ASKCBFORMATNAME               : messageName = "WM_ASKCBFORMATNAME";   break; //0x030C
  2449. #  endif
  2450.  
  2451. #  ifdef KIT_PM_WM_CHANGECBCHAIN
  2452.   case WM_CHANGECBCHAIN                 : messageName = "WM_CHANGECBCHAIN";     break; //0x030D
  2453. #  endif
  2454.  
  2455. #  ifdef KIT_PM_WM_HSCROLLCLIPBOARD
  2456.   case WM_HSCROLLCLIPBOARD              : messageName = "WM_HSCROLLCLIPBOARD";  break; //0x030E
  2457. #  endif
  2458.  
  2459. #  ifdef KIT_PM_WM_QUERYNEWPALETTE
  2460.   case WM_QUERYNEWPALETTE               : messageName = "WM_QUERYNEWPALETTE";   break; //0x030F
  2461. #  endif
  2462.  
  2463. #  ifdef KIT_PM_WM_PALETTEISCHANGING
  2464.   case WM_PALETTEISCHANGING             : messageName = "WM_PALETTEISCHANGING"; break; //0x0310
  2465. #  endif
  2466.  
  2467. #  ifdef KIT_PM_WM_PALETTECHANGED
  2468.   case WM_PALETTECHANGED                : messageName = "WM_PALETTECHANGED";    break; //0x0311
  2469. #  endif
  2470.  
  2471. #  ifdef KIT_PM_WM_HOTKEY
  2472.   case WM_HOTKEY                        : messageName = "WM_HOTKEY";            break; //0x0312
  2473. #  endif
  2474.  
  2475.  
  2476. #if(WINVER >= 0x0400)
  2477. #  ifdef KIT_PM_WM_PRINT
  2478.   case WM_PRINT                         : messageName = "WM_PRINT";       break; //0x0317
  2479. #  endif
  2480.  
  2481. #  ifdef KIT_PM_WM_PRINTCLIENT
  2482.   case WM_PRINTCLIENT                   : messageName = "WM_PRINTCLIENT"; break; //0x0318
  2483. #  endif
  2484. #endif /* WINVER >= 0x0400 */
  2485.  
  2486.  
  2487. #if(_WIN32_WINNT >= 0x0500)
  2488. #  ifdef KIT_PM_WM_APPCOMMAND
  2489.   case WM_APPCOMMAND                    : messageName = "WM_APPCOMMAND"; break; //0x0319
  2490. #  endif
  2491. #endif /* _WIN32_WINNT >= 0x0500 */
  2492.  
  2493.  
  2494. #if(_WIN32_WINNT >= 0x0501)
  2495. #  ifdef KIT_PM_WM_THEMECHANGED
  2496.   case WM_THEMECHANGED                  : messageName = "WM_THEMECHANGED"; break; //0x031A
  2497. #  endif
  2498. #endif /* _WIN32_WINNT >= 0x0501 */
  2499.  
  2500.  
  2501. #if(_WIN32_WINNT >= 0x0501)
  2502. #  ifdef KIT_PM_WM_CLIPBOARDUPDATE
  2503.   case WM_CLIPBOARDUPDATE               : messageName = "WM_CLIPBOARDUPDATE"; break; //0x031D
  2504. #  endif
  2505. #endif /* _WIN32_WINNT >= 0x0501 */
  2506.  
  2507.  
  2508. #if(_WIN32_WINNT >= 0x0600)
  2509. #  ifdef KIT_PM_WM_DWMCOMPOSITIONCHANGED
  2510.   case WM_DWMCOMPOSITIONCHANGED         : messageName = "WM_DWMCOMPOSITIONCHANGED";       break; //0x031E
  2511. #  endif
  2512.  
  2513. #  ifdef KIT_PM_WM_DWMNCRENDERINGCHANGED
  2514.   case WM_DWMNCRENDERINGCHANGED         : messageName = "WM_DWMNCRENDERINGCHANGED";       break; //0x031F
  2515. #  endif
  2516.  
  2517. #  ifdef KIT_PM_WM_DWMCOLORIZATIONCOLORCHANGED
  2518.   case WM_DWMCOLORIZATIONCOLORCHANGED   : messageName = "WM_DWMCOLORIZATIONCOLORCHANGED"; break; //0x0320
  2519. #  endif
  2520.  
  2521. #  ifdef KIT_PM_WM_DWMWINDOWMAXIMIZEDCHANGE
  2522.   case WM_DWMWINDOWMAXIMIZEDCHANGE      : messageName = "WM_DWMWINDOWMAXIMIZEDCHANGE";    break; //0x0321
  2523. #  endif
  2524. #endif /* _WIN32_WINNT >= 0x0600 */
  2525.  
  2526.  
  2527. #if(_WIN32_WINNT >= 0x0601)
  2528. #  ifdef KIT_PM_WM_DWMSENDICONICTHUMBNAIL
  2529.   case WM_DWMSENDICONICTHUMBNAIL        : messageName = "WM_DWMSENDICONICTHUMBNAIL";         break; //0x0323
  2530. #  endif
  2531.  
  2532. #  ifdef KIT_PM_WM_DWMSENDICONICLIVEPREVIEWBITMAP
  2533.   case WM_DWMSENDICONICLIVEPREVIEWBITMAP: messageName = "WM_DWMSENDICONICLIVEPREVIEWBITMAP"; break; //0x0326
  2534. #  endif
  2535. #endif /* _WIN32_WINNT >= 0x0601 */
  2536.  
  2537.  
  2538. #if(WINVER >= 0x0600)
  2539. #  ifdef KIT_PM_WM_GETTITLEBARINFOEX
  2540.   case WM_GETTITLEBARINFOEX             : messageName = "WM_GETTITLEBARINFOEX"; break; //0x033F
  2541. #  endif
  2542. #endif /* WINVER >= 0x0600 */
  2543.  
  2544.  
  2545.   default:;
  2546. #  ifdef KIT_PM_WM_UNKNOWN
  2547.   messageName = "(unknown)";
  2548. #  endif
  2549.   }
  2550.  
  2551.  
  2552.  
  2553.   if(messageName != nullptr){
  2554.     printf("hwnd=%p, wParam=0x%08X, lParam=%p, msg={ 0x%04X \"%s\" }\n",
  2555.            hwnd, (u32)wParam, (void*)lParam, message, messageName);
  2556.   }
  2557. }
  2558. #endif /* _DEBUG */
  2559.  
  2560.  
  2561. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Window\kit_WindowProc.cpp */
  2562.  
  2563.  
  2564.  
  2565.  
  2566. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Window\kit_Window.cpp */
  2567.  
  2568. #include <kit/_video/Window.hpp>
  2569. #include "_kit_Window.hpp"
  2570.  
  2571. #include <kit/_video/Bitmap.hpp>
  2572. #include "../Bitmap/_kit_Bitmap.hpp"
  2573.  
  2574. #include <string.h> //for strncpy_s
  2575.  
  2576. #define KIT_INVALID_WINDOW _kit_invalid_window
  2577.  
  2578.  
  2579. namespace kit {
  2580.  
  2581. static const char _kit_invalid_window[] = "invalid window";
  2582.  
  2583. namespace w32 {
  2584.   size_t      winCount = 0; //number of existing kit::Window instances
  2585.   const char  winClassName[] = "kit::Window Class";
  2586.   WNDCLASSEXA winClass;
  2587.   ATOM        winClassAtom;
  2588. };
  2589.  
  2590.  
  2591.  
  2592.  
  2593. Window::Window(const char* windowTitle,
  2594.                u32 windowWidth, u32 windowHeight,
  2595.                u32 windowFlags,
  2596.                s32 windowX,     s32 windowY,
  2597.                u32 canvasWidth, u32 canvasHeight)
  2598. {
  2599.   _type = KIT_CLASSTYPE_WINDOW;
  2600.   _opaque = new _WindowOpaque;
  2601.  
  2602.   char* errorText = nullptr;
  2603.   if(0){ //this code block is only entered via goto in the event of an exception
  2604.     //_DestroyWindow  : DestroyWindow(_opaque->winHandle);
  2605.     _DeleteDC       : DeleteDC(_opaque->canvasDevCtx);
  2606.     _UnregisterClass: if(w32::winCount == 0) UnregisterClassA(w32::winClassName, w32::hThisInst);
  2607.     _DelCritSection : DeleteCriticalSection(&_opaque->lock);
  2608.     throw (const char*)errorText;
  2609.   }
  2610.  
  2611.  
  2612.   //window title
  2613.   if(windowTitle != nullptr){
  2614.     if( strncpy_s(_title, 256, windowTitle, 255) )
  2615.       throw "windowTitle failed to copy";
  2616.     _title[255] = 0; //just in case
  2617.   } else {
  2618.     _title[0] = 0;
  2619.   }
  2620.  
  2621.  
  2622.   //window size
  2623.   s32 screenWidth  = GetSystemMetrics(SM_CXSCREEN);
  2624.   s32 screenHeight = GetSystemMetrics(SM_CYSCREEN);
  2625.   if(!windowWidth ) windowWidth  = screenWidth;
  2626.   if(!windowHeight) windowHeight = screenHeight;
  2627.  
  2628.  
  2629.   //canvas size
  2630.   if(canvasWidth  > windowWidth ) throw "canvasWidth > windowWidth";
  2631.   if(canvasHeight > windowHeight) throw "canvasHeight > windowHeight";
  2632.   if(!canvasWidth ) canvasWidth  = windowWidth;
  2633.   if(!canvasHeight) canvasHeight = windowHeight;
  2634.  
  2635.   _opaque->canvasSize.x = canvasWidth;
  2636.   _opaque->canvasSize.y = canvasHeight;
  2637.  
  2638.   _opaque->canvasStretchMode = KIT_INITIAL_STRETCH_MODE;
  2639.   _opaque->canvasStretch = (canvasWidth<windowWidth || canvasHeight<windowHeight);
  2640.  
  2641.  
  2642.   //initialize mutex
  2643.   InitializeCriticalSectionAndSpinCount(&_opaque->lock, KIT_LOCK_SPINCOUNT);
  2644.  
  2645.  
  2646.   //create and register window class (only if no other windows are present)
  2647.   if(w32::winCount == 0){
  2648.     w32::winClass.cbSize        = sizeof(WNDCLASSEX);
  2649.     w32::winClass.style         = 0;
  2650.     w32::winClass.lpfnWndProc   = w32::WindowProc;
  2651.     w32::winClass.cbClsExtra    = 0;
  2652.     w32::winClass.cbWndExtra    = 0;
  2653.     w32::winClass.hInstance     = w32::hThisInst;
  2654.     w32::winClass.hIcon         = nullptr;
  2655.     w32::winClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
  2656.     w32::winClass.hbrBackground = nullptr;
  2657.     w32::winClass.lpszMenuName  = nullptr;
  2658.     w32::winClass.lpszClassName = w32::winClassName;
  2659.     w32::winClass.hIconSm       = nullptr; //(the window's small icon)
  2660.     w32::winClassAtom = RegisterClassExA(&w32::winClass);
  2661.     if(!w32::winClassAtom){
  2662.       errorText = "RegisterClassA() failed";
  2663.       goto _DelCritSection;
  2664.     }
  2665.   }
  2666.  
  2667.  
  2668.   //create canvas info
  2669.   _opaque->canvasInfo.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
  2670.   _opaque->canvasInfo.bmiHeader.biWidth       = canvasWidth;
  2671.   _opaque->canvasInfo.bmiHeader.biHeight      = canvasHeight;
  2672.   _opaque->canvasInfo.bmiHeader.biPlanes      = 1;      //should always be 1
  2673.   _opaque->canvasInfo.bmiHeader.biBitCount    = 32;     //for 0x--RRGGBB
  2674.   _opaque->canvasInfo.bmiHeader.biCompression = BI_RGB; //uncompressed rgb
  2675.   _opaque->canvas = nullptr;
  2676.   _opaque->canvasDevCtx = CreateCompatibleDC(nullptr);
  2677.   if(_opaque->canvasDevCtx == nullptr){
  2678.     errorText = "CreateCompatibleDC() failed";
  2679.     goto _UnregisterClass;
  2680.   }
  2681.  
  2682.  
  2683.   //pre-creation window flag handling
  2684.   DWORD _windowFlags   = WS_OVERLAPPEDWINDOW; //will be hidden initially
  2685.   DWORD _windowFlagsEx = 0;
  2686.   //if(windowFlags & KIT_WINFLAG_FULLSCREEN); //tbd
  2687.   if(windowFlags & WINFLAG_BORDERLESS){
  2688.     windowFlags &= ~WINFLAG_RESIZABLE;
  2689.     //_windowFlags |=  WS_POPUP;
  2690.     //_windowFlags &= ~WS_CAPTION;
  2691.     //_windowFlags &= ~WS_SYSMENU;
  2692.   }
  2693.   if(!(windowFlags & WINFLAG_RESIZABLE)){
  2694.     _windowFlags &= ~WS_THICKFRAME;
  2695.   }
  2696.   if(windowFlags & WINFLAG_MINIMIZED) _windowFlags |= WS_MINIMIZE;
  2697.   if(windowFlags & WINFLAG_MAXIMIZED) _windowFlags |= WS_MAXIMIZE;
  2698.  
  2699.  
  2700.   //create window
  2701.   shape::point winSize = CalculateWindowSize(windowWidth, windowHeight,
  2702.                                              _windowFlags, _windowFlagsEx);
  2703.   _opaque->winHandle = CreateWindowExA(_windowFlagsEx, w32::winClassName, _title,
  2704.                                        _windowFlags, windowX, windowY, winSize.x, winSize.y,
  2705.                                        nullptr, nullptr, w32::hThisInst, (LPVOID)this);
  2706.   if(_opaque->winHandle == nullptr){
  2707.     errorText = "CreateWindowA() failed";
  2708.     goto _DeleteDC;
  2709.   }
  2710.  
  2711.  
  2712.   //window position
  2713.   RECT winRectTmp;
  2714.   GetWindowRect(_opaque->winHandle, &winRectTmp); //get window's bounding box
  2715.   _opaque->winRect = ConvertToKitRect(winRectTmp);
  2716.  
  2717.   shape::point centerPos;
  2718.   centerPos.x = screenWidth /2 - _opaque->winRect.w/2;
  2719.   centerPos.y = screenHeight/2 - _opaque->winRect.h/2;
  2720.  
  2721.   if(     windowX == WINPOS_UNDEFINED) windowX = CW_USEDEFAULT;
  2722.   else if(windowX == WINPOS_CENTERED ) windowX = centerPos.x;
  2723.   if(     windowY == WINPOS_UNDEFINED) windowY = CW_USEDEFAULT;
  2724.   else if(windowY == WINPOS_CENTERED ) windowY = centerPos.y;
  2725.  
  2726.   SetWindowPos(_opaque->winHandle, nullptr, windowX,windowY,
  2727.                0,0, SWP_NOZORDER | SWP_NOSIZE);
  2728.  
  2729.   GetWindowRect(_opaque->winHandle, &winRectTmp); //get window's bounding box
  2730.   _opaque->winRect = ConvertToKitRect(winRectTmp);
  2731.  
  2732.  
  2733.   //post-creation window flag handling
  2734.   //SetWindowLong(_opaque->winHandle, GWL_STYLE, WS_POPUP);
  2735.   if(!(windowFlags & WINFLAG_HIDDEN)) ShowWindow(_opaque->winHandle, SW_SHOW);
  2736.   if(  windowFlags & WINFLAG_FOCUS  ) SetFocus(_opaque->winHandle);
  2737.  
  2738.  
  2739.   _opaque->winDestroyed = false;
  2740.   ++w32::winCount; //add window to total count
  2741.   _valid = true;
  2742.   _constructing = false;
  2743. }
  2744.  
  2745.  
  2746.  
  2747. Window::~Window(){
  2748.   if(!_valid) return;
  2749.   _valid = false;
  2750.   --w32::winCount; //remove window from total count
  2751.  
  2752.   if(_opaque != nullptr){
  2753.     DestroyWindow(_opaque->winHandle);
  2754.     DeleteDC(_opaque->canvasDevCtx);
  2755.     if(w32::winCount == 0) UnregisterClassA(w32::winClassName, w32::hThisInst);
  2756.     DeleteCriticalSection(&_opaque->lock);
  2757.     delete _opaque;
  2758.     _opaque = nullptr;
  2759.   }
  2760. }
  2761.  
  2762.  
  2763.  
  2764.  
  2765. bool Window::isDestroyed(){
  2766.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2767.   return _opaque->winDestroyed; //set by w32::WindowProc, rather than destructor
  2768. }
  2769.  
  2770.  
  2771.  
  2772.  
  2773. shape::rect Window::getWindowRect(){
  2774.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2775.   return _opaque->winRect;
  2776. }
  2777.  
  2778.  
  2779.  
  2780. shape::point Window::getCanvasSize(){
  2781.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2782.   return _opaque->canvasSize;
  2783. }
  2784.  
  2785.  
  2786.  
  2787. color::ARGB* Window::getPixels(){
  2788.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2789.   return _opaque->canvasPixels;
  2790. }
  2791.  
  2792.  
  2793.  
  2794.  
  2795. bool Window::pollEvent(WindowEvent* event_p){
  2796.   MSG message;
  2797.   if(PeekMessage(&message, NULL, 0, 0, PM_REMOVE)){
  2798.     TranslateMessage(&message);
  2799.     DispatchMessage(&message);
  2800.     return true;
  2801.   } else {
  2802.     return false;
  2803.   }
  2804. }
  2805.  
  2806.  
  2807.  
  2808.  
  2809. void Window::lock(bool locked){
  2810.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2811.   if(locked) EnterCriticalSection(&_opaque->lock);
  2812.   else       LeaveCriticalSection(&_opaque->lock);
  2813. }
  2814.  
  2815.  
  2816.  
  2817. void Window::present(){
  2818.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2819.   InvalidateRect(_opaque->winHandle, nullptr, false);
  2820.   UpdateWindow(_opaque->winHandle);
  2821. }
  2822.  
  2823.  
  2824.  
  2825.  
  2826. void Window::clear(color::ARGB color){
  2827.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2828.   HBRUSH brushHandle = CreateSolidBrush(color.v);
  2829.   if(brushHandle != nullptr){
  2830.     SelectObject(_opaque->canvasDevCtx, brushHandle);
  2831.     RECT rectF;
  2832.     rectF.left   = 0;
  2833.     rectF.top    = 0;
  2834.     rectF.right  = _opaque->canvasSize.x;
  2835.     rectF.bottom = _opaque->canvasSize.y;
  2836.     FillRect(_opaque->canvasDevCtx, &rectF, brushHandle);
  2837.     DeleteObject(brushHandle);
  2838.   }
  2839. }
  2840.  
  2841.  
  2842.  
  2843. void Window::tblitns(Bitmap* bmp, s32 x, s32 y,
  2844.                      color::ARGB transparency)
  2845. {
  2846.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  2847.   if(bmp->getType() != KIT_CLASSTYPE_BITMAP) throw "bmp is not a Bitmap";
  2848.   _BitmapOpaque* bmpOpaque = bmp->_accessOpaque();
  2849.   TransparentBlt(_opaque->canvasDevCtx, x, y,
  2850.                  bmpOpaque->bmpSize.x,
  2851.                  bmpOpaque->bmpSize.y,
  2852.                  bmpOpaque->bmpDevCtx, 0, 0,
  2853.                  bmpOpaque->bmpSize.x,
  2854.                  bmpOpaque->bmpSize.y,
  2855.                  transparency.v);
  2856. }
  2857.  
  2858.  
  2859.  
  2860.  
  2861. }; /* namespace kit */
  2862.  
  2863.  
  2864. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Window\kit_Window.cpp */
  2865.  
  2866.  
  2867.  
  2868.  
  2869. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Bitmap\kit_Bitmap.cpp */
  2870.  
  2871. #include <kit/_video/Bitmap.hpp>
  2872. #include "_kit_Bitmap.hpp"
  2873.  
  2874. #include <string.h> //for memcpy
  2875.  
  2876. #define KIT_INVALID_BITMAP _kit_invalid_bitmap
  2877.  
  2878.  
  2879. namespace kit {
  2880.  
  2881. static const char _kit_invalid_bitmap[] = "invalid bitmap";
  2882.  
  2883.  
  2884.  
  2885.  
  2886. //loads from memory
  2887. Bitmap::Bitmap(const color::ARGB* pixelData,
  2888.                u32 width, u32 height,
  2889.                bool directAccess)
  2890. {
  2891.   _type = KIT_CLASSTYPE_BITMAP;
  2892.   _opaque = new _BitmapOpaque;
  2893.  
  2894.   char* errorText = nullptr;
  2895.   if(0){ //this code block is only entered via goto in the event of an exception
  2896.     _DeleteDC: DeleteDC(_opaque->bmpDevCtx);
  2897.     throw (const char*)errorText;
  2898.   }
  2899.  
  2900.  
  2901.   //verify parameters
  2902.   if(!width ) throw "width = 0";
  2903.   if(!height) throw "height = 0";
  2904.   _opaque->bmpSize.x = width;
  2905.   _opaque->bmpSize.y = height;
  2906.   _opaque->bmpDirectAccess = directAccess;
  2907.  
  2908.  
  2909.   //create the bitmap's device context (for rendering directly to the bitmap)
  2910.   _opaque->bmpDevCtx = CreateCompatibleDC(nullptr);
  2911.   if(_opaque->bmpDevCtx == nullptr) throw "CreateCompatibleDC() failed";
  2912.  
  2913.  
  2914.   //fill in bitmap info
  2915.   _opaque->bmpInfo.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
  2916.   _opaque->bmpInfo.bmiHeader.biWidth       = width;
  2917.   _opaque->bmpInfo.bmiHeader.biHeight      = height;
  2918.   _opaque->bmpInfo.bmiHeader.biPlanes      = 1;      //should always be 1
  2919.   _opaque->bmpInfo.bmiHeader.biBitCount    = 32;     //for 0x--RRGGBB
  2920.   _opaque->bmpInfo.bmiHeader.biCompression = BI_RGB; //uncompressed rgb
  2921.  
  2922.  
  2923.   //create the actual bitmap object
  2924.   if(directAccess){
  2925.     _opaque->bmp = CreateDIBSection(nullptr, &_opaque->bmpInfo, DIB_RGB_COLORS,
  2926.                                     (void**)&_opaque->bmpPixels, nullptr, 0);
  2927.     if(pixelData != nullptr){ //copy pixel data if not null
  2928.       memcpy(_opaque->bmpPixels, pixelData, sizeof(color::ARGB)*width*height);
  2929.     }
  2930.   } else {
  2931.     //tbd
  2932.  
  2933.   }
  2934.  
  2935.   if(_opaque->bmp != nullptr){
  2936.     SelectObject(_opaque->bmpDevCtx, _opaque->bmp);
  2937.     SetStretchBltMode(_opaque->bmpDevCtx, KIT_INITIAL_STRETCH_MODE);
  2938.     _opaque->bmpStretchMode = KIT_INITIAL_STRETCH_MODE;
  2939.   } else {
  2940.     errorText = "failed to create bitmap object";
  2941.     goto _DeleteDC;
  2942.   }
  2943.  
  2944.  
  2945.   _valid = true;
  2946. }
  2947.  
  2948.  
  2949.  
  2950. Bitmap::~Bitmap(){
  2951.   if(!_valid) return;
  2952.   _valid = false;
  2953.  
  2954.   if(_opaque != nullptr){
  2955.     DeleteObject(_opaque->bmp);
  2956.     DeleteDC(_opaque->bmpDevCtx);
  2957.     delete _opaque;
  2958.     _opaque = nullptr;
  2959.   }
  2960. }
  2961.  
  2962.  
  2963.  
  2964. }; /* namespace kit */
  2965.  
  2966.  
  2967. /* D:\Media\ToolProj\_C++\projects\win32_2\w32_2\src\kit_win32\Bitmap\kit_Bitmap.cpp */
  2968.  
  2969.  
  2970.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement