From: Jeremy W. <jez...@ho...> - 2003-11-17 19:32:57
|
All, Below is code from Trevor Garside (reproduced with permission) - it adds a new event _Drag for the splitter control. The downside is that it disables the _Release event. I've tested it and it works (558). If this is included in any new build, the _Release event should be enabled. Cheers, jez. --- /* ########################################################################### # (@)INTERNAL:SplitterMsgLoop(hwnd, uMsg, wParam, lParam) # message loop for Win32::GUI::Splitter objects */ LRESULT CALLBACK SplitterMsgLoop(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int PerlResult; char Name[MAX_EVENT_NAME]; HV* self; SV** fetching; SV* storing; long tracking, horizontal, trackpos; int min; int max; POINT pt; HWND phwnd; HDC hdc; RECT rc; LPPERLWIN32GUI_USERDATA perlud; #ifdef PERLWIN32GUI_STRONGDEBUG printf("!XS(SplitterMsgLoop) got (%ld, 0x%x, %ld, %ld)\n", hwnd, uMsg, wParam, lParam); #endif if(uMsg == WM_DESTROY) { safefree( (LPPERLWIN32GUI_USERDATA) GetWindowLong(hwnd, GWL_USERDATA)); return DefWindowProc(hwnd, uMsg, wParam, lParam); } #ifdef PERL_OBJECT pPerl = ((LPPERLWIN32GUI_USERDATA) GetWindowLong(hwnd, GWL_USERDATA))->pPerl; #endif PerlResult = 1; strcpy(Name, "main::"); if(GetObjectName(NOTXSCALL hwnd, Name)) { switch(uMsg) { case WM_MOUSEMOVE: self = HV_SELF_FROM_WINDOW(hwnd); fetching = hv_fetch(self, "-tracking", 9, FALSE); if(SvMAGICAL(self)) mg_get(*fetching); if(fetching != NULL) { tracking = SvIV(*fetching); if(tracking) { fetching = hv_fetch(self, "-horizontal", 11, FALSE); if(SvMAGICAL(self)) mg_get(*fetching); if(fetching != NULL && SvOK(*fetching)) { horizontal = SvIV(*fetching); } fetching = hv_fetch(self, "-trackpos", 9, FALSE); if(SvMAGICAL(self)) mg_get(*fetching); if(fetching != NULL && SvOK(*fetching)) { trackpos = SvIV(*fetching); } /* * (@)EVENT:Drag(COORD) * Sent when the Splitter is dragged to a new coordinate * (@)APPLIES_TO:Splitter */ if(horizontal > 0) { phwnd = GetParent(hwnd); GetCursorPos(&pt); ScreenToClient(phwnd, &pt); if(trackpos != pt.y) { pt.y = AdjustSplitterCoord(NOTXSCALL self, pt.y, phwnd); //DrawSplitter(NOTXSCALL hwnd); GetClientRect(hwnd, &rc); SetWindowPos(hwnd, NULL, rc.left, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //DrawSplitter(NOTXSCALL hwnd); if(trackpos != pt.y) { storing = newSViv((long) pt.y); hv_store(self, "-trackpos", 9, storing, 0); if(SvMAGICAL(self)) mg_set(storing); strcat(Name, "_Drag"); PerlResult = DoEvent_Long(NOTXSCALL Name, (long) pt.y); } } } else { phwnd = GetParent(hwnd); GetCursorPos(&pt); ScreenToClient(phwnd, &pt); if(trackpos != pt.x) { pt.x = AdjustSplitterCoord(NOTXSCALL self, pt.x, phwnd); //DrawSplitter(NOTXSCALL hwnd); GetClientRect(hwnd, &rc); SetWindowPos(hwnd, NULL, pt.x, rc.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //DrawSplitter(NOTXSCALL hwnd); if(trackpos != pt.y) { storing = newSViv((long) pt.x); hv_store(self, "-trackpos", 9, storing, 0); if(SvMAGICAL(self)) mg_set(storing); strcat(Name, "_Drag"); PerlResult = DoEvent_Long(NOTXSCALL Name, (long) pt.x); } } } } } break; case WM_LBUTTONDOWN: self = HV_SELF_FROM_WINDOW(hwnd); storing = newSViv((long) 1); hv_store(self, "-tracking", 9, storing, 0); if(SvMAGICAL(self)) mg_set(storing); fetching = hv_fetch(self, "-horizontal", 11, FALSE); if(SvMAGICAL(self)) mg_get(*fetching); if(fetching != NULL && SvOK(*fetching)) { horizontal = SvIV(*fetching); } if(horizontal > 0) { phwnd = GetParent(hwnd); GetCursorPos(&pt); ScreenToClient(phwnd, &pt); pt.y = AdjustSplitterCoord(NOTXSCALL self, pt.y, phwnd); //DrawSplitter(NOTXSCALL hwnd); SetCapture(hwnd); } else { phwnd = GetParent(hwnd); GetCursorPos(&pt); ScreenToClient(phwnd, &pt); pt.x = AdjustSplitterCoord(NOTXSCALL self, pt.x, phwnd); //DrawSplitter(NOTXSCALL hwnd); SetCapture(hwnd); } if(horizontal > 0) { phwnd = GetParent(hwnd); GetCursorPos(&pt); ScreenToClient(phwnd, &pt); pt.y = AdjustSplitterCoord(NOTXSCALL self, pt.y, phwnd); //DrawSplitter(NOTXSCALL hwnd); } else { phwnd = GetParent(hwnd); GetCursorPos(&pt); ScreenToClient(phwnd, &pt); pt.x = AdjustSplitterCoord(NOTXSCALL self, pt.x, phwnd); //DrawSplitter(NOTXSCALL hwnd); } break; case WM_LBUTTONUP: self = HV_SELF_FROM_WINDOW(hwnd); fetching = hv_fetch(self, "-tracking", 9, FALSE); if(SvMAGICAL(self)) mg_get(*fetching); // if(fetching != NULL) { // tracking = SvIV(*fetching); // if(tracking) { // fetching = hv_fetch(self, "-horizontal", 11, FALSE); // if(SvMAGICAL(self)) mg_get(*fetching); // if(fetching != NULL && SvOK(*fetching)) { // horizontal = SvIV(*fetching); // } // if(horizontal > 0) { // phwnd = GetParent(hwnd); // GetCursorPos(&pt); // ScreenToClient(phwnd, &pt); // pt.y = AdjustSplitterCoord(NOTXSCALL self, pt.y, phwnd); // //DrawSplitter(NOTXSCALL hwnd); // strcat(Name, "_Release"); // PerlResult = DoEvent_Long(NOTXSCALL Name, (long) pt.y); // } else { // phwnd = GetParent(hwnd); // GetCursorPos(&pt); // ScreenToClient(phwnd, &pt); // pt.x = AdjustSplitterCoord(NOTXSCALL self, pt.x, phwnd); // //DrawSplitter(NOTXSCALL hwnd); // strcat(Name, "_Release"); // PerlResult = DoEvent_Long(NOTXSCALL Name, (long) pt.x); // } // } // } ReleaseCapture(); if(fetching != NULL) tracking = SvIV(*fetching); else tracking = 0; if(tracking) { storing = newSViv((long) 0); hv_store(self, "-tracking", 9, storing, 0); if(SvMAGICAL(self)) mg_set(storing); } else { /* * (@)EVENT:Click() * Sent when the Splitter is clicked * (@)APPLIES_TO:Splitter */ strcat(Name, "_Click"); PerlResult = DoEvent_Generic(NOTXSCALL Name); } break; // default: // strcat(Name, "_Default"); // PerlResult = DoEvent_Long(NOTXSCALL Name, (long) uMsg); // break; } } if(PerlResult == 0) { return 0; } else { return DefWindowProc(hwnd, uMsg, wParam, lParam); } } _________________________________________________________________ Express yourself with cool emoticons - download MSN Messenger today! http://www.msn.co.uk/messenger |