dcsimg
Results 1 to 9 of 9

Thread: Let Users Move/Resize Controls at Runtime

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    Let Users Move/Resize Controls at Runtime

    Here I am presenting a sample that I found floating on internet.

    This Code allows one to implement a VB IDE like behavior that allows a user to move and resize controls at runtime!

    Imagine the possibilities! There are many. For example you will be able to allow your users to arrange the content of any form in your software according to their requirement!

    Of course you will have to code the part of saving the location of controls.

    Anyways please check this out and enjoy it as much as I have enjoyed it and used it.

    Yogi Yang
    Attached Files Attached Files

  2. #2
    Lively Member Arispan's Avatar
    Join Date
    Apr 2010
    Location
    Greece, Near Athens
    Posts
    98

    Re: Let Users Move/Resize Controls at Runtime

    WOW! Just what I needed. Thanks!
    MOBO: Asrock X58 Extreme
    CPU : Core i7 950 @ 3.07Ghz
    Ram : 8GB
    Hard Drive : 1.5 TB (1 TB, 500GB)
    Graphics : ATI Radeon HD 5670
    Dual Boot : Windows XP Home, Windows 7 Ultimate x64


    _____________________
    If a reply has helped you, please consider rating it.

  3. #3
    New Member
    Join Date
    Dec 2016
    Posts
    1

    Re: Let Users Move/Resize Controls at Runtime

    Quote Originally Posted by yogiyang View Post
    Here I am presenting a sample that I found floating on internet.

    This Code allows one to implement a VB IDE like behavior that allows a user to move and resize controls at runtime!

    Imagine the possibilities! There are many. For example you will be able to allow your users to arrange the content of any form in your software according to their requirement!

    Of course you will have to code the part of saving the location of controls.

    Anyways please check this out and enjoy it as much as I have enjoyed it and used it.

    Yogi Yang
    Hi, I really like your code but I can't get it to work when I want to move controls inside of a UserControl. I get 438 run-time error on the ClientToScreen api. It appears to have a handle value.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    Re: Let Users Move/Resize Controls at Runtime

    Hello,
    Actually I have never tried to run the code in a custom control (User Control). So I can't help you here.

    Hope someone more talented than me would help you out.

    Regards,

    Yogi Yang

  5. #5
    Addicted Member
    Join Date
    Aug 2017
    Location
    South Africa (in the middle)
    Posts
    160

    Re: Let Users Move/Resize Controls at Runtime

    Now if someone can just add rotate with this....

  6. #6
    PowerPoster
    Join Date
    Oct 2013
    Posts
    3,184

    Re: Let Users Move/Resize Controls at Runtime

    Rotate a control??

  7. #7
    Addicted Member
    Join Date
    Aug 2017
    Location
    South Africa (in the middle)
    Posts
    160

    Re: Let Users Move/Resize Controls at Runtime

    Quote Originally Posted by Arnoutdv View Post
    Rotate a control??
    Yip. That's the idea....

  8. #8
    PowerPoster
    Join Date
    Oct 2013
    Posts
    3,184

    Re: Let Users Move/Resize Controls at Runtime

    You want to have for example a ListBox rotated at 30 degrees?
    What does this has to do with the moving and resizing controls?
    You completely lost me, but the source code is available, so you are free to make these enhancements yourself

  9. #9
    Addicted Member
    Join Date
    Aug 2017
    Location
    South Africa (in the middle)
    Posts
    160

    Re: Let Users Move/Resize Controls at Runtime

    Quote Originally Posted by Arnoutdv View Post
    ...What does this has to do with the moving and resizing controls?
    You completely lost me,...
    This is good code. I like it.
    If I can get my hands on a rotating tool for some toolboxes, it will perfect for some programs with this (moving and resizing) code included.
    It was a bit misleading...

    Some of the tools cannot be dragged or resized. Here are some of them:
    RTFBox
    SSCommand
    Combo

    Needs to be placed inside a panel or picture box. Then double click on the frame/picturebox to resize (any) toolbox/s inside to correct width and/or height (Remember: Combo height cannot be resized).

    Here are some coding I added:
    Code:
    Private Sub Frame2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton And m_bDesignMode Then
            DragBegin Frame2
        End If
    
    End Sub
    
    Private Sub Frame2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
       If m_bDesignMode Then
          MCoM.Width = Frame2.Width - 240
       End If
    
    End Sub
    ...and it looks like this:
    Name:  Image 013.png
Views: 581
Size:  560 Bytes

    ========
    For the RTF:
    Code:
    Private Sub SSFra_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        If Button = vbLeftButton And m_bDesignMode Then
            DragBegin SSFra
        End If
    
    End Sub
    
    Private Sub SSFra_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        If m_bDesignMode Then
            RTX.Width = SSFra.Width - 120
            RTX.Height = SSFra.Height - 300
        End If
    
    End Sub
    ...and:
    Name:  Image 014.png
Views: 580
Size:  784 Bytes

    [Edited to add:]

    Program working:
    Name:  Image 015.png
Views: 583
Size:  937 BytesName:  Image 016.png
Views: 581
Size:  2.3 KB
    Last edited by Inside; Aug 10th, 2017 at 02:25 AM.

Tags for this Thread

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