Results 1 to 9 of 9

Thread: [RESOLVED] More Drag & Drop questions

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Resolved [RESOLVED] More Drag & Drop questions

    Hi peeps,

    I have used an example of repeated D&D for this post.. by
    iPrank

    And as he says it does solve the issue asked on that topic.

    I now have the ability (thx iPrank) to place lots of pictureboxes on my form, and I would like to progress to the next stage, which is that the newly placed pictureboxes need to be moved again to particular co-ordinates.

    I am finding it difficult to work out when and what is going on.....I am told it is an array, does that mean the next PictureBox is automatically Index=1 and so on? and how do I get to detect a pictureBox, is it simply a Mouse_Click event? Which means I do a.... On click, get Index number, and if grid new position greater than last move to next grid position. Thats my thinking, am I so far off course?

    Its difficult because these new pictureboxes aren't actually there until runtime, and I actually copy a few.

    Ideally I would like them to snap to a grid, with arrowed buttons (I've already added them) that move them up and down the grid (only vertically) depending on which one is highlighted.

    I hope I haven't babbled too much and that this is comprehensible.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: More Drag & Drop questions

    Mmm... the more I dig into this, the more it looks like API's are the way to go. Would you agree?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: More Drag & Drop questions

    What does this refer to?
    Private Const WM_NCLBUTTONDOWN = &HA1

    Obviously its a constant, but why in that format?

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: More Drag & Drop questions

    what do mean format?

    that constant is the WindowMessage_NonClientLeftBUTTONDOWN - so you're telling the window that the user clicked on the non-client area, then with the HTCAPTION constant as a parameter you're telling it that was clicked on the caption - and hence the appropriate behaviour (dragging) occurs. You're essentially tricking the window.

    the value &HA1 is Hex, cos it's neater than writing 161

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: More Drag & Drop questions

    Ah, thank you, so which, or how is an area designated the 'NonClientArea' or is just the active form?
    and why 161, is there some sort of list?

    Appreciate your help.

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: More Drag & Drop questions

    if you compare a borderless vb form to a normal vb form then everything that's missing is part of the non-client area. You're basically telling windows that the user clicked on something that they didn't actually click on - and then allowing windows to handle all the moving / redrawing for you.

    and the value is 161 cos it was given a value right after whatever was given the value 160 - the value is irrelevant - what windows associates with this message is the important part. In some cases the value is important as it can signify if a particular bit is on or off - but not in this case.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: More Drag & Drop questions

    Wow that seems strange, why couldn't we just tell windows that we clicked on the PictureBox? and still allow windows to handle all the moving etc.

    These new pictureboxes that I'm producing, can I get them to move again?

    VB Code:
    1. Private Sub srm00_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     If Button = vbLeftButton Then
    3.         If Index = 0 Then
    4.             Load srm00(srm00.UBound + 1)                          'inc index by one ?
    5.             srm00(srm00.UBound).Visible = True                    ' make it visible
    6.             srm00(srm00.UBound).ZOrder 0                          ' make it top layer
    7.             '
    8.             ReleaseCapture
    9.             SendMessageLong srm00(srm00.UBound).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    10.         End If
    11.     End If
    12. End Sub

    Here's the code (from iPranks post) only slightly edited, I'm trying to work out at what point its dropped and haw can I locate its Index. I've a feeling I need its 'hwnd'.

    Perhaps I could click on the PictureBox, and then click on an arrow buttom to move it? Does that sound feasible.

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: More Drag & Drop questions

    try:
    VB Code:
    1. Private Sub srm00_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     If Button = vbLeftButton Then
    3.         If Index = 0 Then
    4.             Load srm00(srm00.UBound + 1)                          'inc index by one ?
    5.             srm00(srm00.UBound).Visible = True                    ' make it visible
    6.             srm00(srm00.UBound).ZOrder 0                          ' make it top layer
    7.             '
    8.             ReleaseCapture
    9.             SendMessageLong srm00(srm00.UBound).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    10.         Else
    11.             ReleaseCapture
    12.             SendMessageLong srm00(Index).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    13.         End If        
    14.     End If
    15. End Sub

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: More Drag & Drop questions

    Brilliant!! I can hardly contain my excitment. Whoo hoo
    I'm going to attempt to get them to snap to a position now.

    I'll have a go on my own first....can't thank you enough.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width