Advertisement
Kitomas

kit_win32 as of 2024-02-22 (1/2)

Feb 22nd, 2024
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 81.06 KB | None | 0 0
  1. /*+src\kit_win32\kit_Bitmap.cpp+*/
  2.  
  3. #include <kit/_video_Bitmap.hpp>
  4. #include "kit_Bitmap_shared.hpp"
  5.  
  6. #define KIT_INVALID_BITMAP _kit_invalid_bitmap
  7.  
  8.  
  9. namespace kit {
  10.  
  11. static const char _kit_invalid_bitmap[] = "invalid bitmap";
  12.  
  13.  
  14.  
  15.  
  16. //loads from memory
  17. Bitmap::Bitmap(const color::ARGB* pixelData,
  18.                u32 width, u32 height,
  19.                bool directAccess)
  20. {
  21.   _type = KIT_CLASSTYPE_BITMAP;
  22.   _opq = (_BitmapOpaque*)CoTaskMemAlloc(sizeof(_BitmapOpaque));
  23.   if(_opq == nullptr) throw "ran out of memory creating _opq";
  24.   memset(_opq, 0, sizeof(_BitmapOpaque));
  25.  
  26.   if(!width ) throw "width = 0";
  27.   if(!height) throw "height = 0";
  28.  
  29.   if(!PopulateBitmapOpaque(*_opq, pixelData, width, height, directAccess)){
  30.     CoTaskMemFree(_opq);
  31.     throw "failed to create internal bitmap";
  32.   }
  33.  
  34.   _valid = true;
  35. }
  36.  
  37.  
  38.  
  39. Bitmap::~Bitmap(){
  40.   if(!_valid) return;
  41.   _valid = false;
  42.  
  43.   if(_opq != nullptr){
  44.     DeleteObject(_opq->handle);
  45.     DeleteDC(_opq->devCtx);
  46.     CoTaskMemFree(_opq);
  47.     _opq = nullptr;
  48.   }
  49. }
  50.  
  51.  
  52.  
  53.  
  54. }; /* namespace kit */
  55.  
  56. /*-src\kit_win32\kit_Bitmap.cpp-*/
  57.  
  58.  
  59. /*+src\kit_win32\kit_main.cpp+*/
  60.  
  61. #include "_kit_globals.hpp"
  62.  
  63. using namespace kit;
  64.  
  65.  
  66. HINSTANCE w32::hThisInst = nullptr;
  67. HINSTANCE w32::hPrevInst = nullptr;
  68. LPSTR     w32::lpszArg   = nullptr;
  69. int       w32::nCmdShow  = SW_HIDE;
  70.  
  71. LARGE_INTEGER w32::ticksPerSecond;
  72.  
  73.  
  74.  
  75.  
  76. //get first and last char of string, excluding leading or trailing whitespace
  77.  //(whitespace as in ' '; i'm not going to bother with '\t', '\n', etc.)
  78. static inline char* _getFirstCharPtr(char* start){
  79.   if(*start == 0) return start;
  80.   while(*start == ' ') ++start;
  81.   return start;
  82. }
  83.  
  84. static inline char* _getLastCharPtr(char* start){
  85.   if(*start == 0) return start;
  86.   char* end = start;
  87.   while(*(end+1) != 0 ) ++end; //go to null terminator
  88.   while(*end == ' ') --end; //go back until a non-whitespace char is found
  89.   return end;
  90. }
  91.  
  92.  
  93.  
  94.  
  95. //provided by the user
  96. extern int main(int argc, char** argv);
  97.  
  98.  
  99. //converts lpszArg to how argv normally behaves,
  100.  //before calling a user-defined main() function
  101. int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
  102.                    LPSTR     lpszArg,   int       nCmdShow)
  103. {
  104.   //assign some global values
  105.   w32::hThisInst = hThisInst;
  106.   w32::hPrevInst = hPrevInst;
  107.   w32::lpszArg   = lpszArg;
  108.   w32::nCmdShow  = nCmdShow;
  109.  
  110.   QueryPerformanceFrequency(&w32::ticksPerSecond);
  111.  
  112.  
  113.   char*      p = (char*)lpszArg;
  114.   int    _argc = 1; //should always contain path to executable
  115.   char** _argv = nullptr;
  116.  
  117.    //parse for the number of arguments (assuming space as delimiter)
  118.   char* first = _getFirstCharPtr(p);
  119.   char* last  = _getLastCharPtr(p);
  120.   int Arg_len = (int)(last-first) + ((*first!=0) ? 1 : 0);
  121.  
  122.   if(Arg_len > 0) ++_argc;
  123.   for(p=first; p<=last; ++p){
  124.     if(*p == ' ') ++_argc;
  125.   }
  126.  
  127.    //create and fill in _argv
  128.   _argv = (char**)CoTaskMemAlloc( sizeof(char*) * _argc );
  129.   if(_argv == nullptr) return ERROR_NOT_ENOUGH_MEMORY;
  130.   memset(_argv, 0, sizeof(char*)*_argc ); //this may be redundant...
  131.  
  132.   char filepath[MAX_PATH]; //path to current process
  133.   if(GetModuleFileNameA(NULL, filepath, MAX_PATH) == 0)
  134.     return ERROR_INSUFFICIENT_BUFFER;
  135.   _argv[0] = filepath;
  136.  
  137.   if(Arg_len > 0){
  138.     int i = 1;
  139.     _argv[i++] = first;
  140.     for(p=first; p<=last; ++p){
  141.       if(*p == ' '){
  142.         *p = 0; //set delimiter to null
  143.         _argv[i++] = p+1; //+1 as in +sizeof(char*)
  144.       }
  145.     }
  146.     *p = 0; //make sure last arg has null terminator
  147.   }
  148.  
  149.  
  150.   int returnCode = main(_argc,_argv);
  151.   CoTaskMemFree(_argv);
  152.   return returnCode;
  153. }
  154.  
  155. /*-src\kit_win32\kit_main.cpp-*/
  156.  
  157.  
  158. /*+src\kit_win32\kit_Mutex.cpp+*/
  159.  
  160. #include <kit/_misc_Mutex.hpp>
  161. #include "_kit_globals.hpp"
  162.  
  163. #define KIT_MUTEX_NULLPTR _kit_mutex_nullptr
  164.  
  165.  
  166. using namespace kit;
  167.  
  168. static const char _kit_mutex_nullptr[] = "internal mutex = nullptr";
  169.  
  170.  
  171.  
  172.  
  173. MutexSimple::MutexSimple(u32 spinCount){
  174.   _type = KIT_CLASSTYPE_MUTEXSIMPLE;
  175.  
  176.   //(no cast needed when allocating, since _mutex_ptr is already of type void*)
  177.   _mutex_ptr = CoTaskMemAlloc(sizeof(CRITICAL_SECTION));
  178.   if(_mutex_ptr == nullptr) throw "ran out of memory creating internal mutex";
  179.   memset(_mutex_ptr, 0, sizeof(CRITICAL_SECTION));
  180.  
  181.   if(spinCount == -1){
  182.     InitializeCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  183.     //to my knowledge, there is no GetCriticalSectionSpinCount,
  184.      //so i need to probe for it with a "Set" before setting it back
  185.      //(also, i tried to grab the SpinCount member of the critical section
  186.      // directly, but that seemed to result in undefined behavior for some reason!!!)
  187.     _spinCount = SetCriticalSectionSpinCount((CRITICAL_SECTION*)_mutex_ptr, 0);
  188.     SetCriticalSectionSpinCount((CRITICAL_SECTION*)_mutex_ptr, _spinCount);
  189.  
  190.   } else {
  191.     InitializeCriticalSectionAndSpinCount((CRITICAL_SECTION*)_mutex_ptr, spinCount);
  192.     _spinCount = spinCount;
  193.  
  194.   }
  195. }
  196.  
  197.  
  198.  
  199. MutexSimple::~MutexSimple(){
  200.   if(_mutex_ptr == nullptr) return;
  201.   DeleteCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  202.   CoTaskMemFree(_mutex_ptr);
  203.   _mutex_ptr = nullptr;
  204. }
  205.  
  206.  
  207.  
  208.  
  209. void MutexSimple::setSpinCount(u32 spinCount){
  210.   if(_mutex_ptr == nullptr) throw KIT_MUTEX_NULLPTR;
  211.   SetCriticalSectionSpinCount((CRITICAL_SECTION*)_mutex_ptr, spinCount);
  212.   _spinCount = spinCount;
  213. }
  214.  
  215.  
  216.  
  217.  
  218. void MutexSimple::lock(bool locked){
  219.   if(_mutex_ptr == nullptr) throw KIT_MUTEX_NULLPTR;
  220.   if(locked) EnterCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  221.   else       LeaveCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  222. }
  223.  
  224.  
  225.  
  226. bool MutexSimple::tryLock(){
  227.   if(_mutex_ptr == nullptr) throw KIT_MUTEX_NULLPTR;
  228.   return TryEnterCriticalSection((CRITICAL_SECTION*)_mutex_ptr);
  229. }
  230.  
  231. /*-src\kit_win32\kit_Mutex.cpp-*/
  232.  
  233.  
  234. /*+src\kit_win32\kit_time.cpp+*/
  235.  
  236. #include <kit/_misc_time.hpp>
  237. #include "_kit_globals.hpp"
  238.  
  239. #include <Windows.h>
  240.  
  241.  
  242. namespace kit {
  243.  
  244.  
  245.  
  246.  
  247. u64 time::getTicks(){
  248.   LARGE_INTEGER ticks;
  249.   QueryPerformanceCounter(&ticks);
  250.   return ticks.QuadPart;
  251. }
  252.  
  253.  
  254.  
  255. u64 time::getTicksPerSecond(){
  256.   return w32::ticksPerSecond.QuadPart;
  257. }
  258.  
  259.  
  260.  
  261. f64 time::getUptime(){
  262.   return (f64)time::getTicks()/w32::ticksPerSecond.QuadPart;
  263. }
  264.  
  265.  
  266.  
  267.  
  268. void time::sleep(u32 milliseconds){
  269.   Sleep(milliseconds);
  270. }
  271.  
  272.  
  273.  
  274.  
  275. }; /* namespace kit */
  276.  
  277. /*-src\kit_win32\kit_time.cpp-*/
  278.  
  279.  
  280. /*+src\kit_win32\kit_Window.cpp+*/
  281.  
  282. #include <kit/_video_Window.hpp>
  283. #include "kit_Window_shared.hpp"
  284.  
  285. #define KIT_IS_INVALID_WINDOW ( (!_valid && !_constructing) || _opq->winClosed )
  286. #define KIT_INVALID_WINDOW _kit_invalid_window
  287.  
  288.  
  289. namespace kit {
  290.  
  291. static const char _kit_invalid_window[] = "invalid window";
  292.  
  293. namespace w32 {
  294.   u32         winCount = 0; //number of existing kit::Window instances
  295.   const char  winClassName[] = "kit::Window Class";
  296.   WNDCLASSEXA winClass;
  297.   ATOM        winClassAtom;
  298. };
  299.  
  300.  
  301.  
  302.  
  303. Window::Window(const char* windowTitle,
  304.                u32 windowWidth, u32 windowHeight,
  305.                u32 windowFlags,
  306.                s32 windowX,     s32 windowY,
  307.                u32 canvasWidth, u32 canvasHeight,
  308.                bool directAccess)
  309. {
  310.   _type = KIT_CLASSTYPE_WINDOW;
  311.  
  312.   _opq = (_WindowOpaque*)CoTaskMemAlloc(sizeof(_WindowOpaque));
  313.   if(_opq == nullptr) throw "ran out of memory creating _opq";
  314.   memset(_opq, 0, sizeof(_WindowOpaque));
  315.  
  316.   char* errorText = "no error";
  317.   if(0){ //this code block is only entered via goto in the event of an exception
  318.     //(destroying the window is unnecessary, as it's the last thing to be made anyway)
  319.     //_DestroyWindow  : DestroyWindow(_opq->winHandle);
  320.     _DestroyCanvas  : DeleteObject(_opq->canvas.handle);
  321.                       DeleteDC(_opq->canvas.devCtx);
  322.     _UnregisterClass: if(w32::winCount == 0) UnregisterClassA(w32::winClassName, w32::hThisInst);
  323.     _DelCritSection : DeleteCriticalSection(&_opq->lock);
  324.     _FreeOpaque     : CoTaskMemFree(_opq);
  325.     throw (const char*)errorText;
  326.   }
  327.  
  328.  
  329.   //window title
  330.   if(windowTitle != nullptr){
  331.     if( strncpy_s(_title, 256, windowTitle, 255) )
  332.       throw "windowTitle failed to copy";
  333.     _title[255] = 0; //just in case
  334.   } else {
  335.     _title[0] = 0;
  336.   }
  337.  
  338.  
  339.   //window size
  340.   if(!windowWidth ) windowWidth  = GetSystemMetrics(SM_CXSCREEN);
  341.   if(!windowHeight) windowHeight = GetSystemMetrics(SM_CYSCREEN);
  342.  
  343.  
  344.   //create event queue
  345.   _opq->eventQueue = (WindowEvent*)CoTaskMemAlloc(sizeof(WindowEvent)*65536);
  346.   if(_opq->eventQueue == nullptr){
  347.     errorText = "ran out of memory creating event queue";
  348.     goto _FreeOpaque;
  349.   }
  350.   //(no memset is necessary for the event queue, thankfully)
  351.   _opq->eventQueueNext = 0; //both indexes are 16-bit, so they'll roll over on overflow
  352.   _opq->eventQueueEnd  = 0;  //(which is nice, since the queue's length is exactly 2^16)
  353.  
  354.  
  355.   //initialize mutex
  356.   InitializeCriticalSectionAndSpinCount(&_opq->lock, KIT_LOCK_SPINCOUNT);
  357.  
  358.  
  359.   //create and register window class (only if no other windows are present)
  360.   if(w32::winCount == 0){
  361.     w32::winClass.cbSize        = sizeof(WNDCLASSEX);
  362.     w32::winClass.style         = CS_DBLCLKS; //allow double clicks
  363.     w32::winClass.lpfnWndProc   = w32::WindowProc;
  364.     w32::winClass.cbClsExtra    = 0;
  365.     w32::winClass.cbWndExtra    = 0;
  366.     w32::winClass.hInstance     = w32::hThisInst;
  367.     w32::winClass.hIcon         = nullptr;
  368.     w32::winClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
  369.     w32::winClass.hbrBackground = nullptr;
  370.     w32::winClass.lpszMenuName  = nullptr;
  371.     w32::winClass.lpszClassName = w32::winClassName;
  372.     w32::winClass.hIconSm       = nullptr; //(the window's small icon)
  373.     w32::winClassAtom = RegisterClassExA(&w32::winClass);
  374.     if(!w32::winClassAtom){
  375.       errorText = "RegisterClassA() failed";
  376.       goto _DelCritSection;
  377.     }
  378.   }
  379.  
  380.  
  381.   //create canvas
  382.   if(canvasWidth  > windowWidth ) throw "canvasWidth > windowWidth";
  383.   if(canvasHeight > windowHeight) throw "canvasHeight > windowHeight";
  384.   if(!canvasWidth ) canvasWidth  = windowWidth;
  385.   if(!canvasHeight) canvasHeight = windowHeight;
  386.   _opq->canvasStretch = (canvasWidth<windowWidth || canvasHeight<windowHeight);
  387.  
  388.   if(!PopulateBitmapOpaque(_opq->canvas, nullptr, canvasWidth, canvasHeight, directAccess))
  389.   {
  390.     errorText = "failed to create canvas";
  391.     goto _UnregisterClass;
  392.   }
  393.  
  394.  
  395.   HandlePreCreationWindowFlags(_opq, windowFlags);
  396.  
  397.  
  398.   //create window
  399.   shape::point winSize = CalculateWindowSize(windowWidth, windowHeight,
  400.                                              _opq->winFlags, _opq->winFlagsEx);
  401.  
  402.   _opq->winHandle = CreateWindowExA(_opq->winFlagsEx, w32::winClassName, _title,
  403.                                     _opq->winFlags, windowX, windowY, winSize.x, winSize.y,
  404.                                     nullptr, nullptr, w32::hThisInst, (LPVOID)this);
  405.  
  406.   if(_opq->winHandle == nullptr){
  407.     errorText = "CreateWindowA() failed";
  408.     goto _DestroyCanvas;
  409.   }
  410.  
  411.  
  412.   _opq->winRect.x = (windowX != WINPOS_UNCHANGED) ? windowX : WINPOS_UNDEFINED;
  413.   _opq->winRect.y = (windowY != WINPOS_UNCHANGED) ? windowY : WINPOS_UNDEFINED;
  414.   _opq->winRect.w = winSize.x;
  415.   _opq->winRect.h = winSize.y;
  416.   setWindowRect(&_opq->winRect);
  417.  
  418.  
  419.   if(_opq->winFullscreen            ) setFullscreen(true);
  420.   if(!(windowFlags & WINFLAG_HIDDEN)) setVisibility(true);
  421.   if(  windowFlags & WINFLAG_FOCUS  ) setFocus(true);
  422.  
  423.  
  424.   _opq->winClosed = false;
  425.   _opq->winIndex = w32::winCount++; //set window index, before adding to total count
  426.   _valid = true;
  427.   _constructing = false;
  428. }
  429.  
  430.  
  431.  
  432. Window::~Window(){
  433.   if(!_valid) return;
  434.   _valid = false;
  435.   --w32::winCount; //remove window from total count
  436.  
  437.   if(_opq != nullptr){
  438.     DestroyWindow(_opq->winHandle);
  439.     DeleteObject(_opq->canvas.handle);
  440.     DeleteDC(_opq->canvas.devCtx);
  441.     if(w32::winCount == 0) UnregisterClassA(w32::winClassName, w32::hThisInst);
  442.     DeleteCriticalSection(&_opq->lock);
  443.     CoTaskMemFree(_opq->eventQueue);
  444.     CoTaskMemFree(_opq);
  445.     _opq = nullptr;
  446.   }
  447. }
  448.  
  449.  
  450.  
  451.  
  452. bool Window::isClosed(){
  453.   //(can't use KIT_IS_INVALID_WINDOW here)
  454.   if(!_valid && !_constructing) throw KIT_INVALID_WINDOW;
  455.   return _opq->winClosed; //set by w32::WindowProc, rather than destructor
  456. }
  457.  
  458.  
  459.  
  460. shape::rect Window::getWindowRect(){
  461.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  462.   return _opq->winRect;
  463. }
  464.  
  465.  
  466.  
  467. shape::point Window::getCanvasSize(){
  468.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  469.   return _opq->canvas.size;
  470. }
  471.  
  472.  
  473.  
  474. color::ARGB* Window::getPixels(){
  475.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  476.   if(_opq->canvas.directAccess) return _opq->canvas.pixels;
  477.   else throw "window does not support direct access";
  478. }
  479.  
  480.  
  481.  
  482.  
  483. //if newRect == nullptr, the window will stretch to fit the whole screen
  484. void Window::setWindowRect(shape::rect* newRect){
  485.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  486.  
  487.  
  488.   s32 screenWidth  = GetSystemMetrics(SM_CXSCREEN);
  489.   s32 screenHeight = GetSystemMetrics(SM_CYSCREEN);
  490.  
  491.  
  492.   if(newRect != nullptr){
  493.  
  494.     RECT winRectTmp;
  495.     GetWindowRect(_opq->winHandle, &winRectTmp); //get window's bounding box
  496.     shape::rect winRectCurrent = ConvertToKitRect(winRectTmp);
  497.  
  498.     shape::point centerPos;
  499.     centerPos.x = screenWidth /2 - winRectCurrent.w/2;
  500.     centerPos.y = screenHeight/2 - winRectCurrent.h/2;
  501.  
  502.  
  503.     if(     newRect->x == WINPOS_UNDEFINED) newRect->x = CW_USEDEFAULT;
  504.     else if(newRect->x == WINPOS_CENTERED ) newRect->x = centerPos.x;
  505.     if(     newRect->y == WINPOS_UNDEFINED) newRect->y = CW_USEDEFAULT;
  506.     else if(newRect->y == WINPOS_CENTERED ) newRect->y = centerPos.y;
  507.  
  508.     shape::rect _newRect = winRectCurrent;
  509.     if(newRect->x != WINPOS_UNCHANGED) _newRect.x = newRect->x;
  510.     if(newRect->y != WINPOS_UNCHANGED) _newRect.y = newRect->y;
  511.     if(newRect->w!=WINPOS_UNCHANGED && newRect->w>0) _newRect.w = newRect->w;
  512.     if(newRect->h!=WINPOS_UNCHANGED && newRect->h>0) _newRect.h = newRect->h;
  513.  
  514.  
  515.     SetWindowPos(_opq->winHandle, nullptr, newRect->x,newRect->y,
  516.                  newRect->w, newRect->h, SWP_NOZORDER);
  517.  
  518.     GetWindowRect(_opq->winHandle, &winRectTmp); //get window's bounding box (again)
  519.     _opq->winRect = ConvertToKitRect(winRectTmp); //update the window's rect
  520.  
  521.  
  522.   } else {
  523.     //winRect automatically gets overwritten for every WM_MOVE and WM_SIZE message,
  524.      //so record its previous value so it can be set back after the SetWindowPos
  525.     shape::rect previousRectValue = _opq->winRect;
  526.  
  527.     //this will fill the entire screen
  528.     SetWindowPos(_opq->winHandle, nullptr, 0,0,
  529.                  screenWidth, screenHeight, SWP_NOZORDER);
  530.  
  531.     _opq->winRect = previousRectValue;
  532.  
  533.  
  534.   }
  535. }
  536.  
  537.  
  538.  
  539. void Window::setVisibility(bool showWindow){
  540.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  541.   ShowWindow(_opq->winHandle, (showWindow) ? SW_SHOW : SW_HIDE);
  542.   _opq->winShown = showWindow;
  543.   //*maybe* set _opq->winFlags (probably not needed, though)
  544. }
  545.  
  546.  
  547.  
  548. void Window::setFocus(bool enable){
  549.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  550.   SetFocus((enable) ? _opq->winHandle : nullptr);
  551.   _opq->winFocus = enable;
  552. }
  553.  
  554.  
  555.  
  556. void Window::setFullscreen(bool enable){
  557.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  558.  
  559.  
  560.   if(enable){ //modify values accordingly
  561.     //style flags
  562.     SetWindowLongA(_opq->winHandle, GWL_STYLE,
  563.                    _opq->winFlags & ~(WS_CAPTION | WS_THICKFRAME));
  564.  
  565.     //extended style flags
  566.     SetWindowLong(_opq->winHandle, GWL_EXSTYLE,
  567.                   _opq->winFlagsEx & ~(WS_EX_DLGMODALFRAME |
  568.                   WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
  569.  
  570.     //stretch window to match screen's width and height
  571.     setWindowRect(nullptr);
  572.  
  573.  
  574.   } else { //restore values to what they were before
  575.     //restore style flags
  576.     SetWindowLongA(_opq->winHandle, GWL_STYLE, _opq->winFlags);
  577.  
  578.     //restore extended style flags
  579.     SetWindowLong(_opq->winHandle, GWL_EXSTYLE, _opq->winFlagsEx);
  580.  
  581.     //restore window position and size
  582.     setWindowRect(&_opq->winRect);
  583.  
  584.  
  585.   }
  586.  
  587.   //idk for sure why this fixes the issue of the window breaking when
  588.    //fullscreen is toggled, but if it works in the constructor and here too,
  589.    //then i have no problem with doing it this way :)
  590.   setVisibility(_opq->winShown);
  591. }
  592.  
  593.  
  594.  
  595.  
  596. bool Window::pollEvent(WindowEvent* event_p){
  597.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  598.  
  599.   //take one event off the current event queue and set it to *event_p
  600.   EnterCriticalSection(&_opq->lock);
  601.   WindowEvent event = RemoveFromEventQueue(_opq);
  602.   LeaveCriticalSection(&_opq->lock);
  603.  
  604.  
  605.   //if previous event queue is now empty, process any pending window messages,
  606.    //while adding any events generated by WindowProc to the event queue
  607.   if(_opq->eventQueueNext == _opq->eventQueueEnd){
  608.     MSG message;
  609.     while(PeekMessageA(&message, _opq->winHandle, 0, 0, PM_REMOVE)){
  610.       TranslateMessage(&message);
  611.       DispatchMessageA(&message);
  612.     }
  613.   }
  614.  
  615.  
  616.   if(event_p != nullptr) *event_p = event;
  617.   return event.type != WINEVENT_NULL;
  618. }
  619.  
  620.  
  621.  
  622.  
  623. void Window::lock(bool locked){
  624.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  625.   if(locked) EnterCriticalSection(&_opq->lock);
  626.   else       LeaveCriticalSection(&_opq->lock);
  627. }
  628.  
  629.  
  630.  
  631. void Window::present(){
  632.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  633.   InvalidateRect(_opq->winHandle, nullptr, false);
  634.   UpdateWindow(_opq->winHandle);
  635. }
  636.  
  637.  
  638.  
  639.  
  640. void Window::clear(color::ARGB color){
  641.   if(KIT_IS_INVALID_WINDOW) throw KIT_INVALID_WINDOW;
  642.   HBRUSH brushHandle = CreateSolidBrush(color.v);
  643.   if(brushHandle != nullptr){
  644.     SelectObject(_opq->canvas.devCtx, brushHandle);
  645.     RECT rectF;
  646.     rectF.left   = 0;
  647.     rectF.top    = 0;
  648.     rectF.right  = _opq->canvas.size.x;
  649.     rectF.bottom = _opq->canvas.size.y;
  650.     FillRect(_opq->canvas.devCtx, &rectF, brushHandle);
  651.     DeleteObject(brushHandle);
  652.   }
  653. }
  654.  
  655.  
  656.  
  657.  
  658. }; /* namespace kit */
  659.  
  660. /*-src\kit_win32\kit_Window.cpp-*/
  661.  
  662.  
  663. /*+src\kit_win32\kit_Window_WindowProc.cpp+*/
  664.  
  665. #include <kit/_video_Window.hpp>
  666. #include <kit/_video_WindowEvent.hpp>
  667. #include "kit_Window_shared.hpp"
  668. #include "kit_Window_WindowProcEvent.hpp"
  669.  
  670.  
  671. using namespace kit;
  672.  
  673.  
  674.  
  675.  
  676. #if defined(_DEBUG)
  677. static void printMessage(HWND, UINT, WPARAM, LPARAM);
  678. #else
  679. #define printMessage(...) ;
  680. #endif /* _DEBUG */
  681.  
  682. LRESULT CALLBACK w32::WindowProc(HWND winHandle, UINT message,
  683.                                  WPARAM wParam, LPARAM lParam)
  684. {
  685.   //printMessage(winHandle, message, wParam, lParam); //debug thingy
  686.   Window* window = (Window*)GetWindowLongPtrA(winHandle, GWLP_USERDATA);
  687.  
  688.   if(window == nullptr){
  689.     if(message == WM_CREATE){
  690.       //set userdata to a pointer to the associated kit::Window
  691.       CREATESTRUCT* cs = (CREATESTRUCT*)lParam;
  692.       SetWindowLongPtrA(winHandle, GWLP_USERDATA, (LONG_PTR)cs->lpCreateParams);
  693.       return 0;
  694.     }
  695.     goto _dwp; //lol
  696.   } else if(!window->isValid() && !window->isConstructing()){
  697.     _dwp: return DefWindowProcA(winHandle, message, wParam, lParam);
  698.   }
  699.  
  700.  
  701.  
  702.   _WindowOpaque* opq = window->_accessOpaque();
  703.   EnterCriticalSection(&opq->lock);
  704.   LRESULT returnResult = 0;
  705.  
  706.   WindowEvent event; //will be populated by any call to KIT_HANDLE_EVENT()...
  707.   memset(&event, 0, sizeof(WindowEvent));
  708.   event.common.type     = WINEVENT_COMMON; //...otherwise it will stay common
  709.   event.common.winIndex = opq->winIndex;
  710.  
  711.   bool switchBool  = false; //multipurpose
  712.   bool switchBool2 = true;   //^^
  713.   u32  switchFlags = 0;      //^^
  714.  
  715.  
  716.   switch(message){
  717.     //window and canvas messages (WINEVENT_WIN_<event name>)
  718.  
  719.     //WINEVENT_WIN_CLOSE
  720.     case WM_CLOSE:
  721.     {
  722.       KIT_HANDLE_EVENT(WIN_CLOSE);
  723.  
  724.     } break;
  725.  
  726.  
  727.     //WINEVENT_WIN_MOVED
  728.     case WM_MOVE:
  729.     {
  730.       //window moved; adjust its position accordingly
  731.       opq->winRect.x = GET_X_LPARAM(lParam);
  732.       opq->winRect.y = GET_Y_LPARAM(lParam);
  733.  
  734.       KIT_HANDLE_EVENT(WIN_MOVED, opq->winRect);
  735.  
  736.     } break;
  737.  
  738.  
  739.     //WINEVENT_WIN_RESIZED
  740.     case WM_SIZE:
  741.     {
  742.       //window resized; adjust its size accordingly
  743.       opq->winRect.w = LOWORD(lParam);
  744.       opq->winRect.h = HIWORD(lParam);
  745.  
  746.       //resize canvas if it's supposed to scale with the window
  747.       if(!opq->canvasStretch)
  748.         ResizeBitmapOpaque(opq->canvas, opq->winRect.w, opq->winRect.h);
  749.  
  750.       //blit canvas to the window to reflect its new size
  751.       window->present();
  752.  
  753.       KIT_HANDLE_EVENT(WIN_RESIZED, opq->winRect);
  754.  
  755.     } break;
  756.  
  757.  
  758.     //WINEVENT_WIN_UNFOCUSING
  759.     case WM_KILLFOCUS:
  760.     {
  761.       //if a key is released outside the client area, its key up message
  762.        //is never sent, so here the key states are reset when unfocusing...
  763.        //...but first, send a key up event for every currently pressed key
  764.  
  765.       //call QPC only once, since the events technically happen at the same time
  766.       QueryPerformanceCounter((LARGE_INTEGER*)&event.key.timestamp);
  767.  
  768.       using namespace WindowProcEvent;
  769.       KEY_Params params = 0;
  770.       params.currUnpressed = 1;
  771.  
  772.       for(u32 chr=0; chr<256; ++chr){
  773.         //send a KEY_UP only if the state was previously true
  774.         if(opq->keyStates[chr] == true){
  775.           params.scanCode = MapVirtualKeyA(chr, MAPVK_VK_TO_VSC);
  776.           KIT_HANDLE_EVENT(KEY_CHARUPDOWN, false, chr, params, 0);
  777.           if(!AddToEventQueue(opq,event)){ _printf("event queue is full!!!\n"); }
  778.         }
  779.       }
  780.  
  781.       memset(opq->keyStates, 0, sizeof(bool)*256); //NOW the states can be reset
  782.       opq->kmod.all = 0; //reset any key modifiers too
  783.  
  784.       opq->winFocus = false;
  785.  
  786.       KIT_HANDLE_EVENT(WIN_UNFOCUSING);
  787.  
  788.     } break;
  789.  
  790.  
  791.     //WINEVENT_WIN_FOCUSED
  792.     case WM_SETFOCUS:
  793.     {
  794.       opq->winFocus = true;
  795.  
  796.       KIT_HANDLE_EVENT(WIN_FOCUSED);
  797.  
  798.     } break;
  799.  
  800.  
  801.     //(no associated event)
  802.     case WM_DESTROY:
  803.     {
  804.       opq->winClosed = true;
  805.  
  806.     } break;
  807.  
  808.  
  809.     //(no associated event)
  810.     case WM_GETMINMAXINFO:
  811.     {
  812.       //enforce minimum window size if canvas does not scale with the window
  813.       if(opq->canvasStretch){
  814.         u32 winStyleCurrent   = GetWindowLongA(winHandle, GWL_STYLE  );
  815.         u32 winStyleExCurrent = GetWindowLongA(winHandle, GWL_EXSTYLE);
  816.         shape::point winSizeAdjusted = CalculateWindowSize(opq->canvas.size.x,
  817.                                                            opq->canvas.size.y,
  818.                                                            winStyleCurrent,
  819.                                                            winStyleExCurrent);
  820.  
  821.         MINMAXINFO* mmi = (MINMAXINFO*)lParam;
  822.         mmi->ptMinTrackSize.x = winSizeAdjusted.x;
  823.         mmi->ptMinTrackSize.y = winSizeAdjusted.y;
  824.       }
  825.  
  826.     } break;
  827.  
  828.  
  829.     //(no associated event)
  830.     case WM_PAINT:
  831.     {
  832.       if(opq->canvas.handle == nullptr) break; //just in case
  833.       PAINTSTRUCT paint;
  834.       HDC         winDevCtx; //window device context
  835.       RECT        rectO; //[O]riginal
  836.       shape::rect rectW; //[W]indow
  837.       shape::rect rectF; //[F]rame
  838.  
  839.       //prepare window for painting
  840.       winDevCtx = BeginPaint(winHandle, &paint);
  841.       rectO = paint.rcPaint;
  842.       rectW = ConvertToKitRect(rectO);
  843.  
  844.       //calculate copy region of canvas
  845.       f64 percentageX = (f64)rectW.x/rectW.w; //from 0.0 -> 1.0
  846.       f64 percentageY = (f64)rectW.y/rectW.h; //from 0.0 -> 1.0
  847.       rectF.w = opq->canvas.size.x;
  848.       rectF.h = opq->canvas.size.y;
  849.       rectF.x = (s32)( (f64)rectF.w*percentageX + 0.5 ); //(+0.5 for rounding)
  850.       rectF.y = (s32)( (f64)rectF.y*percentageY + 0.5 );
  851.  
  852.       //copy canvas bitmap to window
  853.        //(window and canvas stretch modes should be the same)
  854.       SetStretchBltMode(winDevCtx, opq->canvas.stretchMode);
  855.       StretchBlt(winDevCtx, rectW.x,rectW.y, rectW.w,rectW.h,
  856.                  opq->canvas.devCtx, rectF.x,rectF.y, rectF.w,rectF.h, SRCCOPY);
  857.  
  858.       EndPaint(winHandle, &paint);
  859.  
  860.     } break;
  861.  
  862.  
  863.  
  864.     //keyboard messages (WINEVENT_KEY_<event name>)
  865.  
  866.     //WINEVENT_KEY_CHAR, WINEVENT_KEY_UP, WINEVENT_KEY_DOWN
  867.     case WM_CHAR:
  868.     case WM_SYSKEYUP:
  869.     case WM_SYSKEYDOWN:
  870.     case WM_KEYUP:
  871.     case WM_KEYDOWN:
  872.     case WM_SYSCHAR:
  873.     {
  874. #define printKeyParams() {                                                        \
  875.   _printf("{\n");                                                                 \
  876.   _printf("  charEvent      = %s\n", (charEvent) ? "true" : "false");             \
  877.   _printf("  virtualKeyCode = %c (0x%02X)\n", virtualKeyCode, virtualKeyCode);    \
  878.   _printf("  repeatCount    = %u\n", params.repeatCount);                         \
  879.   _printf("  scanCode       = %c (0x%02X)\n", params.scanCode,params.scanCode);   \
  880.   _printf("  extendedKey    = %s\n", (params.extendedKey) ? "true" : "false");    \
  881.   _printf("  altKeyDown     = %s\n", (params.altKeyDown) ? "true" : "false");     \
  882.   _printf("  prevPressed    = %s\n", (!params.prevUnpressed) ? "true" : "false"); \
  883.   _printf("  currPressed    = %s\n", (!params.currUnpressed) ? "true" : "false"); \
  884.   _printf("}\n"); }
  885.       //^^ i'll remove this stuff once i figure out how to handle key modifiers
  886.  
  887.       using namespace WindowProcEvent;
  888.  
  889.       //marshal relevant stuff to pass to event handler
  890.       bool    charEvent = message==WM_CHAR;
  891.       u8 virtualKeyCode = (u8)wParam;
  892.       KEY_Params params = (u32)lParam;
  893.  
  894.       //set repeat flag
  895.       params.repeatCount = (!params.currUnpressed)        == true &&
  896.                            opq->keyStates[virtualKeyCode] == true;
  897.  
  898.       if(!charEvent) opq->keyStates[virtualKeyCode] = !params.currUnpressed;
  899.  
  900.       //update any relevant key modifiers
  901.       opq->kmod.all = 0; //tbd
  902.  
  903.       KIT_HANDLE_EVENT(KEY_CHARUPDOWN, charEvent, virtualKeyCode,
  904.                                        params,    opq->kmod.all);
  905.  
  906.     } break;
  907.  
  908.  
  909.  
  910.     //mouse messages (WINEVENT_MOUSE_<event name>)
  911.  
  912.     //WINEVENT_MOUSE_MOVE
  913.     case WM_MOUSEMOVE:
  914.     {
  915.       using namespace WindowProcEvent;
  916.  
  917.       //get button states
  918.       MOUSE_ButtonStates buttonStates;
  919.       buttonStates.left   = (wParam&MK_LBUTTON ) != 0;
  920.       buttonStates.middle = (wParam&MK_MBUTTON ) != 0;
  921.       buttonStates.right  = (wParam&MK_RBUTTON ) != 0;
  922.       buttonStates.x1     = (wParam&MK_XBUTTON1) != 0;
  923.       buttonStates.x2     = (wParam&MK_XBUTTON2) != 0;
  924.  
  925.       //get new mouse position
  926.       shape::point mousePositionNew;
  927.       mousePositionNew.x = GET_X_LPARAM(lParam);
  928.       mousePositionNew.y = GET_Y_LPARAM(lParam);
  929.  
  930.       //if this is the first instance of WINEVENT_MOUSE_MOVE,
  931.        //there is no previous mouse position, so the delta should be 0 then
  932.       if(!opq->mouseWasMovedBefore){
  933.         //(handle MOUSE_ENTER events here too, since
  934.          //there is no special message for it)
  935.         KIT_HANDLE_EVENT(MOUSE_ENTER);
  936.         QueryPerformanceCounter((LARGE_INTEGER*)&event.common.timestamp);
  937.         if(!AddToEventQueue(opq,event)){ _printf("event queue is full!!!\n"); }
  938.         opq->mousePosition = mousePositionNew,
  939.         opq->mouseWasMovedBefore = true;
  940.       }
  941.  
  942.       KIT_HANDLE_EVENT(MOUSE_MOVE, buttonStates.value,
  943.                        opq->mousePosition, mousePositionNew);
  944.  
  945.       opq->mousePosition = mousePositionNew; //set current position to new one
  946.  
  947.     } break;
  948.  
  949.  
  950.     //WINEVENT_MOUSE_LEAVE
  951.     case WM_MOUSELEAVE:
  952.     {
  953.       //indicates that the mouse will have yet to be moved inside client area
  954.       opq->mouseWasMovedBefore = false;
  955.  
  956.       KIT_HANDLE_EVENT(MOUSE_LEAVE);
  957.  
  958.     } break;
  959.  
  960.  
  961.     /*WINEVENT_MOUSE_ENTER (is handled inside WM_MOUSEMOVE)
  962.     case WM_<there is no mouse enter message!>:
  963.     {
  964.       KIT_HANDLE_EVENT(MOUSE_ENTER);
  965.  
  966.     } break; */
  967.  
  968.  
  969.     //WINEVENT_MOUSE_UP, WINEVENT_MOUSE_DOWN
  970.      //switchBool  = event.mouse.dblClick
  971.      //switchBool2 = event.mouse.pressed
  972.      //switchFlags = event.mouse.button
  973.     case WM_LBUTTONDBLCLK: switchBool  = true;  goto _notLButtonUp;
  974.     case WM_LBUTTONUP    : switchBool2 = false; _notLButtonUp:
  975.     case WM_LBUTTONDOWN  : switchFlags |= MBUTTON_LEFT; goto _handleMouseClick;
  976.  
  977.     case WM_MBUTTONDBLCLK: switchBool  = true;  goto _notMButtonUp;
  978.     case WM_MBUTTONUP    : switchBool2 = false; _notMButtonUp:
  979.     case WM_MBUTTONDOWN  : switchFlags |= MBUTTON_MIDDLE; goto _handleMouseClick;
  980.  
  981.     case WM_RBUTTONDBLCLK: switchBool  = true;  goto _notRButtonUp;
  982.     case WM_RBUTTONUP    : switchBool2 = false; _notRButtonUp:
  983.     case WM_RBUTTONDOWN  : switchFlags |= MBUTTON_RIGHT; goto _handleMouseClick;
  984.  
  985.     case WM_XBUTTONDBLCLK: switchBool  = true;  goto _notXButtonUp;
  986.     case WM_XBUTTONUP    : switchBool2 = false; _notXButtonUp:
  987.     case WM_XBUTTONDOWN  : if(wParam & MK_XBUTTON1) switchFlags |= MBUTTON_X1;
  988.                            else                     switchFlags |= MBUTTON_X2;
  989.     {
  990.       _handleMouseClick:
  991.  
  992.       shape::point clickPosition;
  993.       clickPosition.x = GET_X_LPARAM(lParam);
  994.       clickPosition.y = GET_Y_LPARAM(lParam);
  995.  
  996.       u8   buttonStates = (u8)switchFlags;
  997.       bool pressed      = switchBool2;
  998.       bool doubleClick  = switchBool;
  999.  
  1000.       KIT_HANDLE_EVENT(MOUSE_UPDOWN, clickPosition,
  1001.                        buttonStates, pressed, doubleClick);
  1002.  
  1003.     } break;
  1004.  
  1005.  
  1006.     //WINEVENT_MOUSE_HWHEEL, WINEVENT_MOUSE_VWHEEL
  1007.     case WM_MOUSEHWHEEL:
  1008.     case WM_MOUSEWHEEL:
  1009.     {
  1010.       using namespace WindowProcEvent;
  1011.  
  1012.       bool verticalScroll = message==WM_MOUSEWHEEL;
  1013.  
  1014.       s16  scrollAmount = (s16)HIWORD(wParam);
  1015.  
  1016.       MOUSE_ButtonStates buttonStates;
  1017.       buttonStates.left   = (wParam&MK_LBUTTON ) != 0;
  1018.       buttonStates.middle = (wParam&MK_MBUTTON ) != 0;
  1019.       buttonStates.right  = (wParam&MK_RBUTTON ) != 0;
  1020.       buttonStates.x1     = (wParam&MK_XBUTTON1) != 0;
  1021.       buttonStates.x2     = (wParam&MK_XBUTTON2) != 0;
  1022.  
  1023.       shape::point scrollMousePosition;
  1024.       scrollMousePosition.x = GET_X_LPARAM(lParam);
  1025.       scrollMousePosition.y = GET_Y_LPARAM(lParam);
  1026.       //the coordinates are relative to the screen, not the window (for some reason)
  1027.       ScreenToClient(winHandle, (POINT*)&scrollMousePosition);
  1028.  
  1029.       KIT_HANDLE_EVENT(MOUSE_HVWHEEL, verticalScroll, scrollAmount,
  1030.                        buttonStates.value, scrollMousePosition);
  1031.  
  1032.     } break;
  1033.  
  1034.  
  1035.  
  1036.     default: returnResult = DefWindowProcA(winHandle, message, wParam, lParam);
  1037.   }
  1038.  
  1039.  
  1040.   if(event.type != WINEVENT_COMMON){
  1041.     //idk how expensive QPC is, so i'll only call it if the event is valid
  1042.     QueryPerformanceCounter((LARGE_INTEGER*)&event.common.timestamp);
  1043.     //i pray AddToEventQueue never fails ever
  1044.     if(!AddToEventQueue(opq,event)){ _printf("event queue is full!!!\n"); }
  1045.   }
  1046.  
  1047.  
  1048.   LeaveCriticalSection(&opq->lock);
  1049.   return returnResult;
  1050. }
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059. //these are for enabling and disabling what messages are printed
  1060.  //simply comment these out to disable them
  1061.  
  1062. #define KIT_PM_WM_NULL                           //0x0000
  1063. #define KIT_PM_WM_CREATE                         //0x0001
  1064. #define KIT_PM_WM_DESTROY                        //0x0002
  1065. #define KIT_PM_WM_MOVE                           //0x0003
  1066. #define KIT_PM_WM_SIZE                           //0x0005
  1067. #define KIT_PM_WM_ACTIVATE                       //0x0006
  1068. #define KIT_PM_WM_SETFOCUS                       //0x0007
  1069. #define KIT_PM_WM_KILLFOCUS                      //0x0008
  1070. #define KIT_PM_WM_ENABLE                         //0x000A
  1071. #define KIT_PM_WM_SETREDRAW                      //0x000B
  1072. #define KIT_PM_WM_SETTEXT                        //0x000C
  1073. //#define KIT_PM_WM_GETTEXT                        //0x000D
  1074. //#define KIT_PM_WM_GETTEXTLENGTH                  //0x000E
  1075. #define KIT_PM_WM_PAINT                          //0x000F
  1076. #define KIT_PM_WM_CLOSE                          //0x0010
  1077. #define KIT_PM_WM_QUERYENDSESSION                //0x0011
  1078. #define KIT_PM_WM_QUIT                           //0x0012
  1079. #define KIT_PM_WM_QUERYOPEN                      //0x0013
  1080. #define KIT_PM_WM_ERASEBKGND                     //0x0014
  1081. #define KIT_PM_WM_SYSCOLORCHANGE                 //0x0015
  1082. #define KIT_PM_WM_ENDSESSION                     //0x0016
  1083. #define KIT_PM_WM_SHOWWINDOW                     //0x0018
  1084. #define KIT_PM_WM_SETTINGCHANGE                  //0x001A
  1085. #define KIT_PM_WM_DEVMODECHANGE                  //0x001B
  1086. #define KIT_PM_WM_ACTIVATEAPP                    //0x001C
  1087. #define KIT_PM_WM_FONTCHANGE                     //0x001D
  1088. #define KIT_PM_WM_TIMECHANGE                     //0x001E
  1089. #define KIT_PM_WM_CANCELMODE                     //0x001F
  1090. //#define KIT_PM_WM_SETCURSOR                      //0x0020
  1091. #define KIT_PM_WM_MOUSEACTIVATE                  //0x0021
  1092. #define KIT_PM_WM_CHILDACTIVATE                  //0x0022
  1093. #define KIT_PM_WM_QUEUESYNC                      //0x0023
  1094. #define KIT_PM_WM_GETMINMAXINFO                  //0x0024
  1095. #define KIT_PM_WM_PAINTICON                      //0x0026
  1096. #define KIT_PM_WM_ICONERASEBKGND                 //0x0027
  1097. #define KIT_PM_WM_NEXTDLGCTL                     //0x0028
  1098. #define KIT_PM_WM_SPOOLERSTATUS                  //0x002A
  1099. #define KIT_PM_WM_DRAWITEM                       //0x002B
  1100. #define KIT_PM_WM_MEASUREITEM                    //0x002C
  1101. #define KIT_PM_WM_DELETEITEM                     //0x002D
  1102. #define KIT_PM_WM_VKEYTOITEM                     //0x002E
  1103. #define KIT_PM_WM_CHARTOITEM                     //0x002F
  1104. #define KIT_PM_WM_SETFONT                        //0x0030
  1105. #define KIT_PM_WM_GETFONT                        //0x0031
  1106. #define KIT_PM_WM_SETHOTKEY                      //0x0032
  1107. #define KIT_PM_WM_GETHOTKEY                      //0x0033
  1108. #define KIT_PM_WM_QUERYDRAGICON                  //0x0037
  1109. #define KIT_PM_WM_COMPAREITEM                    //0x0039
  1110. #define KIT_PM_WM_GETOBJECT                      //0x003D
  1111. #define KIT_PM_WM_COMPACTING                     //0x0041
  1112. #define KIT_PM_WM_COMMNOTIFY                     //0x0044
  1113. #define KIT_PM_WM_WINDOWPOSCHANGING              //0x0046
  1114. #define KIT_PM_WM_WINDOWPOSCHANGED               //0x0047
  1115. #define KIT_PM_WM_POWER                          //0x0048
  1116. #define KIT_PM_WM_COPYDATA                       //0x004A
  1117. #define KIT_PM_WM_CANCELJOURNAL                  //0x004B
  1118. #define KIT_PM_WM_NOTIFY                         //0x004E
  1119. #define KIT_PM_WM_INPUTLANGCHANGEREQUEST         //0x0050
  1120. #define KIT_PM_WM_INPUTLANGCHANGE                //0x0051
  1121. #define KIT_PM_WM_TCARD                          //0x0052
  1122. #define KIT_PM_WM_HELP                           //0x0053
  1123. #define KIT_PM_WM_USERCHANGED                    //0x0054
  1124. #define KIT_PM_WM_NOTIFYFORMAT                   //0x0055
  1125. #define KIT_PM_WM_CONTEXTMENU                    //0x007B
  1126. #define KIT_PM_WM_STYLECHANGING                  //0x007C
  1127. #define KIT_PM_WM_STYLECHANGED                   //0x007D
  1128. #define KIT_PM_WM_DISPLAYCHANGE                  //0x007E
  1129. #define KIT_PM_WM_GETICON                        //0x007F
  1130. #define KIT_PM_WM_SETICON                        //0x0080
  1131. #define KIT_PM_WM_NCCREATE                       //0x0081
  1132. #define KIT_PM_WM_NCDESTROY                      //0x0082
  1133. #define KIT_PM_WM_NCCALCSIZE                     //0x0083
  1134. //#define KIT_PM_WM_NCHITTEST                      //0x0084
  1135. #define KIT_PM_WM_NCPAINT                        //0x0085
  1136. #define KIT_PM_WM_NCACTIVATE                     //0x0086
  1137. #define KIT_PM_WM_GETDLGCODE                     //0x0087
  1138. #define KIT_PM_WM_SYNCPAINT                      //0x0088
  1139.  
  1140. //#define KIT_PM_WM_NCMOUSEMOVE                    //0x00A0
  1141. #define KIT_PM_WM_NCLBUTTONDOWN                  //0x00A1
  1142. #define KIT_PM_WM_NCLBUTTONUP                    //0x00A2
  1143. #define KIT_PM_WM_NCLBUTTONDBLCLK                //0x00A3
  1144. #define KIT_PM_WM_NCRBUTTONDOWN                  //0x00A4
  1145. #define KIT_PM_WM_NCRBUTTONUP                    //0x00A5
  1146. #define KIT_PM_WM_NCRBUTTONDBLCLK                //0x00A6
  1147. #define KIT_PM_WM_NCMBUTTONDOWN                  //0x00A7
  1148. #define KIT_PM_WM_NCMBUTTONUP                    //0x00A8
  1149. #define KIT_PM_WM_NCMBUTTONDBLCLK                //0x00A9
  1150. #define KIT_PM_WM_NCXBUTTONDOWN                  //0x00AB
  1151. #define KIT_PM_WM_NCXBUTTONUP                    //0x00AC
  1152. #define KIT_PM_WM_NCXBUTTONDBLCLK                //0x00AD
  1153.  
  1154. #define KIT_PM_WM_INPUT_DEVICE_CHANGE            //0x00FE
  1155. #define KIT_PM_WM_INPUT                          //0x00FF
  1156. #define KIT_PM_WM_KEYDOWN                        //0x0100
  1157. #define KIT_PM_WM_KEYUP                          //0x0101
  1158. #define KIT_PM_WM_CHAR                           //0x0102
  1159. #define KIT_PM_WM_DEADCHAR                       //0x0103
  1160. #define KIT_PM_WM_SYSKEYDOWN                     //0x0104
  1161. #define KIT_PM_WM_SYSKEYUP                       //0x0105
  1162. #define KIT_PM_WM_SYSCHAR                        //0x0106
  1163. #define KIT_PM_WM_SYSDEADCHAR                    //0x0107
  1164. #define KIT_PM_WM_UNICHAR                        //0x0109
  1165. #define KIT_PM_WM_IME_STARTCOMPOSITION           //0x010D
  1166. #define KIT_PM_WM_IME_ENDCOMPOSITION             //0x010E
  1167. #define KIT_PM_WM_IME_COMPOSITION                //0x010F
  1168. #define KIT_PM_WM_INITDIALOG                     //0x0110
  1169. #define KIT_PM_WM_COMMAND                        //0x0111
  1170. #define KIT_PM_WM_SYSCOMMAND                     //0x0112
  1171. #define KIT_PM_WM_TIMER                          //0x0113
  1172. #define KIT_PM_WM_HSCROLL                        //0x0114
  1173. #define KIT_PM_WM_VSCROLL                        //0x0115
  1174. #define KIT_PM_WM_INITMENU                       //0x0116
  1175. #define KIT_PM_WM_INITMENUPOPUP                  //0x0117
  1176. #define KIT_PM_WM_GESTURE                        //0x0119
  1177. #define KIT_PM_WM_GESTURENOTIFY                  //0x011A
  1178. #define KIT_PM_WM_MENUSELECT                     //0x011F
  1179. #define KIT_PM_WM_MENUCHAR                       //0x0120
  1180. #define KIT_PM_WM_ENTERIDLE                      //0x0121
  1181. #define KIT_PM_WM_MENURBUTTONUP                  //0x0122
  1182. #define KIT_PM_WM_MENUDRAG                       //0x0123
  1183. #define KIT_PM_WM_MENUGETOBJECT                  //0x0124
  1184. #define KIT_PM_WM_UNINITMENUPOPUP                //0x0125
  1185. #define KIT_PM_WM_MENUCOMMAND                    //0x0126
  1186. #define KIT_PM_WM_CHANGEUISTATE                  //0x0127
  1187. #define KIT_PM_WM_UPDATEUISTATE                  //0x0128
  1188. #define KIT_PM_WM_QUERYUISTATE                   //0x0129
  1189. #define KIT_PM_WM_CTLCOLORMSGBOX                 //0x0132
  1190. #define KIT_PM_WM_CTLCOLOREDIT                   //0x0133
  1191. #define KIT_PM_WM_CTLCOLORLISTBOX                //0x0134
  1192. #define KIT_PM_WM_CTLCOLORBTN                    //0x0135
  1193. #define KIT_PM_WM_CTLCOLORDLG                    //0x0136
  1194. #define KIT_PM_WM_CTLCOLORSCROLLBAR              //0x0137
  1195. #define KIT_PM_WM_CTLCOLORSTATIC                 //0x0138
  1196. #define KIT_PM_MN_GETHMENU                       //0x01E1
  1197.  
  1198. //#define KIT_PM_WM_MOUSEMOVE                      //0x0200
  1199. #define KIT_PM_WM_LBUTTONDOWN                    //0x0201
  1200. #define KIT_PM_WM_LBUTTONUP                      //0x0202
  1201. #define KIT_PM_WM_LBUTTONDBLCLK                  //0x0203
  1202. #define KIT_PM_WM_RBUTTONDOWN                    //0x0204
  1203. #define KIT_PM_WM_RBUTTONUP                      //0x0205
  1204. #define KIT_PM_WM_RBUTTONDBLCLK                  //0x0206
  1205. #define KIT_PM_WM_MBUTTONDOWN                    //0x0207
  1206. #define KIT_PM_WM_MBUTTONUP                      //0x0208
  1207. #define KIT_PM_WM_MBUTTONDBLCLK                  //0x0209
  1208. #define KIT_PM_WM_MOUSEWHEEL                     //0x020A
  1209. #define KIT_PM_WM_XBUTTONDOWN                    //0x020B
  1210. #define KIT_PM_WM_XBUTTONUP                      //0x020C
  1211. #define KIT_PM_WM_XBUTTONDBLCLK                  //0x020D
  1212.  
  1213. #define KIT_PM_WM_PARENTNOTIFY                   //0x0210
  1214. #define KIT_PM_WM_ENTERMENULOOP                  //0x0211
  1215. #define KIT_PM_WM_EXITMENULOOP                   //0x0212
  1216. #define KIT_PM_WM_NEXTMENU                       //0x0213
  1217. #define KIT_PM_WM_SIZING                         //0x0214
  1218. #define KIT_PM_WM_CAPTURECHANGED                 //0x0215
  1219. #define KIT_PM_WM_MOVING                         //0x0216
  1220. #define KIT_PM_WM_POWERBROADCAST                 //0x0218
  1221. #define KIT_PM_WM_DEVICECHANGE                   //0x0219
  1222. #define KIT_PM_WM_MDICREATE                      //0x0220
  1223. #define KIT_PM_WM_MDIDESTROY                     //0x0221
  1224. #define KIT_PM_WM_MDIACTIVATE                    //0x0222
  1225. #define KIT_PM_WM_MDIRESTORE                     //0x0223
  1226. #define KIT_PM_WM_MDINEXT                        //0x0224
  1227. #define KIT_PM_WM_MDIMAXIMIZE                    //0x0225
  1228. #define KIT_PM_WM_MDITILE                        //0x0226
  1229. #define KIT_PM_WM_MDICASCADE                     //0x0227
  1230. #define KIT_PM_WM_MDIICONARRANGE                 //0x0228
  1231. #define KIT_PM_WM_MDIGETACTIVE                   //0x0229
  1232. #define KIT_PM_WM_MDISETMENU                     //0x0230
  1233. #define KIT_PM_WM_ENTERSIZEMOVE                  //0x0231
  1234. #define KIT_PM_WM_EXITSIZEMOVE                   //0x0232
  1235. #define KIT_PM_WM_DROPFILES                      //0x0233
  1236. #define KIT_PM_WM_MDIREFRESHMENU                 //0x0234
  1237. #define KIT_PM_WM_POINTERDEVICECHANGE            //0x0238
  1238. #define KIT_PM_WM_POINTERDEVICEINRANGE           //0x0239
  1239. #define KIT_PM_WM_POINTERDEVICEOUTOFRANGE        //0x023A
  1240. #define KIT_PM_WM_TOUCH                          //0x0240
  1241. #define KIT_PM_WM_NCPOINTERUPDATE                //0x0241
  1242. #define KIT_PM_WM_NCPOINTERDOWN                  //0x0242
  1243. #define KIT_PM_WM_NCPOINTERUP                    //0x0243
  1244. #define KIT_PM_WM_POINTERUPDATE                  //0x0245
  1245. #define KIT_PM_WM_POINTERDOWN                    //0x0246
  1246. #define KIT_PM_WM_POINTERUP                      //0x0247
  1247. #define KIT_PM_WM_POINTERENTER                   //0x0249
  1248. #define KIT_PM_WM_POINTERLEAVE                   //0x024A
  1249. #define KIT_PM_WM_POINTERACTIVATE                //0x024B
  1250. #define KIT_PM_WM_POINTERCAPTURECHANGED          //0x024C
  1251. #define KIT_PM_WM_TOUCHHITTESTING                //0x024D
  1252. #define KIT_PM_WM_POINTERWHEEL                   //0x024E
  1253. #define KIT_PM_WM_POINTERHWHEEL                  //0x024F
  1254. #define KIT_PM_DM_POINTERHITTEST                 //0x0250
  1255. #define KIT_PM_WM_POINTERROUTEDTO                //0x0251
  1256. #define KIT_PM_WM_POINTERROUTEDAWAY              //0x0252
  1257. #define KIT_PM_WM_POINTERROUTEDRELEASED          //0x0253
  1258. #define KIT_PM_WM_IME_SETCONTEXT                 //0x0281
  1259. #define KIT_PM_WM_IME_NOTIFY                     //0x0282
  1260. #define KIT_PM_WM_IME_CONTROL                    //0x0283
  1261. #define KIT_PM_WM_IME_COMPOSITIONFULL            //0x0284
  1262. #define KIT_PM_WM_IME_SELECT                     //0x0285
  1263. #define KIT_PM_WM_IME_CHAR                       //0x0286
  1264. #define KIT_PM_WM_IME_REQUEST                    //0x0288
  1265. #define KIT_PM_WM_IME_KEYDOWN                    //0x0290
  1266. #define KIT_PM_WM_IME_KEYUP                      //0x0291
  1267. #define KIT_PM_WM_MOUSEHOVER                     //0x02A1
  1268. #define KIT_PM_WM_MOUSELEAVE                     //0x02A3
  1269. #define KIT_PM_WM_NCMOUSEHOVER                   //0x02A0
  1270. #define KIT_PM_WM_NCMOUSELEAVE                   //0x02A2
  1271. #define KIT_PM_WM_WTSSESSION_CHANGE              //0x02B1
  1272. #define KIT_PM_WM_DPICHANGED                     //0x02E0
  1273. #define KIT_PM_WM_DPICHANGED_BEFOREPARENT        //0x02E2
  1274. #define KIT_PM_WM_DPICHANGED_AFTERPARENT         //0x02E3
  1275. #define KIT_PM_WM_GETDPISCALEDSIZE               //0x02E4
  1276. #define KIT_PM_WM_CUT                            //0x0300
  1277. #define KIT_PM_WM_COPY                           //0x0301
  1278. #define KIT_PM_WM_PASTE                          //0x0302
  1279. #define KIT_PM_WM_CLEAR                          //0x0303
  1280. #define KIT_PM_WM_UNDO                           //0x0304
  1281. #define KIT_PM_WM_RENDERFORMAT                   //0x0305
  1282. #define KIT_PM_WM_RENDERALLFORMATS               //0x0306
  1283. #define KIT_PM_WM_DESTROYCLIPBOARD               //0x0307
  1284. #define KIT_PM_WM_DRAWCLIPBOARD                  //0x0308
  1285. #define KIT_PM_WM_PAINTCLIPBOARD                 //0x0309
  1286. #define KIT_PM_WM_VSCROLLCLIPBOARD               //0x030A
  1287. #define KIT_PM_WM_SIZECLIPBOARD                  //0x030B
  1288. #define KIT_PM_WM_ASKCBFORMATNAME                //0x030C
  1289. #define KIT_PM_WM_CHANGECBCHAIN                  //0x030D
  1290. #define KIT_PM_WM_HSCROLLCLIPBOARD               //0x030E
  1291. #define KIT_PM_WM_QUERYNEWPALETTE                //0x030F
  1292. #define KIT_PM_WM_PALETTEISCHANGING              //0x0310
  1293. #define KIT_PM_WM_PALETTECHANGED                 //0x0311
  1294. #define KIT_PM_WM_HOTKEY                         //0x0312
  1295. #define KIT_PM_WM_PRINT                          //0x0317
  1296. #define KIT_PM_WM_PRINTCLIENT                    //0x0318
  1297. #define KIT_PM_WM_APPCOMMAND                     //0x0319
  1298. #define KIT_PM_WM_THEMECHANGED                   //0x031A
  1299. #define KIT_PM_WM_CLIPBOARDUPDATE                //0x031D
  1300. #define KIT_PM_WM_DWMCOMPOSITIONCHANGED          //0x031E
  1301. #define KIT_PM_WM_DWMNCRENDERINGCHANGED          //0x031F
  1302. #define KIT_PM_WM_DWMCOLORIZATIONCOLORCHANGED    //0x0320
  1303. #define KIT_PM_WM_DWMWINDOWMAXIMIZEDCHANGE       //0x0321
  1304. #define KIT_PM_WM_DWMSENDICONICTHUMBNAIL         //0x0323
  1305. #define KIT_PM_WM_DWMSENDICONICLIVEPREVIEWBITMAP //0x0326
  1306. #define KIT_PM_WM_GETTITLEBARINFOEX              //0x033F
  1307. //#define KIT_PM_WM_UNKNOWN                        //0x????
  1308.  
  1309.  
  1310.  
  1311.  
  1312. #if defined(_DEBUG) //this function will do nothing otherwise
  1313. static void printMessage(HWND hwnd, UINT message,
  1314.                          WPARAM wParam, LPARAM lParam)
  1315. {
  1316.   char* messageName = nullptr;
  1317.  
  1318.  
  1319.   switch(message){
  1320. #  ifdef KIT_PM_WM_NULL
  1321.   case WM_NULL                          : messageName = "WM_NULL";              break; //0x0000
  1322. #  endif
  1323.  
  1324. #  ifdef KIT_PM_WM_CREATE
  1325.   case WM_CREATE                        : messageName = "WM_CREATE";            break; //0x0001
  1326. #  endif
  1327.  
  1328. #  ifdef KIT_PM_WM_DESTROY
  1329.   case WM_DESTROY                       : messageName = "WM_DESTROY";           break; //0x0002
  1330. #  endif
  1331.  
  1332. #  ifdef KIT_PM_WM_MOVE
  1333.   case WM_MOVE                          : messageName = "WM_MOVE";              break; //0x0003
  1334. #  endif
  1335.  
  1336. #  ifdef KIT_PM_WM_SIZE
  1337.   case WM_SIZE                          : messageName = "WM_SIZE";              break; //0x0005
  1338. #  endif
  1339.  
  1340. #  ifdef KIT_PM_WM_ACTIVATE
  1341.   case WM_ACTIVATE                      : messageName = "WM_ACTIVATE";          break; //0x0006
  1342. #  endif
  1343.  
  1344. #  ifdef KIT_PM_WM_SETFOCUS
  1345.   case WM_SETFOCUS                      : messageName = "WM_SETFOCUS";          break; //0x0007
  1346. #  endif
  1347.  
  1348. #  ifdef KIT_PM_WM_KILLFOCUS
  1349.   case WM_KILLFOCUS                     : messageName = "WM_KILLFOCUS";         break; //0x0008
  1350. #  endif
  1351.  
  1352. #  ifdef KIT_PM_WM_ENABLE
  1353.   case WM_ENABLE                        : messageName = "WM_ENABLE";            break; //0x000A
  1354. #  endif
  1355.  
  1356. #  ifdef KIT_PM_WM_SETREDRAW
  1357.   case WM_SETREDRAW                     : messageName = "WM_SETREDRAW";         break; //0x000B
  1358. #  endif
  1359.  
  1360. #  ifdef KIT_PM_WM_SETTEXT
  1361.   case WM_SETTEXT                       : messageName = "WM_SETTEXT";           break; //0x000C
  1362. #  endif
  1363.  
  1364. #  ifdef KIT_PM_WM_GETTEXT
  1365.   case WM_GETTEXT                       : messageName = "WM_GETTEXT";           break; //0x000D
  1366. #  endif
  1367.  
  1368. #  ifdef KIT_PM_WM_GETTEXTLENGTH
  1369.   case WM_GETTEXTLENGTH                 : messageName = "WM_GETTEXTLENGTH";     break; //0x000E
  1370. #  endif
  1371.  
  1372. #  ifdef KIT_PM_WM_PAINT
  1373.   case WM_PAINT                         : messageName = "WM_PAINT";             break; //0x000F
  1374. #  endif
  1375.  
  1376. #  ifdef KIT_PM_WM_CLOSE
  1377.   case WM_CLOSE                         : messageName = "WM_CLOSE";             break; //0x0010
  1378. #  endif
  1379.  
  1380. #  ifdef KIT_PM_WM_QUERYENDSESSION
  1381.   case WM_QUERYENDSESSION               : messageName = "WM_QUERYENDSESSION";   break; //0x0011
  1382. #  endif
  1383.  
  1384. #  ifdef KIT_PM_WM_QUIT
  1385.   case WM_QUIT                          : messageName = "WM_QUIT";              break; //0x0012
  1386. #  endif
  1387.  
  1388. #  ifdef KIT_PM_WM_QUERYOPEN
  1389.   case WM_QUERYOPEN                     : messageName = "WM_QUERYOPEN";         break; //0x0013
  1390. #  endif
  1391.  
  1392. #  ifdef KIT_PM_WM_ERASEBKGND
  1393.   case WM_ERASEBKGND                    : messageName = "WM_ERASEBKGND";        break; //0x0014
  1394. #  endif
  1395.  
  1396. #  ifdef KIT_PM_WM_SYSCOLORCHANGE
  1397.   case WM_SYSCOLORCHANGE                : messageName = "WM_SYSCOLORCHANGE";    break; //0x0015
  1398. #  endif
  1399.  
  1400. #  ifdef KIT_PM_WM_ENDSESSION
  1401.   case WM_ENDSESSION                    : messageName = "WM_ENDSESSION";        break; //0x0016
  1402. #  endif
  1403.  
  1404. #  ifdef KIT_PM_WM_SHOWWINDOW
  1405.   case WM_SHOWWINDOW                    : messageName = "WM_SHOWWINDOW";        break; //0x0018
  1406. #  endif
  1407.  
  1408. #  ifdef KIT_PM_WM_SETTINGCHANGE
  1409.   case WM_SETTINGCHANGE                 : messageName = "WM_SETTINGCHANGE";     break; //0x001A
  1410. #  endif
  1411.  
  1412. #  ifdef KIT_PM_WM_DEVMODECHANGE
  1413.   case WM_DEVMODECHANGE                 : messageName = "WM_DEVMODECHANGE";     break; //0x001B
  1414. #  endif
  1415.  
  1416. #  ifdef KIT_PM_WM_ACTIVATEAPP
  1417.   case WM_ACTIVATEAPP                   : messageName = "WM_ACTIVATEAPP";       break; //0x001C
  1418. #  endif
  1419.  
  1420. #  ifdef KIT_PM_WM_FONTCHANGE
  1421.   case WM_FONTCHANGE                    : messageName = "WM_FONTCHANGE";        break; //0x001D
  1422. #  endif
  1423.  
  1424. #  ifdef KIT_PM_WM_TIMECHANGE
  1425.   case WM_TIMECHANGE                    : messageName = "WM_TIMECHANGE";        break; //0x001E
  1426. #  endif
  1427.  
  1428. #  ifdef KIT_PM_WM_CANCELMODE
  1429.   case WM_CANCELMODE                    : messageName = "WM_CANCELMODE";        break; //0x001F
  1430. #  endif
  1431.  
  1432. #  ifdef KIT_PM_WM_SETCURSOR
  1433.   case WM_SETCURSOR                     : messageName = "WM_SETCURSOR";         break; //0x0020
  1434. #  endif
  1435.  
  1436. #  ifdef KIT_PM_WM_MOUSEACTIVATE
  1437.   case WM_MOUSEACTIVATE                 : messageName = "WM_MOUSEACTIVATE";     break; //0x0021
  1438. #  endif
  1439.  
  1440. #  ifdef KIT_PM_WM_CHILDACTIVATE
  1441.   case WM_CHILDACTIVATE                 : messageName = "WM_CHILDACTIVATE";     break; //0x0022
  1442. #  endif
  1443.  
  1444. #  ifdef KIT_PM_WM_QUEUESYNC
  1445.   case WM_QUEUESYNC                     : messageName = "WM_QUEUESYNC";         break; //0x0023
  1446. #  endif
  1447.  
  1448. #  ifdef KIT_PM_WM_GETMINMAXINFO
  1449.   case WM_GETMINMAXINFO                 : messageName = "WM_GETMINMAXINFO";     break; //0x0024
  1450. #  endif
  1451.  
  1452. #  ifdef KIT_PM_WM_PAINTICON
  1453.   case WM_PAINTICON                     : messageName = "WM_PAINTICON";         break; //0x0026
  1454. #  endif
  1455.  
  1456. #  ifdef KIT_PM_WM_ICONERASEBKGND
  1457.   case WM_ICONERASEBKGND                : messageName = "WM_ICONERASEBKGND";    break; //0x0027
  1458. #  endif
  1459.  
  1460. #  ifdef KIT_PM_WM_NEXTDLGCTL
  1461.   case WM_NEXTDLGCTL                    : messageName = "WM_NEXTDLGCTL";        break; //0x0028
  1462. #  endif
  1463.  
  1464. #  ifdef KIT_PM_WM_SPOOLERSTATUS
  1465.   case WM_SPOOLERSTATUS                 : messageName = "WM_SPOOLERSTATUS";     break; //0x002A
  1466. #  endif
  1467.  
  1468. #  ifdef KIT_PM_WM_DRAWITEM
  1469.   case WM_DRAWITEM                      : messageName = "WM_DRAWITEM";          break; //0x002B
  1470. #  endif
  1471.  
  1472. #  ifdef KIT_PM_WM_MEASUREITEM
  1473.   case WM_MEASUREITEM                   : messageName = "WM_MEASUREITEM";       break; //0x002C
  1474. #  endif
  1475.  
  1476. #  ifdef KIT_PM_WM_DELETEITEM
  1477.   case WM_DELETEITEM                    : messageName = "WM_DELETEITEM";        break; //0x002D
  1478. #  endif
  1479.  
  1480. #  ifdef KIT_PM_WM_VKEYTOITEM
  1481.   case WM_VKEYTOITEM                    : messageName = "WM_VKEYTOITEM";        break; //0x002E
  1482. #  endif
  1483.  
  1484. #  ifdef KIT_PM_WM_CHARTOITEM
  1485.   case WM_CHARTOITEM                    : messageName = "WM_CHARTOITEM";        break; //0x002F
  1486. #  endif
  1487.  
  1488. #  ifdef KIT_PM_WM_SETFONT
  1489.   case WM_SETFONT                       : messageName = "WM_SETFONT";           break; //0x0030
  1490. #  endif
  1491.  
  1492. #  ifdef KIT_PM_WM_GETFONT
  1493.   case WM_GETFONT                       : messageName = "WM_GETFONT";           break; //0x0031
  1494. #  endif
  1495.  
  1496. #  ifdef KIT_PM_WM_SETHOTKEY
  1497.   case WM_SETHOTKEY                     : messageName = "WM_SETHOTKEY";         break; //0x0032
  1498. #  endif
  1499.  
  1500. #  ifdef KIT_PM_WM_GETHOTKEY
  1501.   case WM_GETHOTKEY                     : messageName = "WM_GETHOTKEY";         break; //0x0033
  1502. #  endif
  1503.  
  1504. #  ifdef KIT_PM_WM_QUERYDRAGICON
  1505.   case WM_QUERYDRAGICON                 : messageName = "WM_QUERYDRAGICON";     break; //0x0037
  1506. #  endif
  1507.  
  1508. #  ifdef KIT_PM_WM_COMPAREITEM
  1509.   case WM_COMPAREITEM                   : messageName = "WM_COMPAREITEM";       break; //0x0039
  1510. #  endif
  1511.  
  1512.  
  1513. #if(WINVER >= 0x0500)
  1514. #ifndef _WIN32_WCE
  1515. #  ifdef KIT_PM_WM_GETOBJECT
  1516.   case WM_GETOBJECT                     : messageName = "WM_GETOBJECT";         break; //0x003D
  1517. #  endif
  1518. #endif
  1519. #endif /* WINVER >= 0x0500 */
  1520.  
  1521.  
  1522. #  ifdef KIT_PM_WM_COMPACTING
  1523.   case WM_COMPACTING                    : messageName = "WM_COMPACTING";        break; //0x0041
  1524. #  endif
  1525.  
  1526. #  ifdef KIT_PM_WM_COMMNOTIFY
  1527.   case WM_COMMNOTIFY                    : messageName = "WM_COMMNOTIFY";        break; //0x0044
  1528. #  endif
  1529.  
  1530. #  ifdef KIT_PM_WM_WINDOWPOSCHANGING
  1531.   case WM_WINDOWPOSCHANGING             : messageName = "WM_WINDOWPOSCHANGING"; break; //0x0046
  1532. #  endif
  1533.  
  1534. #  ifdef KIT_PM_WM_WINDOWPOSCHANGED
  1535.   case WM_WINDOWPOSCHANGED              : messageName = "WM_WINDOWPOSCHANGED";  break; //0x0047
  1536. #  endif
  1537.  
  1538. #  ifdef KIT_PM_WM_POWER
  1539.   case WM_POWER                         : messageName = "WM_POWER";             break; //0x0048
  1540. #  endif
  1541.  
  1542. #  ifdef KIT_PM_WM_COPYDATA
  1543.   case WM_COPYDATA                      : messageName = "WM_COPYDATA";          break; //0x004A
  1544. #  endif
  1545.  
  1546. #  ifdef KIT_PM_WM_CANCELJOURNAL
  1547.   case WM_CANCELJOURNAL                 : messageName = "WM_CANCELJOURNAL";     break; //0x004B
  1548. #  endif
  1549.  
  1550.  
  1551. #if(WINVER >= 0x0400)
  1552. #  ifdef KIT_PM_WM_NOTIFY
  1553.   case WM_NOTIFY                        : messageName = "WM_NOTIFY";            break; //0x004E
  1554. #  endif
  1555.  
  1556. #  ifdef KIT_PM_WM_INPUTLANGCHANGEREQUEST
  1557.   case WM_INPUTLANGCHANGEREQUEST        : messageName = "WM_INPUTLANGCHANGEREQUEST"; break; //0x0050
  1558. #  endif
  1559.  
  1560. #  ifdef KIT_PM_WM_INPUTLANGCHANGE
  1561.   case WM_INPUTLANGCHANGE               : messageName = "WM_INPUTLANGCHANGE";   break; //0x0051
  1562. #  endif
  1563.  
  1564. #  ifdef KIT_PM_WM_TCARD
  1565.   case WM_TCARD                         : messageName = "WM_TCARD";             break; //0x0052
  1566. #  endif
  1567.  
  1568. #  ifdef KIT_PM_WM_HELP
  1569.   case WM_HELP                          : messageName = "WM_HELP";              break; //0x0053
  1570. #  endif
  1571.  
  1572. #  ifdef KIT_PM_WM_USERCHANGED
  1573.   case WM_USERCHANGED                   : messageName = "WM_USERCHANGED";       break; //0x0054
  1574. #  endif
  1575.  
  1576. #  ifdef KIT_PM_WM_NOTIFYFORMAT
  1577.   case WM_NOTIFYFORMAT                  : messageName = "WM_NOTIFYFORMAT";      break; //0x0055
  1578. #  endif
  1579.  
  1580. #  ifdef KIT_PM_WM_CONTEXTMENU
  1581.   case WM_CONTEXTMENU                   : messageName = "WM_CONTEXTMENU";       break; //0x007B
  1582. #  endif
  1583.  
  1584. #  ifdef KIT_PM_WM_STYLECHANGING
  1585.   case WM_STYLECHANGING                 : messageName = "WM_STYLECHANGING";     break; //0x007C
  1586. #  endif
  1587.  
  1588. #  ifdef KIT_PM_WM_STYLECHANGED
  1589.   case WM_STYLECHANGED                  : messageName = "WM_STYLECHANGED";      break; //0x007D
  1590. #  endif
  1591.  
  1592. #  ifdef KIT_PM_WM_DISPLAYCHANGE
  1593.   case WM_DISPLAYCHANGE                 : messageName = "WM_DISPLAYCHANGE";     break; //0x007E
  1594. #  endif
  1595.  
  1596. #  ifdef KIT_PM_WM_GETICON
  1597.   case WM_GETICON                       : messageName = "WM_GETICON";           break; //0x007F
  1598. #  endif
  1599.  
  1600. #  ifdef KIT_PM_WM_SETICON
  1601.   case WM_SETICON                       : messageName = "WM_SETICON";           break; //0x0080
  1602. #  endif
  1603. #endif /* WINVER >= 0x0400 */
  1604.  
  1605.  
  1606. #  ifdef KIT_PM_WM_NCCREATE
  1607.   case WM_NCCREATE                      : messageName = "WM_NCCREATE";          break; //0x0081
  1608. #  endif
  1609.  
  1610. #  ifdef KIT_PM_WM_NCDESTROY
  1611.   case WM_NCDESTROY                     : messageName = "WM_NCDESTROY";         break; //0x0082
  1612. #  endif
  1613.  
  1614. #  ifdef KIT_PM_WM_NCCALCSIZE
  1615.   case WM_NCCALCSIZE                    : messageName = "WM_NCCALCSIZE";        break; //0x0083
  1616. #  endif
  1617.  
  1618. #  ifdef KIT_PM_WM_NCHITTEST
  1619.   case WM_NCHITTEST                     : messageName = "WM_NCHITTEST";         break; //0x0084
  1620. #  endif
  1621.  
  1622. #  ifdef KIT_PM_WM_NCPAINT
  1623.   case WM_NCPAINT                       : messageName = "WM_NCPAINT";           break; //0x0085
  1624. #  endif
  1625.  
  1626. #  ifdef KIT_PM_WM_NCACTIVATE
  1627.   case WM_NCACTIVATE                    : messageName = "WM_NCACTIVATE";        break; //0x0086
  1628. #  endif
  1629.  
  1630. #  ifdef KIT_PM_WM_GETDLGCODE
  1631.   case WM_GETDLGCODE                    : messageName = "WM_GETDLGCODE";        break; //0x0087
  1632. #  endif
  1633.  
  1634.  
  1635. #ifndef _WIN32_WCE
  1636. #  ifdef KIT_PM_WM_SYNCPAINT
  1637.   case WM_SYNCPAINT                     : messageName = "WM_SYNCPAINT";         break; //0x0088
  1638. #  endif
  1639. #endif
  1640.  
  1641.  
  1642. #  ifdef KIT_PM_WM_NCMOUSEMOVE
  1643.   case WM_NCMOUSEMOVE                   : messageName = "WM_NCMOUSEMOVE";       break; //0x00A0
  1644. #  endif
  1645.  
  1646. #  ifdef KIT_PM_WM_NCLBUTTONDOWN
  1647.   case WM_NCLBUTTONDOWN                 : messageName = "WM_NCLBUTTONDOWN";     break; //0x00A1
  1648. #  endif
  1649.  
  1650. #  ifdef KIT_PM_WM_NCLBUTTONUP
  1651.   case WM_NCLBUTTONUP                   : messageName = "WM_NCLBUTTONUP";       break; //0x00A2
  1652. #  endif
  1653.  
  1654. #  ifdef KIT_PM_WM_NCLBUTTONDBLCLK
  1655.   case WM_NCLBUTTONDBLCLK               : messageName = "WM_NCLBUTTONDBLCLK";   break; //0x00A3
  1656. #  endif
  1657.  
  1658. #  ifdef KIT_PM_WM_NCRBUTTONDOWN
  1659.   case WM_NCRBUTTONDOWN                 : messageName = "WM_NCRBUTTONDOWN";     break; //0x00A4
  1660. #  endif
  1661.  
  1662. #  ifdef KIT_PM_WM_NCRBUTTONUP
  1663.   case WM_NCRBUTTONUP                   : messageName = "WM_NCRBUTTONUP";       break; //0x00A5
  1664. #  endif
  1665.  
  1666. #  ifdef KIT_PM_WM_NCRBUTTONDBLCLK
  1667.   case WM_NCRBUTTONDBLCLK               : messageName = "WM_NCRBUTTONDBLCLK";   break; //0x00A6
  1668. #  endif
  1669.  
  1670. #  ifdef KIT_PM_WM_NCMBUTTONDOWN
  1671.   case WM_NCMBUTTONDOWN                 : messageName = "WM_NCMBUTTONDOWN";     break; //0x00A7
  1672. #  endif
  1673.  
  1674. #  ifdef KIT_PM_WM_NCMBUTTONUP
  1675.   case WM_NCMBUTTONUP                   : messageName = "WM_NCMBUTTONUP";       break; //0x00A8
  1676. #  endif
  1677.  
  1678. #  ifdef KIT_PM_WM_NCMBUTTONDBLCLK
  1679.   case WM_NCMBUTTONDBLCLK               : messageName = "WM_NCMBUTTONDBLCLK";   break; //0x00A9
  1680. #  endif
  1681.  
  1682.  
  1683. #if(_WIN32_WINNT >= 0x0500)
  1684. #  ifdef KIT_PM_WM_NCXBUTTONDOWN
  1685.   case WM_NCXBUTTONDOWN                 : messageName = "WM_NCXBUTTONDOWN";     break; //0x00AB
  1686. #  endif
  1687.  
  1688. #  ifdef KIT_PM_WM_NCXBUTTONUP
  1689.   case WM_NCXBUTTONUP                   : messageName = "WM_NCXBUTTONUP";       break; //0x00AC
  1690. #  endif
  1691.  
  1692. #  ifdef KIT_PM_WM_NCXBUTTONDBLCLK
  1693.   case WM_NCXBUTTONDBLCLK               : messageName = "WM_NCXBUTTONDBLCLK";   break; //0x00AD
  1694. #  endif
  1695. #endif /* _WIN32_WINNT >= 0x0500 */
  1696.  
  1697.  
  1698. #if(_WIN32_WINNT >= 0x0501)
  1699. #  ifdef KIT_PM_WM_INPUT_DEVICE_CHANGE
  1700.   case WM_INPUT_DEVICE_CHANGE           : messageName = "WM_INPUT_DEVICE_CHANGE"; break; //0x00FE
  1701. #  endif
  1702.  
  1703. #  ifdef KIT_PM_WM_INPUT
  1704.   case WM_INPUT                         : messageName = "WM_INPUT";             break; //0x00FF
  1705. #  endif
  1706. #endif /* _WIN32_WINNT >= 0x0501 */
  1707.  
  1708.  
  1709. #  ifdef KIT_PM_WM_KEYDOWN
  1710.   case WM_KEYDOWN                       : messageName = "WM_KEYDOWN";           break; //0x0100
  1711. #  endif
  1712.  
  1713. #  ifdef KIT_PM_WM_KEYUP
  1714.   case WM_KEYUP                         : messageName = "WM_KEYUP";             break; //0x0101
  1715. #  endif
  1716.  
  1717. #  ifdef KIT_PM_WM_CHAR
  1718.   case WM_CHAR                          : messageName = "WM_CHAR";              break; //0x0102
  1719. #  endif
  1720.  
  1721. #  ifdef KIT_PM_WM_DEADCHAR
  1722.   case WM_DEADCHAR                      : messageName = "WM_DEADCHAR";          break; //0x0103
  1723. #  endif
  1724.  
  1725. #  ifdef KIT_PM_WM_SYSKEYDOWN
  1726.   case WM_SYSKEYDOWN                    : messageName = "WM_SYSKEYDOWN";        break; //0x0104
  1727. #  endif
  1728.  
  1729. #  ifdef KIT_PM_WM_SYSKEYUP
  1730.   case WM_SYSKEYUP                      : messageName = "WM_SYSKEYUP";          break; //0x0105
  1731. #  endif
  1732.  
  1733. #  ifdef KIT_PM_WM_SYSCHAR
  1734.   case WM_SYSCHAR                       : messageName = "WM_SYSCHAR";           break; //0x0106
  1735. #  endif
  1736.  
  1737. #  ifdef KIT_PM_WM_SYSDEADCHAR
  1738.   case WM_SYSDEADCHAR                   : messageName = "WM_SYSDEADCHAR";       break; //0x0107
  1739. #  endif
  1740.  
  1741.  
  1742. #if(_WIN32_WINNT >= 0x0501)
  1743. #  ifdef KIT_PM_WM_UNICHAR
  1744.   case WM_UNICHAR                       : messageName = "WM_UNICHAR";           break; //0x0109
  1745. #  endif
  1746. #endif /* _WIN32_WINNT >= 0x0501 */
  1747.  
  1748.  
  1749. #if(WINVER >= 0x0400)
  1750. #  ifdef KIT_PM_WM_IME_STARTCOMPOSITION
  1751.   case WM_IME_STARTCOMPOSITION          : messageName = "WM_IME_STARTCOMPOSITION"; break; //0x010D
  1752. #  endif
  1753.  
  1754. #  ifdef KIT_PM_WM_IME_ENDCOMPOSITION
  1755.   case WM_IME_ENDCOMPOSITION            : messageName = "WM_IME_ENDCOMPOSITION";   break; //0x010E
  1756. #  endif
  1757.  
  1758. #  ifdef KIT_PM_WM_IME_COMPOSITION
  1759.   case WM_IME_COMPOSITION               : messageName = "WM_IME_COMPOSITION";      break; //0x010F
  1760. #  endif
  1761. #endif /* WINVER >= 0x0400 */
  1762.  
  1763.  
  1764. #  ifdef KIT_PM_WM_INITDIALOG
  1765.   case WM_INITDIALOG                    : messageName = "WM_INITDIALOG";        break; //0x0110
  1766. #  endif
  1767.  
  1768. #  ifdef KIT_PM_WM_COMMAND
  1769.   case WM_COMMAND                       : messageName = "WM_COMMAND";           break; //0x0111
  1770. #  endif
  1771.  
  1772. #  ifdef KIT_PM_WM_SYSCOMMAND
  1773.   case WM_SYSCOMMAND                    : messageName = "WM_SYSCOMMAND";        break; //0x0112
  1774. #  endif
  1775.  
  1776. #  ifdef KIT_PM_WM_TIMER
  1777.   case WM_TIMER                         : messageName = "WM_TIMER";             break; //0x0113
  1778. #  endif
  1779.  
  1780. #  ifdef KIT_PM_WM_HSCROLL
  1781.   case WM_HSCROLL                       : messageName = "WM_HSCROLL";           break; //0x0114
  1782. #  endif
  1783.  
  1784. #  ifdef KIT_PM_WM_VSCROLL
  1785.   case WM_VSCROLL                       : messageName = "WM_VSCROLL";           break; //0x0115
  1786. #  endif
  1787.  
  1788. #  ifdef KIT_PM_WM_INITMENU
  1789.   case WM_INITMENU                      : messageName = "WM_INITMENU";          break; //0x0116
  1790. #  endif
  1791.  
  1792. #  ifdef KIT_PM_WM_INITMENUPOPUP
  1793.   case WM_INITMENUPOPUP                 : messageName = "WM_INITMENUPOPUP";     break; //0x0117
  1794. #  endif
  1795.  
  1796.  
  1797. #if(WINVER >= 0x0601)
  1798. #  ifdef KIT_PM_WM_GESTURE
  1799.   case WM_GESTURE                       : messageName = "WM_GESTURE";           break; //0x0119
  1800. #  endif
  1801.  
  1802. #  ifdef KIT_PM_WM_GESTURENOTIFY
  1803.   case WM_GESTURENOTIFY                 : messageName = "WM_GESTURENOTIFY";     break; //0x011A
  1804. #  endif
  1805. #endif /* WINVER >= 0x0601 */
  1806.  
  1807.  
  1808. #  ifdef KIT_PM_WM_MENUSELECT
  1809.   case WM_MENUSELECT                    : messageName = "WM_MENUSELECT";        break; //0x011F
  1810. #  endif
  1811.  
  1812. #  ifdef KIT_PM_WM_MENUCHAR
  1813.   case WM_MENUCHAR                      : messageName = "WM_MENUCHAR";          break; //0x0120
  1814. #  endif
  1815.  
  1816. #  ifdef KIT_PM_WM_ENTERIDLE
  1817.   case WM_ENTERIDLE                     : messageName = "WM_ENTERIDLE";         break; //0x0121
  1818. #  endif
  1819.  
  1820.  
  1821. /* WHY IS THIS SET UP THIS WAY! */
  1822. #if(WINVER >= 0x0500)
  1823. #ifndef _WIN32_WCE
  1824. #  ifdef KIT_PM_WM_MENURBUTTONUP
  1825.   case WM_MENURBUTTONUP                 : messageName = "WM_MENURBUTTONUP";     break; //0x0122
  1826. #  endif
  1827.  
  1828. #  ifdef KIT_PM_WM_MENUDRAG
  1829.   case WM_MENUDRAG                      : messageName = "WM_MENUDRAG";          break; //0x0123
  1830. #  endif
  1831.  
  1832. #  ifdef KIT_PM_WM_MENUGETOBJECT
  1833.   case WM_MENUGETOBJECT                 : messageName = "WM_MENUGETOBJECT";     break; //0x0124
  1834. #  endif
  1835.  
  1836. #  ifdef KIT_PM_WM_UNINITMENUPOPUP
  1837.   case WM_UNINITMENUPOPUP               : messageName = "WM_UNINITMENUPOPUP";   break; //0x0125
  1838. #  endif
  1839.  
  1840. #  ifdef KIT_PM_WM_MENUCOMMAND
  1841.   case WM_MENUCOMMAND                   : messageName = "WM_MENUCOMMAND";       break; //0x0126
  1842. #  endif
  1843. #ifndef _WIN32_WCE
  1844. #if(_WIN32_WINNT >= 0x0500)
  1845. #  ifdef KIT_PM_WM_CHANGEUISTATE
  1846.   case WM_CHANGEUISTATE                 : messageName = "WM_CHANGEUISTATE";     break; //0x0127
  1847. #  endif
  1848.  
  1849. #  ifdef KIT_PM_WM_UPDATEUISTATE
  1850.   case WM_UPDATEUISTATE                 : messageName = "WM_UPDATEUISTATE";     break; //0x0128
  1851. #  endif
  1852.  
  1853. #  ifdef KIT_PM_WM_QUERYUISTATE
  1854.   case WM_QUERYUISTATE                  : messageName = "WM_QUERYUISTATE";      break; //0x0129
  1855. #  endif
  1856. #endif /* _WIN32_WINNT >= 0x0500 */
  1857. #endif
  1858.  
  1859. #endif
  1860. #endif /* WINVER >= 0x0500 */
  1861. /* WHY IS THIS SET UP THIS WAY! */
  1862.  
  1863.  
  1864.  
  1865. #  ifdef KIT_PM_WM_CTLCOLORMSGBOX
  1866.   case WM_CTLCOLORMSGBOX                : messageName = "WM_CTLCOLORMSGBOX";    break; //0x0132
  1867. #  endif
  1868.  
  1869. #  ifdef KIT_PM_WM_CTLCOLOREDIT
  1870.   case WM_CTLCOLOREDIT                  : messageName = "WM_CTLCOLOREDIT";      break; //0x0133
  1871. #  endif
  1872.  
  1873. #  ifdef KIT_PM_WM_CTLCOLORLISTBOX
  1874.   case WM_CTLCOLORLISTBOX               : messageName = "WM_CTLCOLORLISTBOX";   break; //0x0134
  1875. #  endif
  1876.  
  1877. #  ifdef KIT_PM_WM_CTLCOLORBTN
  1878.   case WM_CTLCOLORBTN                   : messageName = "WM_CTLCOLORBTN";       break; //0x0135
  1879. #  endif
  1880.  
  1881. #  ifdef KIT_PM_WM_CTLCOLORDLG
  1882.   case WM_CTLCOLORDLG                   : messageName = "WM_CTLCOLORDLG";       break; //0x0136
  1883. #  endif
  1884.  
  1885. #  ifdef KIT_PM_WM_CTLCOLORSCROLLBAR
  1886.   case WM_CTLCOLORSCROLLBAR             : messageName = "WM_CTLCOLORSCROLLBAR"; break; //0x0137
  1887. #  endif
  1888.  
  1889. #  ifdef KIT_PM_WM_CTLCOLORSTATIC
  1890.   case WM_CTLCOLORSTATIC                : messageName = "WM_CTLCOLORSTATIC";    break; //0x0138
  1891. #  endif
  1892.  
  1893. #  ifdef KIT_PM_MN_GETHMENU
  1894.   case MN_GETHMENU                      : messageName = "MN_GETHMENU";          break; //0x01E1
  1895. #  endif
  1896.  
  1897. #  ifdef KIT_PM_WM_MOUSEMOVE
  1898.   case WM_MOUSEMOVE                     : messageName = "WM_MOUSEMOVE";         break; //0x0200
  1899. #  endif
  1900.  
  1901. #  ifdef KIT_PM_WM_LBUTTONDOWN
  1902.   case WM_LBUTTONDOWN                   : messageName = "WM_LBUTTONDOWN";       break; //0x0201
  1903. #  endif
  1904.  
  1905. #  ifdef KIT_PM_WM_LBUTTONUP
  1906.   case WM_LBUTTONUP                     : messageName = "WM_LBUTTONUP";         break; //0x0202
  1907. #  endif
  1908.  
  1909. #  ifdef KIT_PM_WM_LBUTTONDBLCLK
  1910.   case WM_LBUTTONDBLCLK                 : messageName = "WM_LBUTTONDBLCLK";     break; //0x0203
  1911. #  endif
  1912.  
  1913. #  ifdef KIT_PM_WM_RBUTTONDOWN
  1914.   case WM_RBUTTONDOWN                   : messageName = "WM_RBUTTONDOWN";       break; //0x0204
  1915. #  endif
  1916.  
  1917. #  ifdef KIT_PM_WM_RBUTTONUP
  1918.   case WM_RBUTTONUP                     : messageName = "WM_RBUTTONUP";         break; //0x0205
  1919. #  endif
  1920.  
  1921. #  ifdef KIT_PM_WM_RBUTTONDBLCLK
  1922.   case WM_RBUTTONDBLCLK                 : messageName = "WM_RBUTTONDBLCLK";     break; //0x0206
  1923. #  endif
  1924.  
  1925. #  ifdef KIT_PM_WM_MBUTTONDOWN
  1926.   case WM_MBUTTONDOWN                   : messageName = "WM_MBUTTONDOWN";       break; //0x0207
  1927. #  endif
  1928.  
  1929. #  ifdef KIT_PM_WM_MBUTTONUP
  1930.   case WM_MBUTTONUP                     : messageName = "WM_MBUTTONUP";         break; //0x0208
  1931. #  endif
  1932.  
  1933. #  ifdef KIT_PM_WM_MBUTTONDBLCLK
  1934.   case WM_MBUTTONDBLCLK                 : messageName = "WM_MBUTTONDBLCLK";     break; //0x0209
  1935. #  endif
  1936.  
  1937.  
  1938. #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
  1939. #  ifdef KIT_PM_WM_MOUSEWHEEL
  1940.   case WM_MOUSEWHEEL                    : messageName = "WM_MOUSEWHEEL";        break; //0x020A
  1941. #  endif
  1942. #endif
  1943.  
  1944.  
  1945. #if (_WIN32_WINNT >= 0x0500)
  1946. #  ifdef KIT_PM_WM_XBUTTONDOWN
  1947.   case WM_XBUTTONDOWN                   : messageName = "WM_XBUTTONDOWN";       break; //0x020B
  1948. #  endif
  1949.  
  1950. #  ifdef KIT_PM_WM_XBUTTONUP
  1951.   case WM_XBUTTONUP                     : messageName = "WM_XBUTTONUP";         break; //0x020C
  1952. #  endif
  1953.  
  1954. #  ifdef KIT_PM_WM_XBUTTONDBLCLK
  1955.   case WM_XBUTTONDBLCLK                 : messageName = "WM_XBUTTONDBLCLK";     break; //0x020D
  1956. #  endif
  1957. #endif
  1958.  
  1959.  
  1960. #  ifdef KIT_PM_WM_PARENTNOTIFY
  1961.   case WM_PARENTNOTIFY                  : messageName = "WM_PARENTNOTIFY";      break; //0x0210
  1962. #  endif
  1963.  
  1964. #  ifdef KIT_PM_WM_ENTERMENULOOP
  1965.   case WM_ENTERMENULOOP                 : messageName = "WM_ENTERMENULOOP";     break; //0x0211
  1966. #  endif
  1967.  
  1968. #  ifdef KIT_PM_WM_EXITMENULOOP
  1969.   case WM_EXITMENULOOP                  : messageName = "WM_EXITMENULOOP";      break; //0x0212
  1970. #  endif
  1971.  
  1972.  
  1973. #if(WINVER >= 0x0400)
  1974. #  ifdef KIT_PM_WM_NEXTMENU
  1975.   case WM_NEXTMENU                      : messageName = "WM_NEXTMENU";          break; //0x0213
  1976. #  endif
  1977.  
  1978. #  ifdef KIT_PM_WM_SIZING
  1979.   case WM_SIZING                        : messageName = "WM_SIZING";            break; //0x0214
  1980. #  endif
  1981.  
  1982. #  ifdef KIT_PM_WM_CAPTURECHANGED
  1983.   case WM_CAPTURECHANGED                : messageName = "WM_CAPTURECHANGED";    break; //0x0215
  1984. #  endif
  1985.  
  1986. #  ifdef KIT_PM_WM_MOVING
  1987.   case WM_MOVING                        : messageName = "WM_MOVING";            break; //0x0216
  1988. #  endif
  1989.  
  1990. #  ifdef KIT_PM_WM_POWERBROADCAST
  1991.   case WM_POWERBROADCAST                : messageName = "WM_POWERBROADCAST";    break; //0x0218
  1992. #  endif
  1993.  
  1994. #  ifdef KIT_PM_WM_DEVICECHANGE
  1995.   case WM_DEVICECHANGE                  : messageName = "WM_DEVICECHANGE";      break; //0x0219
  1996. #  endif
  1997. #endif /* WINVER >= 0x0400 */
  1998.  
  1999.  
  2000. #  ifdef KIT_PM_WM_MDICREATE
  2001.   case WM_MDICREATE                     : messageName = "WM_MDICREATE";         break; //0x0220
  2002. #  endif
  2003.  
  2004. #  ifdef KIT_PM_WM_MDIDESTROY
  2005.   case WM_MDIDESTROY                    : messageName = "WM_MDIDESTROY";        break; //0x0221
  2006. #  endif
  2007.  
  2008. #  ifdef KIT_PM_WM_MDIACTIVATE
  2009.   case WM_MDIACTIVATE                   : messageName = "WM_MDIACTIVATE";       break; //0x0222
  2010. #  endif
  2011.  
  2012. #  ifdef KIT_PM_WM_MDIRESTORE
  2013.   case WM_MDIRESTORE                    : messageName = "WM_MDIRESTORE";        break; //0x0223
  2014. #  endif
  2015.  
  2016. #  ifdef KIT_PM_WM_MDINEXT
  2017.   case WM_MDINEXT                       : messageName = "WM_MDINEXT";           break; //0x0224
  2018. #  endif
  2019.  
  2020. #  ifdef KIT_PM_WM_MDIMAXIMIZE
  2021.   case WM_MDIMAXIMIZE                   : messageName = "WM_MDIMAXIMIZE";       break; //0x0225
  2022. #  endif
  2023.  
  2024. #  ifdef KIT_PM_WM_MDITILE
  2025.   case WM_MDITILE                       : messageName = "WM_MDITILE";           break; //0x0226
  2026. #  endif
  2027.  
  2028. #  ifdef KIT_PM_WM_MDICASCADE
  2029.   case WM_MDICASCADE                    : messageName = "WM_MDICASCADE";        break; //0x0227
  2030. #  endif
  2031.  
  2032. #  ifdef KIT_PM_WM_MDIICONARRANGE
  2033.   case WM_MDIICONARRANGE                : messageName = "WM_MDIICONARRANGE";    break; //0x0228
  2034. #  endif
  2035.  
  2036. #  ifdef KIT_PM_WM_MDIGETACTIVE
  2037.   case WM_MDIGETACTIVE                  : messageName = "WM_MDIGETACTIVE";      break; //0x0229
  2038. #  endif
  2039.  
  2040. #  ifdef KIT_PM_WM_MDISETMENU
  2041.   case WM_MDISETMENU                    : messageName = "WM_MDISETMENU";        break; //0x0230
  2042. #  endif
  2043.  
  2044. #  ifdef KIT_PM_WM_ENTERSIZEMOVE
  2045.   case WM_ENTERSIZEMOVE                 : messageName = "WM_ENTERSIZEMOVE";     break; //0x0231
  2046. #  endif
  2047.  
  2048. #  ifdef KIT_PM_WM_EXITSIZEMOVE
  2049.   case WM_EXITSIZEMOVE                  : messageName = "WM_EXITSIZEMOVE";      break; //0x0232
  2050. #  endif
  2051.  
  2052. #  ifdef KIT_PM_WM_DROPFILES
  2053.   case WM_DROPFILES                     : messageName = "WM_DROPFILES";         break; //0x0233
  2054. #  endif
  2055.  
  2056. #  ifdef KIT_PM_WM_MDIREFRESHMENU
  2057.   case WM_MDIREFRESHMENU                : messageName = "WM_MDIREFRESHMENU";    break; //0x0234
  2058. #  endif
  2059.  
  2060.  
  2061. #if(WINVER >= 0x0602)
  2062. #  ifdef KIT_PM_WM_POINTERDEVICECHANGE
  2063.   case WM_POINTERDEVICECHANGE           : messageName = "WM_POINTERDEVICECHANGE";     break; //0x0238
  2064. #  endif
  2065.  
  2066. #  ifdef KIT_PM_WM_POINTERDEVICEINRANGE
  2067.   case WM_POINTERDEVICEINRANGE          : messageName = "WM_POINTERDEVICEINRANGE";    break; //0x0239
  2068. #  endif
  2069.  
  2070. #  ifdef KIT_PM_WM_POINTERDEVICEOUTOFRANGE
  2071.   case WM_POINTERDEVICEOUTOFRANGE       : messageName = "WM_POINTERDEVICEOUTOFRANGE"; break; //0x023A
  2072. #  endif
  2073. #endif /* WINVER >= 0x0602 */
  2074.  
  2075.  
  2076. #if(WINVER >= 0x0601)
  2077. #  ifdef KIT_PM_WM_TOUCH
  2078.   case WM_TOUCH                         : messageName = "WM_TOUCH";             break; //0x0240
  2079. #  endif
  2080. #endif /* WINVER >= 0x0601 */
  2081.  
  2082.  
  2083. #if(WINVER >= 0x0602)
  2084. #  ifdef KIT_PM_WM_NCPOINTERUPDATE
  2085.   case WM_NCPOINTERUPDATE               : messageName = "WM_NCPOINTERUPDATE";   break; //0x0241
  2086. #  endif
  2087.  
  2088. #  ifdef KIT_PM_WM_NCPOINTERDOWN
  2089.   case WM_NCPOINTERDOWN                 : messageName = "WM_NCPOINTERDOWN";     break; //0x0242
  2090. #  endif
  2091.  
  2092. #  ifdef KIT_PM_WM_NCPOINTERUP
  2093.   case WM_NCPOINTERUP                   : messageName = "WM_NCPOINTERUP";       break; //0x0243
  2094. #  endif
  2095.  
  2096. #  ifdef KIT_PM_WM_POINTERUPDATE
  2097.   case WM_POINTERUPDATE                 : messageName = "WM_POINTERUPDATE";     break; //0x0245
  2098. #  endif
  2099.  
  2100. #  ifdef KIT_PM_WM_POINTERDOWN
  2101.   case WM_POINTERDOWN                   : messageName = "WM_POINTERDOWN";       break; //0x0246
  2102. #  endif
  2103.  
  2104. #  ifdef KIT_PM_WM_POINTERUP
  2105.   case WM_POINTERUP                     : messageName = "WM_POINTERUP";         break; //0x0247
  2106. #  endif
  2107.  
  2108. #  ifdef KIT_PM_WM_POINTERENTER
  2109.   case WM_POINTERENTER                  : messageName = "WM_POINTERENTER";      break; //0x0249
  2110. #  endif
  2111.  
  2112. #  ifdef KIT_PM_WM_POINTERLEAVE
  2113.   case WM_POINTERLEAVE                  : messageName = "WM_POINTERLEAVE";      break; //0x024A
  2114. #  endif
  2115.  
  2116. #  ifdef KIT_PM_WM_POINTERACTIVATE
  2117.   case WM_POINTERACTIVATE               : messageName = "WM_POINTERACTIVATE";   break; //0x024B
  2118. #  endif
  2119.  
  2120. #  ifdef KIT_PM_WM_POINTERCAPTURECHANGED
  2121.   case WM_POINTERCAPTURECHANGED         : messageName = "WM_POINTERCAPTURECHANGED"; break; //0x024C
  2122. #  endif
  2123.  
  2124. #  ifdef KIT_PM_WM_TOUCHHITTESTING
  2125.   case WM_TOUCHHITTESTING               : messageName = "WM_TOUCHHITTESTING";   break; //0x024D
  2126. #  endif
  2127.  
  2128. #  ifdef KIT_PM_WM_POINTERWHEEL
  2129.   case WM_POINTERWHEEL                  : messageName = "WM_POINTERWHEEL";      break; //0x024E
  2130. #  endif
  2131.  
  2132. #  ifdef KIT_PM_WM_POINTERHWHEEL
  2133.   case WM_POINTERHWHEEL                 : messageName = "WM_POINTERHWHEEL";     break; //0x024F
  2134. #  endif
  2135.  
  2136. #  ifdef KIT_PM_DM_POINTERHITTEST
  2137.   case DM_POINTERHITTEST                : messageName = "DM_POINTERHITTEST";    break; //0x0250
  2138. #  endif
  2139.  
  2140. #  ifdef KIT_PM_WM_POINTERROUTEDTO
  2141.   case WM_POINTERROUTEDTO               : messageName = "WM_POINTERROUTEDTO";   break; //0x0251
  2142. #  endif
  2143.  
  2144. #  ifdef KIT_PM_WM_POINTERROUTEDAWAY
  2145.   case WM_POINTERROUTEDAWAY             : messageName = "WM_POINTERROUTEDAWAY"; break; //0x0252
  2146. #  endif
  2147.  
  2148. #  ifdef KIT_PM_WM_POINTERROUTEDRELEASED2
  2149.   case WM_POINTERROUTEDRELEASED         : messageName = "WM_POINTERROUTEDRELEASED"; break; //0x0253
  2150. #  endif
  2151. #endif /* WINVER >= 0x0602 */
  2152.  
  2153.  
  2154. #if(WINVER >= 0x0400)
  2155. #  ifdef KIT_PM_WM_IME_SETCONTEXT
  2156.   case WM_IME_SETCONTEXT                : messageName = "WM_IME_SETCONTEXT";    break; //0x0281
  2157. #  endif
  2158.  
  2159. #  ifdef KIT_PM_WM_IME_NOTIFY
  2160.   case WM_IME_NOTIFY                    : messageName = "WM_IME_NOTIFY";        break; //0x0282
  2161. #  endif
  2162.  
  2163. #  ifdef KIT_PM_WM_IME_CONTROL
  2164.   case WM_IME_CONTROL                   : messageName = "WM_IME_CONTROL";       break; //0x0283
  2165. #  endif
  2166.  
  2167. #  ifdef KIT_PM_WM_IME_COMPOSITIONFULL
  2168.   case WM_IME_COMPOSITIONFULL           : messageName = "WM_IME_COMPOSITIONFULL"; break; //0x0284
  2169. #  endif
  2170.  
  2171. #  ifdef KIT_PM_WM_IME_SELECT
  2172.   case WM_IME_SELECT                    : messageName = "WM_IME_SELECT";        break; //0x0285
  2173. #  endif
  2174.  
  2175. #  ifdef KIT_PM_WM_IME_CHAR
  2176.   case WM_IME_CHAR                      : messageName = "WM_IME_CHAR";          break; //0x0286
  2177. #  endif
  2178. #endif /* WINVER >= 0x0400 */
  2179.  
  2180.  
  2181. #if(WINVER >= 0x0500)
  2182. #  ifdef KIT_PM_WM_IME_REQUEST
  2183.   case WM_IME_REQUEST                   : messageName = "WM_IME_REQUEST";       break; //0x0288
  2184. #  endif
  2185. #endif /* WINVER >= 0x0500 */
  2186.  
  2187.  
  2188. #if(WINVER >= 0x0400)
  2189. #  ifdef KIT_PM_WM_IME_KEYDOWN
  2190.   case WM_IME_KEYDOWN                   : messageName = "WM_IME_KEYDOWN";       break; //0x0290
  2191. #  endif
  2192.  
  2193. #  ifdef KIT_PM_WM_IME_KEYUP
  2194.   case WM_IME_KEYUP                     : messageName = "WM_IME_KEYUP";         break; //0x0291
  2195. #  endif
  2196. #endif /* WINVER >= 0x0400 */
  2197.  
  2198.  
  2199. #if((_WIN32_WINNT >= 0x0400) || (WINVER >= 0x0500))
  2200. #  ifdef KIT_PM_WM_MOUSEHOVER
  2201.   case WM_MOUSEHOVER                    : messageName = "WM_MOUSEHOVER";        break; //0x02A1
  2202. #  endif
  2203.  
  2204. #  ifdef KIT_PM_WM_MOUSELEAVE
  2205.   case WM_MOUSELEAVE                    : messageName = "WM_MOUSELEAVE";        break; //0x02A3
  2206. #  endif
  2207. #endif
  2208.  
  2209.  
  2210. #if(WINVER >= 0x0500)
  2211. #  ifdef KIT_PM_WM_NCMOUSEHOVER
  2212.   case WM_NCMOUSEHOVER                  : messageName = "WM_NCMOUSEHOVER";      break; //0x02A0
  2213. #  endif
  2214.  
  2215. #  ifdef KIT_PM_WM_NCMOUSELEAVE
  2216.   case WM_NCMOUSELEAVE                  : messageName = "WM_NCMOUSELEAVE";      break; //0x02A2
  2217. #  endif
  2218. #endif /* WINVER >= 0x0500 */
  2219.  
  2220.  
  2221. #if(_WIN32_WINNT >= 0x0501)
  2222. #  ifdef KIT_PM_WM_WTSSESSION_CHANGE
  2223.   case WM_WTSSESSION_CHANGE             : messageName = "WM_WTSSESSION_CHANGE"; break; //0x02B1
  2224. #  endif
  2225. #endif /* _WIN32_WINNT >= 0x0501 */
  2226.  
  2227.  
  2228. #if(WINVER >= 0x0601)
  2229. #  ifdef KIT_PM_WM_DPICHANGED
  2230.   case WM_DPICHANGED                    : messageName = "WM_DPICHANGED";        break; //0x02E0
  2231. #  endif
  2232. #endif /* WINVER >= 0x0601 */
  2233.  
  2234.  
  2235. #if(WINVER >= 0x0605)
  2236. #  ifdef KIT_PM_WM_DPICHANGED_BEFOREPARENT
  2237.   case WM_DPICHANGED_BEFOREPARENT       : messageName = "WM_DPICHANGED_BEFOREPARENT"; break; //0x02E2
  2238. #  endif
  2239.  
  2240. #  ifdef KIT_PM_WM_DPICHANGED_AFTERPARENT
  2241.   case WM_DPICHANGED_AFTERPARENT        : messageName = "WM_DPICHANGED_AFTERPARENT";  break; //0x02E3
  2242. #  endif
  2243.  
  2244. #  ifdef KIT_PM_WM_GETDPISCALEDSIZE
  2245.   case WM_GETDPISCALEDSIZE              : messageName = "WM_GETDPISCALEDSIZE";  break; //0x02E4
  2246. #  endif
  2247. #endif /* WINVER >= 0x0605 */
  2248.  
  2249.  
  2250. #  ifdef KIT_PM_WM_CUT
  2251.   case WM_CUT                           : messageName = "WM_CUT";               break; //0x0300
  2252. #  endif
  2253.  
  2254. #  ifdef KIT_PM_WM_COPY
  2255.   case WM_COPY                          : messageName = "WM_COPY";              break; //0x0301
  2256. #  endif
  2257.  
  2258. #  ifdef KIT_PM_WM_PASTE
  2259.   case WM_PASTE                         : messageName = "WM_PASTE";             break; //0x0302
  2260. #  endif
  2261.  
  2262. #  ifdef KIT_PM_WM_CLEAR
  2263.   case WM_CLEAR                         : messageName = "WM_CLEAR";             break; //0x0303
  2264. #  endif
  2265.  
  2266. #  ifdef KIT_PM_WM_UNDO
  2267.   case WM_UNDO                          : messageName = "WM_UNDO";              break; //0x0304
  2268. #  endif
  2269.  
  2270. #  ifdef KIT_PM_WM_RENDERFORMAT
  2271.   case WM_RENDERFORMAT                  : messageName = "WM_RENDERFORMAT";      break; //0x0305
  2272. #  endif
  2273.  
  2274. #  ifdef KIT_PM_WM_RENDERALLFORMATS
  2275.   case WM_RENDERALLFORMATS              : messageName = "WM_RENDERALLFORMATS";  break; //0x0306
  2276. #  endif
  2277.  
  2278. #  ifdef KIT_PM_WM_DESTROYCLIPBOARD
  2279.   case WM_DESTROYCLIPBOARD              : messageName = "WM_DESTROYCLIPBOARD";  break; //0x0307
  2280. #  endif
  2281.  
  2282. #  ifdef KIT_PM_WM_DRAWCLIPBOARD
  2283.   case WM_DRAWCLIPBOARD                 : messageName = "WM_DRAWCLIPBOARD";     break; //0x0308
  2284. #  endif
  2285.  
  2286. #  ifdef KIT_PM_WM_PAINTCLIPBOARD
  2287.   case WM_PAINTCLIPBOARD                : messageName = "WM_PAINTCLIPBOARD";    break; //0x0309
  2288. #  endif
  2289.  
  2290. #  ifdef KIT_PM_WM_VSCROLLCLIPBOARD
  2291.   case WM_VSCROLLCLIPBOARD              : messageName = "WM_VSCROLLCLIPBOARD";  break; //0x030A
  2292. #  endif
  2293.  
  2294. #  ifdef KIT_PM_WM_SIZECLIPBOARD
  2295.   case WM_SIZECLIPBOARD                 : messageName = "WM_SIZECLIPBOARD";     break; //0x030B
  2296. #  endif
  2297.  
  2298. #  ifdef KIT_PM_WM_ASKCBFORMATNAME
  2299.   case WM_ASKCBFORMATNAME               : messageName = "WM_ASKCBFORMATNAME";   break; //0x030C
  2300. #  endif
  2301.  
  2302. #  ifdef KIT_PM_WM_CHANGECBCHAIN
  2303.   case WM_CHANGECBCHAIN                 : messageName = "WM_CHANGECBCHAIN";     break; //0x030D
  2304. #  endif
  2305.  
  2306. #  ifdef KIT_PM_WM_HSCROLLCLIPBOARD
  2307.   case WM_HSCROLLCLIPBOARD              : messageName = "WM_HSCROLLCLIPBOARD";  break; //0x030E
  2308. #  endif
  2309.  
  2310. #  ifdef KIT_PM_WM_QUERYNEWPALETTE
  2311.   case WM_QUERYNEWPALETTE               : messageName = "WM_QUERYNEWPALETTE";   break; //0x030F
  2312. #  endif
  2313.  
  2314. #  ifdef KIT_PM_WM_PALETTEISCHANGING
  2315.   case WM_PALETTEISCHANGING             : messageName = "WM_PALETTEISCHANGING"; break; //0x0310
  2316. #  endif
  2317.  
  2318. #  ifdef KIT_PM_WM_PALETTECHANGED
  2319.   case WM_PALETTECHANGED                : messageName = "WM_PALETTECHANGED";    break; //0x0311
  2320. #  endif
  2321.  
  2322. #  ifdef KIT_PM_WM_HOTKEY
  2323.   case WM_HOTKEY                        : messageName = "WM_HOTKEY";            break; //0x0312
  2324. #  endif
  2325.  
  2326.  
  2327. #if(WINVER >= 0x0400)
  2328. #  ifdef KIT_PM_WM_PRINT
  2329.   case WM_PRINT                         : messageName = "WM_PRINT";       break; //0x0317
  2330. #  endif
  2331.  
  2332. #  ifdef KIT_PM_WM_PRINTCLIENT
  2333.   case WM_PRINTCLIENT                   : messageName = "WM_PRINTCLIENT"; break; //0x0318
  2334. #  endif
  2335. #endif /* WINVER >= 0x0400 */
  2336.  
  2337.  
  2338. #if(_WIN32_WINNT >= 0x0500)
  2339. #  ifdef KIT_PM_WM_APPCOMMAND
  2340.   case WM_APPCOMMAND                    : messageName = "WM_APPCOMMAND"; break; //0x0319
  2341. #  endif
  2342. #endif /* _WIN32_WINNT >= 0x0500 */
  2343.  
  2344.  
  2345. #if(_WIN32_WINNT >= 0x0501)
  2346. #  ifdef KIT_PM_WM_THEMECHANGED
  2347.   case WM_THEMECHANGED                  : messageName = "WM_THEMECHANGED"; break; //0x031A
  2348. #  endif
  2349. #endif /* _WIN32_WINNT >= 0x0501 */
  2350.  
  2351.  
  2352. #if(_WIN32_WINNT >= 0x0501)
  2353. #  ifdef KIT_PM_WM_CLIPBOARDUPDATE
  2354.   case WM_CLIPBOARDUPDATE               : messageName = "WM_CLIPBOARDUPDATE"; break; //0x031D
  2355. #  endif
  2356. #endif /* _WIN32_WINNT >= 0x0501 */
  2357.  
  2358.  
  2359. #if(_WIN32_WINNT >= 0x0600)
  2360. #  ifdef KIT_PM_WM_DWMCOMPOSITIONCHANGED
  2361.   case WM_DWMCOMPOSITIONCHANGED         : messageName = "WM_DWMCOMPOSITIONCHANGED";       break; //0x031E
  2362. #  endif
  2363.  
  2364. #  ifdef KIT_PM_WM_DWMNCRENDERINGCHANGED
  2365.   case WM_DWMNCRENDERINGCHANGED         : messageName = "WM_DWMNCRENDERINGCHANGED";       break; //0x031F
  2366. #  endif
  2367.  
  2368. #  ifdef KIT_PM_WM_DWMCOLORIZATIONCOLORCHANGED
  2369.   case WM_DWMCOLORIZATIONCOLORCHANGED   : messageName = "WM_DWMCOLORIZATIONCOLORCHANGED"; break; //0x0320
  2370. #  endif
  2371.  
  2372. #  ifdef KIT_PM_WM_DWMWINDOWMAXIMIZEDCHANGE
  2373.   case WM_DWMWINDOWMAXIMIZEDCHANGE      : messageName = "WM_DWMWINDOWMAXIMIZEDCHANGE";    break; //0x0321
  2374. #  endif
  2375. #endif /* _WIN32_WINNT >= 0x0600 */
  2376.  
  2377.  
  2378. #if(_WIN32_WINNT >= 0x0601)
  2379. #  ifdef KIT_PM_WM_DWMSENDICONICTHUMBNAIL
  2380.   case WM_DWMSENDICONICTHUMBNAIL        : messageName = "WM_DWMSENDICONICTHUMBNAIL";         break; //0x0323
  2381. #  endif
  2382.  
  2383. #  ifdef KIT_PM_WM_DWMSENDICONICLIVEPREVIEWBITMAP
  2384.   case WM_DWMSENDICONICLIVEPREVIEWBITMAP: messageName = "WM_DWMSENDICONICLIVEPREVIEWBITMAP"; break; //0x0326
  2385. #  endif
  2386. #endif /* _WIN32_WINNT >= 0x0601 */
  2387.  
  2388.  
  2389. #if(WINVER >= 0x0600)
  2390. #  ifdef KIT_PM_WM_GETTITLEBARINFOEX
  2391.   case WM_GETTITLEBARINFOEX             : messageName = "WM_GETTITLEBARINFOEX"; break; //0x033F
  2392. #  endif
  2393. #endif /* WINVER >= 0x0600 */
  2394.  
  2395.  
  2396.   default:;
  2397. #  ifdef KIT_PM_WM_UNKNOWN
  2398.   messageName = "(unknown)";
  2399. #  endif
  2400.   }
  2401.  
  2402.  
  2403.  
  2404.   if(messageName != nullptr){
  2405.     printf("hwnd=%p, wParam=0x%08X, lParam=%p, msg={ 0x%08X \"%s\" }\n",
  2406.            hwnd, (u32)wParam, (void*)lParam, message, messageName);
  2407.   }
  2408. }
  2409. #endif /* _DEBUG */
  2410.  
  2411. /*-src\kit_win32\kit_Window_WindowProc.cpp-*/
  2412.  
  2413.  
  2414. /*+include\kit\_misc_Mutex.hpp+*/
  2415.  
  2416. #ifndef _KIT_INC__MISC_MUTEX_HPP
  2417. #define _KIT_INC__MISC_MUTEX_HPP
  2418.  
  2419. #include "commondef.hpp"
  2420.  
  2421.  
  2422. namespace kit {
  2423.  
  2424.  
  2425.  
  2426.  
  2427. //this mutex is non-blocking within the same thread!
  2428.  //(that means you can lock multiple times in one thread
  2429.  // as long as you unlock it the same number of times)
  2430. class MutexSimple {
  2431.   u32 _type;
  2432.   u32 _spinCount;
  2433.   _GenericOpaquePtr _mutex_ptr = nullptr;
  2434.  
  2435. public:
  2436.   MutexSimple(u32 spinCount = -1);
  2437.   ~MutexSimple();
  2438.  
  2439.   void setSpinCount(u32 spinCount);
  2440.   u32 getSpinCount(){ return _spinCount; }
  2441.  
  2442.   void lock(bool locked = true);
  2443.   void unlock(){ lock(false); }
  2444.   bool tryLock(); //returns true if locked successfully
  2445.  
  2446. };
  2447.  
  2448.  
  2449.  
  2450.  
  2451. };
  2452.  
  2453.  
  2454. #endif /* _KIT_INC__MISC_MUTEX_HPP */
  2455.  
  2456. /*-include\kit\_misc_Mutex.hpp-*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement