Hi,
From what I understand of dragging (which isn't a lot!) most of the
functionality that you would need for this explorer example is present
within Win32::GUI at the moment.
Basically, dragging is a very manual process - you have to do most of the
work - and I think most of the methods to do this work is part of the
imagelist control (BeginDrag, DragEnter,DragMove and EndDrag). You have to
work out when the user starts the drag, when they finish, so on and so on.
I've knocked up a really, really bad example (based upon Chris's code),
which is full of bugs but should be enough for anyone wanting to have a
play. For some reason the drag image is black now and again, and sometimes
the mouseup event doesn't fire and the coordinates are off:) Just like my
normal code then...:)
# ============================
# Listview Large Icon example
# ============================
use Win32::GUI;
use Win32::GUI::BitmapInline ();
$bmpComputer = new Win32::GUI::BitmapInline( q(
Qk02DAAAAAAAADYAAAAoAAAAIAAAACAAAAABABgAAAAAAAAMAAATCwAAEwsAAAAAAAAAAAAA////
/////////////////////////////////v7++fn65eTkyMDBsqKiqJKSo4uNoYmLnYODnYmKqJyc
vLi61NPU7Ozt/Pz8/v7+////////////////////////////////////////////////////////
////+/v72dLTrpeXqYWFuJyeyLW2z7y90bu80Li5zrS0yqytvJaYqH5/lnFwloeIvLq76Onq/f39
////////////////////////////////////////////////////9PPzuJ6fuZ6g1cvM3tvb3NjZ
3NXV2tHR2MzM18jI1cLCwZ6fwZma0rGz0qytv5KSmnFxl4qM1dXW/Pz8////////////////////
////////////////////////+ff3u52e0sfI4+fn4ePk4OHh3t7f29rZ2tTU2dHR18vMu5SWtpaY
noKCnHBys4aIzqam0KOkq3p6lISF4ODh/v7+////////////////////////////////////////
3czNz8HB5+zt5ubn6ejo6enp5ebm4OHh29ra3NjX0L6/wpqb2NLTnZGSnouLmXd3rH+A1auqzJyc
o3V2v7u8+/v7////////////////////////////////////////0Li44N7d6+zt7u7u8fHw8PDw
7Ozs5ubn39/g3dzcy7W1y6enzru7oH9/poaGpoOCso2N0Kio0KOjtYODu7Gy+vv7////////////
////////////////////////////2cLD4d3d7/Hy9vb0/P37+vr58fDw6Ojp4eLi3Nzcxqam0K+w
xaWmqHt5rn5+rXl4uoiI0Kqq0aKjtoSEzsfH/f7+////////////////////////////////////
////8efn18bG8fX1+Pj3/fr7/f//9fn56eno4ePj2dbXw5ia07GxvIiJs3V1tXd2s3JyvoaH0a2t
ypubu5qa8/Pz/v7+/////////////////////////////////////////v7+6dra4dbW7+zt0qms
0q2w4dHS6ezr5Ovr1srJxZaX06qqtnR0tG9xs25wsmtrwIiKzaSkwpub7+zs/v7+////////////
/////////////////////////////////////v7+9Ozs1ri5u31+wIOEwYiPv46Uy7O1yaamy5ub
w4qLsGlqr2hpr2dorWRjtHx80by8+Pf3////////////////////////////////////////////
////////////////////6dnavIGC0Zpw4rmU1KWcxI6VuXqCtXJ1rWJhrGJfrGNgrGFfqFxbrpGS
9fX1/////////////////////////////////////////////////////////////////v7+3sfJ
wYaAy41D1Jg32qRU3q5y27CUzJuYuHh+rGNopldUpFJPnExJsZ2d+Pn5////////////////////
/////////////////////////////////////////////f390K+zxYx605lG2KBF2Z9C2aA+3KVG
4K5f37OC0aGPv4aKrWRqm0tLmoeI0dPT8vPz/f39/v7+////////////////////////////////
////////////////////9/T0xJykyJBy3KRD3adI36hK36pK36tK4KpI4atH47BU4bFn2qyDyZKH
sHN2mW91opKTw8HC6uvs/f39////////////////////////////////////////////////7+jo
wpacy5Zm4qxF4q1O47BQ5LFR5bNT5LJU5bNV5LJS5LFQ5LFO5LJa361u0Zd5u3p2m2VoqJqa8vLz
////////////////////////////////////////////////4tbXxZud0KBi5rNP5bRX5rZZ6Llb
6bla6Llb6bpc6bpc6blb57dZ5rZW5rVS5rNR5bJYzYlipoGB7e/v////////////////////////
/////////////////////fz807/DxZyX2Kle6rlX6rpd671f7b9i7MBi7MBi7cBi7cFj7cBi7L5h
67xf6bpd6Lda67tUzY5Wq4qL8vPz////////////////////////////////////////////+vj5
ya+1wp2S4bRb7sFf7sJk78Rn8MZq8MZr8cds8sds8cds8cdr8MVo78Nm7cFk671g78JbxoVdsZaZ
9vf3////////////////////////////////////////////8e7uxquxxaCI6b5h8cZn8Mdr8spu
9Mty9M1z9M5z9c909c509M1z8stw8slt8cdr78Rn8cVhvn5gtqOm+fr6////////////////////
////////////////////////4trbyK60x6R+7sZo88tv9M109tB49tN899N+99R/99V/99R/99R+
9tF69tB29M1z9Mxu78NpuHpkvrK1+/z8/////////////////////////////////////////v7+
2c7QybO3z6x29s1v9tB299J899WC+NaH+NeL+NeN+NeM+NeN+NiL99aH+NSA9tN799J27L9vsnVm
yMDC/f39////////////////////////////////////////+/v70sfIwayv17Vz+9R299N/+NaH
+NiO+NmT99qY99ua99ua9tua99uX+NmS+NiN99aG+td+6Lp2rnNs0MzO/v7+////////////////
////////////////////////8/Hxyr3BxLCn4L93+9d/+NaI99mS99qZ9t2f9N2l9N+o9N+o9N+n
9N2i9tye99uW+NmP+9uJ4bN8qHFy2dbY/v7+////////////////////////////////////////
6ObmzsLIwq6c6sl7+deG+NmS9tub9d6j9OCr8uGv8+Kz9OO09OOz8+Kv9N+p9d2i99uZ+92Q3at9
pXh74+Lj/v7+////////////////////////////////////////3NjYzsjPv6uM+dWB+9uN+t6Z
9+Cl9OGs8+O08uW78+fA8+fB8+a+8uS69OOy89+p9d2h+NuW16J9qISH7Ozt/v7+////////////
////////////////////////////ysfIzsjMpZaKxq+K28GQ58yc7den9OO2+u7E9+7L9e7P8+zO
8urL8ujE8+W79OKw9eCn89mbzpZ8rJCT9PT0////////////////////////////////////////
////wsHC4t/go5qbm4+SmoqMn4uKqJOKtJ2Rwqyf08Gx5dnE8evU9O/V9e7O9+zF9ui5+OWu8tef
xYx7sJye9/j4////////////////////////////////////////////xcXH09TV3NnZ087OzMPG
yLu+wrO0s5+hqZGTpIiJo4OCp4aEt5mSyK6h2sSt5Myt79mq79SguX94t6ir+vr6////////////
/////////////////////////////////f397e3t5ePk7+7u4d/f0svMyb6/yr2/z7/A1MTE0r2+
xausuZiZsYuNqX+BrYGAtoqDv5CCrHd2wrm6/Pz8////////////////////////////////////
/////////////////////////////////v7++/r68e/v39jY1MjJ3tLT18fI1sDBzrKzxqSmxqGj
wJWYpXp71dDR/v7+////////////////////////////////////////////////////////////
/////////////////////////////v7++fj48Ovr8u7u7OTk3MvLwp2ex66v+fn5////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
) );
$imlChart = new Win32::GUI::ImageList(32,32,24,2,10);
$imlChart->Add($bmpComputer);
my $drag=0;
my $dragitem;
$winMain = new Win32::GUI::Window(
#====================================
-name => "winMain",
-title => "Listview Control",
-pos => [100,100],
-size => [500,500],
-dialogui => 1,
);
$lvwChart = $winMain->AddListView(
#====================================
-name => "lvwChart",
-text => " ",
-left => 5,
-top => 30,
-width => 480,
-height => 420,
-autovscroll => 1,
-autohscroll => 1,
-hottrack => 1,
-visible => 1,
-nocolumnheader => 1,
-imagelist => $imlChart,
);
$lvwChart->View(0); # Set View to LargeIcon
# View Properties
# 0 - lvwIcon
# 1 - lvwSmallIcon
# 2 - lvwList
# 3 - lvwReport
$lvwChart->InsertItem(
#========= ITEM 1 =================
-image => 0,
-text => [ "Computer 1" ]
);
$lvwChart->ItemPosition(0,80,100);
$lvwChart->InsertItem(
#========= ITEM 2 =================
-image => 0,
-text => [ "Computer 2" ]
);
$lvwChart->ItemPosition(0,160,200);
$lvwChart->InsertItem(
#========= ITEM 3 =================
-image => 0,
-text => [ "Computer 3" ]
);
$lvwChart->ItemPosition(0,240,300);
$winMain->Show();
$winMain->Enable();
Win32::GUI::Dialog();
sub winMain_Terminate {
return -1;
}
#====================================
# EVENTS
#====================================
sub lvwChart_ItemClick {
#====================================
my($index) = @_; # ItemClicked
my %item = ();
my $itemtext = "";
my $x = "";
my $y = "";
%item = $lvwChart->ItemInfo($index);
$itemtext = $item{-text};
print "Clicked Item $index: $itemtext\n";
($x,$y) = $lvwChart->ItemPosition($index);
print "Position X-$x Y-$y\n";
$dragitem=$index;
#$lvwChart->MoveItem($index,$mouseX,$mouseY);
$imlChart->BeginDrag(0,0,0);
Win32::GUI::ImageList::DragEnter($winMain,$x, $y);
$drag=1;
return 1;
}
sub lvwChart_MouseMove {
my ($x,$y)[EMAIL PROTECTED];
if ($drag) {
Win32::GUI::ImageList::DragMove($x, $y);
}
return 1;
}
sub lvwChart_MouseUp {
if ($drag) {
Win32::GUI::ImageList::EndDrag();
my ($x, $y) = $winMain->ScreenToClient(Win32::GUI::GetCursorPos());
$lvwChart->ItemPosition($dragitem,$x,$y);
$drag=0;
}
return 1;
}
----- Original Message -----
From: "Frazier, Joe Jr" <[EMAIL PROTECTED]>
To: "Jez White" <[EMAIL PROTECTED]>; "Lloyd, Steve"
<[EMAIL PROTECTED]>; "Chris Wearn" <[EMAIL PROTECTED]>;
"perl-win32-gui-users" <perl-win32-gui-users@lists.sourceforge.net>
Sent: Monday, January 10, 2005 4:35 PM
Subject: RE: [perl-win32-gui-users] Listview Control functionality - Drag n
Drop - Email found in subject
Jez, one thing you may want to think about is if there is a way to
implement the semantics in a way simular to how Windows Explorer
currently handles drag and drop for files in the Listview:
Right Click + drag = Drop shows context menu with options: Copy Here,
Move Here, Create ShortCut Here, SEPARATOR, Cancel
Left Click + Drag = two options, depending on where the target is
dropped: If dropped somewhere on the same drive, then it is a move. If
dropped onto a different drive (or machine), then it is a copy.
"Perhaps" there should be a flag in the constructor to turn this
behaviour on an off. Basically, if Win32::GUI can DWIM if the flag is
on, and let the user handle it via event handlers if it is off (default
to on?)
Anyway, just an idea....
Joe Frazier, Jr.
Senior Support Engineer
Peopleclick Service Support
Tel: +1-800-841-2365
E-Mail: [EMAIL PROTECTED]