From: <Fo...@ao...> - 2001-05-04 19:11:14
|
This is the 128 message: #define WS_EX_TOOLWINDOW 0x00000080L (This is documented in the Win32 Programmer's Reference help file and in the winuser.h file from Visual C++) Yup. Didn't have my VC++ install at work, though... > > > And this would be _so_ neat to use: > > WS_EX_ACCEPTFILES -- Specifies that a window created with this style > accepts drag-drop files. > > Anyone have any idea of things I have to think about if I want to try to > implement a drag-n-drop feature? I have already found the correct set of > functions and messages in the Win32 Reference. > Eh, I forget exactly how it works, but in VB you had to subclass some message or another... wasn't too bad. If you have the exact procedure down, it's pretty simple. Dave |
From: <Fo...@ao...> - 2001-05-07 14:28:40
|
In all likelihood, your best bet is to subclass the window you want it to ac= cept the files, then filter for the appropriate message. I can dig up some M= SKB articles on it if you'd like. Dave In a message dated Sun, 6 May 2001 11:47:29 PM Eastern Daylight Time, Johan=20= Lindstrom <jp...@bo...> writes: << I wrote: >Anyone have any idea of things I have to think about if I want to try to=20 >implement a drag-n-drop feature? I have already found the correct set of=20 >functions and messages in the Win32 Reference. Ok, so I managed to tell a window to accept files dragged from the Explorer=20 with the DragAcceptFiles() function (from the shell32.dll). When I drag the mouse over the window, the mouse pointer changes. When I=20 drop, the window is sent a WM_DROPFILES event. My problem now is how I should capture this event. Naive first try: timer which triggers really often. In the event handler I=20 call $myWindow->PeekMessage(WM_DROPFILES, WM_DROPFILES) and if it returns true, I call $myWindow->GetMessage(WM_DROPFILES, WM_DROPFILES) That works like one in ten times or something. Clearly not the way to go. So, any better way of detecting the WM_DROPFILES event? /J -- Johan Lindstr=F6m, Sourcerer, Boss Casinos Ltd, Antigua jp...@bo... _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >> |
From: Johan L. <jp...@bo...> - 2001-05-09 04:29:37
|
Dave wrote: >In all likelihood, your best bet is to subclass the window you want it to >accept the files, then filter for the appropriate message. I can dig up >some MSKB articles on it if you'd like. Um... are we talking subclassing using the Win32::GUI::Class here? After having looked through the XS code, I haven't found any way to change which messages are handled, except for the "predefined" classes with their own MsgLoops. Well... there is this %Win32::GUI::callbacks hash, but I still haven't figured out if I can get it to work with the WM_DROPFILES event. /J -- Johan Lindström, Sourcerer, Boss Casinos Ltd, Antigua jp...@bo... |
From: Johan L. <jp...@bo...> - 2001-05-10 16:57:36
|
Wohoo! I got it to work! :) It took some XS hacking though. Nothing fancy, mostly copy-paste and common sense. I added the WM_DROPFILES message to the WindowMsgLoop so that it throws an event DropFiles() with the drop handle in question. And once in Perl it was piece a cake to call the shell32.dll functions DragQueryFile and DragFinish to actually get the files. Cool. This is fun! Some code: GUI.xs, line 1839: ---------- case WM_DROPFILES: if(GetObjectName(NOTXSCALL hwnd, Name)) { /* * (@)EVENT:DropFiles(DROP_HANDLE) * Sent when the window receives dropped files. * (@)APPLIES_TO:Window, DialogBox */ strcat(Name, "_DropFiles"); PerlResult = DoEvent_Long(NOTXSCALL Name, UINT(wParam)); } break; ---------- http://www.bahnhof.se/~johanl/perl/Win32GUI/ - AdHoc.pm Perl subs for dealing with the shell32.dll calls handling the drop operation (among other things). - dragdrop.pl Working demo program (if you rebuild the XS code). The actual drag-drop code is this simple in a Perl application: ---------- Win32::GUI::AdHoc::windowDragAcceptFiles($winMain, 1); sub winMain_DropFiles { my ($handleDrop) = @_; print join("\n", Win32::GUI::AdHoc::windowGetDroppedFiles($handleDrop)) . "\n\n"; return(1); } ---------- I guess a more complete solution would include drag-drop to e.g. a RichEdit or Textfield control etc. but I'm not sure what the implications are. I'm not sure how to continue with this. For my personal use, I'm probably gonna create a Win32::GUI::DragDrop module or something (using my XS mod), but maybe this belongs in the next release of Win32::GUI after a code review (after all, I relly don't _know_ these things). Aldo? /J -- Johan Lindström, Sourcerer, Boss Casinos Ltd, Antigua jp...@bo... |
From: <Fo...@ao...> - 2001-05-09 17:14:33
|
Eh, no... I was actually thinking pure SetWindowCapture stuff. Haven't done=20= it in the while, but that's how we used to do it in VB. Dave In a message dated Wed, 9 May 2001 12:43:06 AM Eastern Daylight Time, Johan=20= Lindstrom <jp...@bo...> writes: << Dave wrote: >In all likelihood, your best bet is to subclass the window you want it to=20 >accept the files, then filter for the appropriate message. I can dig up=20 >some MSKB articles on it if you'd like. Um... are we talking subclassing using the Win32::GUI::Class here? After having looked through the XS code, I haven't found any way to change=20 which messages are handled, except for the "predefined" classes with their=20 own MsgLoops. Well... there is this %Win32::GUI::callbacks hash, but I still haven't=20 figured out if I can get it to work with the WM_DROPFILES event. /J -- Johan Lindstr=F6m, Sourcerer, Boss Casinos Ltd, Antigua jp...@bo... _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >> |