Results 1 to 4 of 4

Thread: Nice way to align controls (like vb.net does)

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Nice way to align controls (like vb.net does)

    If you are making a program, in which you want to user to be able to change the interface after runtime..this simple code might be of use:

    Add two lines to your project, line 1 and line 2
    VB Code:
    1. Private Sub Cmd_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Static iX   As Single
    3. Static iY   As Single
    4.  
    5.     If (Button = vbLeftButton) Then
    6.         X = (X - iX)
    7.         Y = (Y - iY)
    8.  
    9.         Cmd(Index).Move (Cmd(Index).Left + X), _
    10.                       (Cmd(Index).Top + Y)
    11.     With Line1
    12.         .X1 = 0
    13.         .X2 = Me.Left + Me.Width
    14.         .Y1 = Cmd(Index).Top
    15.         .Y2 = Cmd(Index).Top
    16.     End With
    17.     With Line2
    18.         .X1 = Cmd(Index).Left + Cmd(Index).Width
    19.         .X2 = .X1
    20.         .Y1 = 0
    21.         .Y2 = Me.Top + Me.Height
    22.     End With
    23.       Else
    24.         iX = X
    25.         iY = Y
    26.     End If
    27. End Sub

    This way, while the users moves the button, the lines will show them whats aligned or not

    Its pretty easy, but really nice

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Nice way to align controls (like vb.net does)

    I used a slightly modified version of this the other day and it worked pretty well.

  3. #3
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Re: Nice way to align controls (like vb.net does)

    I've used it a couple of times.

    Pretty slick...
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  4. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Nice way to align controls (like vb.net does)

    thanks

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