| Autor | Správa |
B.A.X.O
 Užívateľ
 Založený: 22.01.2008 Príspevky: 426 Bydlisko: Bratislava - Petržalka
 | Zaslal: So 01.11.08 16:44 |   |
potrebujem fciu čo ked pretiahnem Picture1 na Picture2 tak sa niečo stane. Ak sa pretiahne inam, tak sa vráti na povodne miesto odkial ju dotycny zobral. A dalsia vec nemusi to presne doliehat na milimetre, teda tak že stači ak sa Picture1 dotkne Picture2 aspoň častou a to už sa uzná.
Ale nejak ma nenapadá jak na to, prosím poradíte? je to docela surne ale |
| |
    |
 |
Patkoo
 Užívateľ
 Založený: 02.11.2008 Príspevky: 85
 | Zaslal: Ne 02.11.08 14:08 |   |
V tomto pripade by som sa pohral so suradnicami X,Y. To znamena, zistit X,Y pre Picture2, do ktoreho budeme premiestnovat Picture1. Potom by som iba porovnaval X,Y suradnice a ak by sa nejaka z nich zhodovala tak by som nastavil Picture1 top a left taky isty, aky ma picture2 => obrazky "sadnu na seba".
Nemam momentalne VB6 u seba kedze sa teraz viac venujem .NETu, ale ak by si potreboval nejaky konkretny priklad mozem sa ti nato pozret.
P.S: Doporucujem http://www.vb6.us/tutorials/drag-and-drop-apps-vb6
Vela stastia ...
S pozdravom, Pato. |
| |
  |
 |
B.A.X.O
 Užívateľ
 Založený: 22.01.2008 Príspevky: 426 Bydlisko: Bratislava - Petržalka
 | Zaslal: Ne 02.11.08 17:41 |   |
no takže kod som si už napísal. ale neviem ako na to s tým že ak sa nepretiahol na Picture1 tak sa vráti na miesto odkial som ho presuval.
kod tu?
| kód: | Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Drag vbBeginDrag
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Drag vbEndDrag
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move X, Y
Command1.Move X - Command1.Width / 2, _
Y - Command1.Height / 2
End Sub
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Command1.Visible = False
End Sub |
|
| |
    |
 |
neutronmind
 Užívateľ
 Založený: 30.04.2008 Príspevky: 885
 | Zaslal: Ne 02.11.08 17:45 |   |
No tak si tie povodne suradnice daj do nejakych docasnych premennych napr. A, B, a ked sa to nepretiahne na Picture1, tak nastav jeho suradnice naspat na A, B.  |
_________________ Empty your memory, with a free()… like a pointer!
If you cast a pointer to an integer,
it becomes the integer, if you cast a pointer to a struct, it becomes the struct…
The pointer can crash…, and can overflow…
Be a pointer my friend… | |
   |
 |
B.A.X.O
 Užívateľ
 Založený: 22.01.2008 Príspevky: 426 Bydlisko: Bratislava - Petržalka
 | Zaslal: Ne 02.11.08 18:15 |   |
Ale ja ich nemám ako zistiť ani |
| |
    |
 |
Patkoo
 Užívateľ
 Založený: 02.11.2008 Príspevky: 85
 | Zaslal: Ne 02.11.08 19:06 |   |
| kód: | Dim top_sur, left_sur As Integer
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Drag vbBeginDrag
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Drag vbEndDrag
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move X, Y
Command1.Move X - Command1.Width / 2, _
Y - Command1.Height / 2
Command1.left = left_sur
Command1.top = top_sur
End Sub
Private Sub Form_Load()
top_sur = Command1.top
left_sur = Command1.left
End Sub
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Command1.Visible = False
End Sub
|
|
| |
  |
 |
B.A.X.O
 Užívateľ
 Založený: 22.01.2008 Príspevky: 426 Bydlisko: Bratislava - Petržalka
 | Zaslal: Po 03.11.08 10:07 |   |
fakt diky moc presne toto som potreboval |
| |
    |
 |
|