Results 1 to 3 of 3

Thread: Resize Shape[rectangle] through mouse in run time

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2010
    Posts
    33

    Resize Shape[rectangle] through mouse in run time

    Hello,

    shall we resize a shape control[rectangle] through mouse move. If possible how to write the code.

    code help please.

    Thanks
    Thendral

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Resize Shape[rectangle] through mouse in run time

    You will have to figure out, through code, whether the mouse is in an area that you want the user to be able to click on to begin resizing. If you were to use the MouseDown & MouseMove events of a control, it won't help much if user is over a border since that area is generally not reported back to VB. The shape control has no mouse events anyway

    Tip: It might prove easier to not worry about MouseDown events for the control, but rather the MouseDown/MouseMove events for the container the control is on. When the MouseDown event occurs check its X,Y coordinate against the bounds of your control if its in an area you say is acceptable, set a flag and cache the X,Y coordinates. From that point on, it will be the same principle used to move image/label controls during runtime. The only difference is you won't be moving, you will be resizing.
    Searching the forum can help there, search for: move label image
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Resize Shape[rectangle] through mouse in run time

    Something as silly as this very quick sample may work for you...
    Code:
    Option Explicit
    
    Private StillDragging As Boolean
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        StillDragging = True
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Not StillDragging Then Exit Sub
        If X < Shape1.Left Then Exit Sub
        If Y < Shape1.Top Then Exit Sub
        Shape1.Move Shape1.Left, Shape1.Top, X - Shape1.Left, Y - Shape1.Top
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        StillDragging = False
    End Sub
    You may need to restrict refion for mouse to allow/disallow resizing (just like toolbar or form have).

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