From: Reini U. <ru...@x-...> - 2006-03-09 13:23:27
|
oops, forgot to attach the patch... 2006/3/9, Reini Urban <ru...@x-...>: > I simplified and fixed some code in the XS part of DragDrop. > The second argument to the DropFiles event is now a proper > Win32::GUI::DragDrop object with the HDROP handle as -handle. > > Unicode filenames not yet supported. > > And I wonder if we should not support a higher level interface, by fillin= g > the needed properties of this object on creation, with the files > and the mousepoint automatically. > Then none of the 4 DragDrop functions would be needed and the > event would be much simplier to use. > > Now: > sub Main_DropFiles { > my $win =3D shift; # dropped on which window > my @files; > if (ref $_[0] eq 'Win32::GUI::DragDrop') { # GUI 1.04 > #my $pos =3D $_[0]->DragQueryPoint(); > #my $l =3D $_[0]->DragQueryFile(0xFFFFFFFF); > #my $f0 =3D $_[0]->DragQueryFile(0); > @files =3D $_[0]->DragQueryFiles(); > # and from here on the HDROP ressource behind the $_[0] object is des= troyed. > } else { > @files =3D Win32::GUI::DragDrop::GetDroppedFiles(shift); # Loft > } > return 0 unless @files; > .. do something with the files > } > > Then: > sub Main_DropFiles { > my $win =3D shift; # dropped on which window > my @files; > if (ref $_[0] eq 'Win32::GUI::DragDrop') { # GUI 1.04 > @files =3D $_[0]->DragFiles; > $pos =3D $_[0]->DragPos; # pos stored in the perl object > } else { > @files =3D Win32::GUI::DragDrop::GetDroppedFiles(shift); # Loft > } > return 0 unless @files; > .. do something with the files > } > > Now I will finish all the needed support functions for CustomDraw and > make a simplier example without Win32::API. > > 2006/3/8, Reini Urban <ru...@x-...>: > > Hi > > I just finished adding DragDrop to Win32::GUI. > > > > I didn't like the Loft methods and it's Win32::API dependency, > > so it's a good GUI.xs and Window.xs integration with the "DropFiles" > > NEM and OEM events supported. > > Attached is the generated pod and patch. > > > > A Window can use the -dropfiles =3D> 0|1 option to accept dropping file= s, > > or the DragAcceptFiles() method. > > The event can be registered via <name>_DropFiles or via -onDropFiles. > > Sample: > > sub Main_DropFiles { > > # check if called as method or function > > if ($_[0] =3D~ /Win32::GUI::(Window|DialogBox)/) { > > shift; > > } > > # now the DragDrop handle should be on the stack. (not an object yet = though) > > my $files =3D Win32::GUI::DragDrop::DragQueryFiles(shift); > > return 0 unless @$files; > > ... > > } > > > > Some notes: > > The DragDrop handle passed to the event is no object yet. > > So only the function call is supported yet, not as method. > > > > sub win_DropFiles { $files =3D $_[0]->DragQueryFiles(); } # invalid! > > I didn't care to stash the handle in XS yet. It's just a long. > -- > Reini Urban > http://phpwiki.org/ > http://spacemovie.mur.at/ http://helsinki.at/ > -- Reini Urban http://phpwiki.org/ http://spacemovie.mur.at/ http://helsinki.at/ |