Todo-Argentum
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

[ APORTE ] Drag&Drop (Dx7)

Ir abajo

[ APORTE ] Drag&Drop (Dx7) Empty [ APORTE ] Drag&Drop (Dx7)

Mensaje por Shermie80 Sáb Nov 02, 2013 12:10 am

en el codigo del frmmain, debajo del option explicit

ponemos

Código:
Private last_i            As Long
 
Public usando_Drag        As Boolean
Public usaba_Drag          As Boolean
en el Sub Form_MouseMove del frmmain abajo de

Código:
LastPressed.ToggleToNormal
ponemos

Código:
          Call ConvertCPtoTP(X, Y, tX, tY)
     
        If usando_Drag Then
                General_Drop_X_Y tX, tY
                usaba_Drag = False
        End If
al final de todo el codigo ponemos

Código:
Dim i        As Integer
 
                Dim file_path As String
             
                'Inventario.SelectedItem  X, Y
 
              If Inventario.GrhIndex(Inventario.SelectedItem) > 0 Then
 
                      last_i = Inventario.SelectedItem
     
                      If last_i > 0 And last_i <= MAX_INVENTORY_SLOTS Then
 
                              Dim Poss As Integer
 
                              Poss = Search_GhID(Inventario.GrhIndex(Inventario.SelectedItem))
                             
                              If Poss = 0 Then
                             
                                      i = GrhData(Inventario.GrhIndex(Inventario.SelectedItem)).FileNum
 
                                      DoEvents
                                     
                                      i = GrhData(Inventario.GrhIndex(Inventario.SelectedItem)).FileNum
                               
                                      file_path = DirGraficos & CStr(GrhData(Inventario.GrhIndex(Inventario.SelectedItem)).FileNum) & ".bmp"
                         
                                      frmMain.ImageList1.ListImages.Add , CStr("g" & Inventario.GrhIndex(Inventario.SelectedItem)), Picture:=LoadPicture(file_path)
                                      Poss = frmMain.ImageList1.ListImages.Count
                              End If
         
                              usando_Drag = True
         
                              Set picInv.MouseIcon = frmMain.ImageList1.ListImages(Poss).ExtractIcon
                              frmMain.picInv.MousePointer = vbCustom
 
                              Exit Sub
 
                      End If
              End If
      End If
 
End Sub
 
Private Function Search_GhID(Gh As Integer) As Long
 
      ' / Author: Dunkansdk
 
        Dim i As Long
 
        For i = 1 To frmMain.ImageList1.ListImages.Count
 
                If frmMain.ImageList1.ListImages(i).Key = "g" & CStr(Gh) Then
                        Search_GhID = i
 
                        Exit For
 
                End If
 
        Next i
 
End Function
 
Private Sub PicInv_MouseMove(Button As Integer, _
                            Shift As Integer, _
                            X As Single, _
                            Y As Single)
 
        If Not usando_Drag Then
                picInv.MousePointer = vbDefault
        End If
 
End Sub
Buscamos en el modulo de clase clsGrapchicalInventory

pero antes declaramos esto abajo de su option explicit

Código:
Private MouseDownSelectedItem      As Long
Dim TempItem                      As Long
ahora buscamos

Código:
Private Sub InventoryWindow_MouseUp(Button As Integer,
y remplazamos todo el sub por esto

Código:
Private Sub InventoryWindow_MouseDown(Button As Integer, _
                                      Shift As Integer, _
                                      X As Single, _
                                      Y As Single)
 
        Dim TempItem As Long
 
        If Button = 2 Then
                TempItem = ClickItem(X, Y)
             
                If TempItem = 0 Then Exit Sub
           
                If Inventory(TempItem).GrhIndex Then
                        MouseDownSelectedItem = TempItem
 
                        Exit Sub
 
                End If
        End If
 
        'MouseDownSelectedItem = 0
End Sub
 
Private Sub InventoryWindow_MouseUp(Button As Integer, _
                                  Shift As Integer, _
                                  X As Single, _
                                  Y As Single)
      '***************************************************
        'Author: Juan Martín Sotuyo Dodero (Maraxus)
      'Last Modify Date: 27/07/04
        'Implements the mouse up event of the inventory picture box
      'Check outs which item was clicked
        '***************************************************
      'Store previously selected item
 
        Dim prevSelItem As Long
 
        'Exit if it got outside the control's area
 
        If X < 0 Or Y < 0 Or X > InventoryWindow.Width Or Y > InventoryWindow.Height Then
 
                Exit Sub
 
        End If
 
        prevSelItem = InvSelectedItem
 
        'Get the currently clickced item
 
      InvSelectedItem = ClickItem(CInt(X), CInt(Y))
 
      'Update needed inventory slots
 
 
        If prevSelItem <> InvSelectedItem Then
                If prevSelItem <> 0 And prevSelItem <> FLAGORO Then Call DrawInventorySlot(prevSelItem)
                If InvSelectedItem Then Call DrawInventorySlot(InvSelectedItem)
        End If
     
        If frmMain.usando_Drag And TempItem <= 25 And TempItem >= 0 And Not frmMain.usaba_Drag Then
                'If InvSelectedItem <> MouseDownSelectedItem And MouseDownSelectedItem <> 0 And InvSelectedItem <> 0 Then
              Call WriteDragInventory(prevSelItem, TempItem)
              frmMain.usando_Drag = False
              'Else
                'frmMain.usando_Drag = False
              'End If
        Else
                frmMain.usando_Drag = False
        End If
 
End Sub
 
 
Agregamos un nuevo modulo con el siguiente codigo

Codigo:

Buscamos

Código:
StopSharingNpc          '/NOCOMPARTIRNPC
abajo

Código:
DragToPos
    DragInventario
AHORA AL SERVIDOR

nuevo modulo llamado Mod_DragAndDrop

Codigo:

buscan

Código:
Case ClientPacketID.Consultation
            Call HandleConsultation(UserIndex)
abajo

Código:
                Case ClientPacketID.DragInventario          'DINVENT
                      Call Mod_DragAndDrop.HandleDragInventory(UserIndex)
         
              Case ClientPacketID.DragToPos              'DTOPOS
                        Call Mod_DragAndDrop.HandleDragToPos(UserIndex)
buscamos en los paquetes

Código:
StopSharingNpc
abajo

Código:
 DragToPos
        DragInventario
remplazar los clsSurfaceManDyn y clsSurfaceManStatic

por estos

clsSurfaceManStatic:

clsSurfaceManDyn:

Fuente:
Shermie80
Shermie80

[ APORTE ] Drag&Drop (Dx7) ZdImiA6

CoverAOStaff
Aportes : 55
Mensajes : 139
Puntos : 822
Edad : 27

https://todo-argentum.foroargentina.net

Volver arriba Ir abajo

Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.