Positioning Controls Using Snap Lines at RunTime-VBForums
Results 1 to 6 of 6

Thread: Positioning Controls Using Snap Lines at RunTime

  1. #1

    Thread Starter
    Addicted Member Davor Geci's Avatar
    Join Date
    Sep 2009
    Posts
    132

    Positioning Controls Using Snap Lines at RunTime

    Hello guys,

    In my project Virtual Forms I'm enabling the user to reposition and resize the controls at RunTime.

    You can read more about the project in this post:
    http://www.vbforums.com/showthread.p...nd-error-free)

    I would like to make it a little bit easier and enable (what we have in newer VS) Snap Lines. (http://www.techotopia.com/index.php/...ing_Snap_Lines)

    Did you guys maybe done something like this in vb6?

    This is the code that I'm using now for resizing and repositioning of the controls in runtime:

    Resizer code example.zip
    Davor Geci
    CEO @ WinPIS
    Take a look at my Virtual Forms project (create database apps in minutes with vb6)

  2. #2

    Thread Starter
    Addicted Member Davor Geci's Avatar
    Join Date
    Sep 2009
    Posts
    132

    Re: Positioning Controls Using Snap Lines at RunTime

    Still trying to find if someone is having some fresh ideas on this Snap Lines?
    Davor Geci
    CEO @ WinPIS
    Take a look at my Virtual Forms project (create database apps in minutes with vb6)

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    15,711

    Re: Positioning Controls Using Snap Lines at RunTime

    Never heard of snap lines until I read this post. Many have likely coded for 'snap-to-grid'. If coding this yourself, I'd think studying how VS does it would be helpful, i.e., on a crowded form, how many snap lines appear. A crowded form may be more helpful in understanding the logic used by VS. In any case, such a line would likely be a custom usercontrol, a thin picturebox, etc, something that can be placed above other controls. Drawing a line or VB line controls won't work because they cannot overlap windowed controls.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    Addicted Member Davor Geci's Avatar
    Join Date
    Sep 2009
    Posts
    132

    Re: Positioning Controls Using Snap Lines at RunTime

    Yes, my main concern is exactly what you are also saying. The crowded form.

    Maybe the way would be to, when the moving starts, to store all the positions of all the controls (environment) in an array and then as the moving proceeds to compare with the values in this array. This will definetly be more faster then always read the positions and properties of the environment. And then when the moving ends (mouse release) to destroy the array.
    Davor Geci
    CEO @ WinPIS
    Take a look at my Virtual Forms project (create database apps in minutes with vb6)

  5. #5
    Addicted Member
    Join Date
    Mar 2017
    Posts
    150

    Re: Positioning Controls Using Snap Lines at RunTime

    Davor

    Are you familiar the MouseDown, MouseUp and MouseMove events?

    Code:
    Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
       ' insert code here
    End Sub
    
    Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
       ' insert code here
    End Sub
    
    Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
       ' insert code here
    End Sub

    In your case, they would probably be associated with the form on which the
    controls occur.

    1. The MouseDown would "detect" which control you select (the X and Y
    trap the mouse position)
    2. The MouseMove would track where you are "dragging" the control.
    3. You could accomplish the Snap "rounding" the X and Y to the nearest,
    say, 100 to 500.
    4. The MouseUp sub could be to reset the .Left and .Top of the selected
    control

    Spoo

  6. #6
    Member
    Join Date
    Mar 2015
    Posts
    52

    Re: Positioning Controls Using Snap Lines at RunTime

    Something like this, but does lines not shapes:

    Name:  lines screen.jpg
Views: 23
Size:  32.9 KB

    Polygon_lines.zip
    Last edited by CreativeDreamer; Mar 24th, 2017 at 02:44 AM. Reason: wrong pic

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.