Results 1 to 11 of 11

Thread: Resize form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Adelaide, Australia
    Posts
    27

    Question Resize form

    Im looking to add a image to the form, so when its clicked it resizes the form. Just like the bit at the bottom right of winamp 3 (for an image of the button im talking about view the attachment), without having to have the whole status bar.

    is is possible?

    chadwick

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Private Sub Image1_Click()
    Me.Move 45, 43, 2000, 2000
    End Sub
    -= a peet post =-

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Adelaide, Australia
    Posts
    27

    what did that do?

    thats not what im looking for, im looking to make it the same as if i had a resizable border.

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Re: what did that do?

    Originally posted by ChAdWiCk
    Im looking to add a image to the form, so when its clicked it resizes the form....
    thats what the code do , but its obv. not what you want
    -= a peet post =-

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Adelaide, Australia
    Posts
    27

    Question

    im looking to make it the same as if i had a resizable border. know how to do it

  6. #6
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Not quite sure what you mean. You want to be able to resize an image just like how you would drag a Form? (e.g. by clicking on its borders and dragging it)

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Adelaide, Australia
    Posts
    27
    no resize the form. do the exact same thing as if i had a resizeable border (but i dont).

    what im going to do is put an image in the bottom right corner. so that if its clicked, you can use the form just like to would if u had clicked the reszable border of the form.

  8. #8
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    This will take care of the dragging.
    VB Code:
    1. Dim OldX As Single
    2. Dim OldY As Single
    3.  
    4. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     If Button = 1 Then
    6.         OldX = X
    7.         OldY = Y
    8.     End If
    9. End Sub
    10.  
    11. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     If Button = vbLeftButton Then Me.Move Me.Left + (X - OldX), Me.Top + (Y - OldY)
    13. End Sub

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Adelaide, Australia
    Posts
    27
    close, that code moves the form. Im hoping that i can get it to resize the form.

  10. #10
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Here's some code from Aaron Young that drags and moves a borderless Form. It's doesn't do exactly what you want, but if you fiddle with it for a bit, you could probably get it working.
    VB Code:
    1. Public Sub DragControl(ByRef oControl As Object, ByVal Button As Integer, ByVal X As Single, ByVal Y As Single, Optional ByVal bInit As Boolean, Optional ByVal bMoveable As Boolean, Optional ByVal bResizable As Boolean)
    2.     Static lXoff As Single, lYoff As Single, bSizing As Boolean
    3.     Dim bBoth As Boolean, bSized As Boolean
    4.    
    5.     If bInit Then
    6.         If (Y > (oControl.Height - 150) Or X > (oControl.Width - 150)) And bResizable Then
    7.             bSizing = True
    8.         End If
    9.         lXoff = X
    10.         lYoff = Y
    11.         Exit Sub
    12.     End If
    13.    
    14.     If bResizable Then
    15.         bBoth = True
    16.         If Y > (oControl.Height - 150) Then
    17.             oControl.MousePointer = vbSizeNS
    18.         Else
    19.             bBoth = False
    20.         End If
    21.         If X > (oControl.Width - 150) Then
    22.             oControl.MousePointer = IIf(bBoth, vbSizeNWSE, vbSizeWE)
    23.         Else
    24.             If Not bBoth Then oControl.MousePointer = vbDefault
    25.         End If
    26.     End If
    27.    
    28.     If bResizable And bSizing Then
    29.         If Button = vbLeftButton Then
    30.             If (Y > (oControl.Height - 150) Or X > (oControl.Width - 150)) Then
    31.                 bBoth = True
    32.                 If Y > (oControl.Height - 150) Then
    33.                     oControl.MousePointer = vbSizeNS
    34.                     If Button = vbLeftButton Then
    35.                         oControl.Height = oControl.Height + Y - lYoff
    36.                         lYoff = oControl.Height
    37.                         lXoff = oControl.Width
    38.                         bSized = True
    39.                     End If
    40.                 Else
    41.                     bBoth = False
    42.                 End If
    43.                 If X > (oControl.Width - 150) Then
    44.                     oControl.MousePointer = IIf(bBoth, vbSizeNWSE, vbSizeWE)
    45.                     If Button = vbLeftButton Then
    46.                         oControl.Width = oControl.Width + X - lXoff
    47.                         lYoff = oControl.Height
    48.                         lXoff = oControl.Width
    49.                         bSized = True
    50.                     End If
    51.                 End If
    52.             End If
    53.         Else
    54.             oControl.MousePointer = vbDefault
    55.             bSizing = False
    56.         End If
    57.     End If
    58.    
    59.     If Not bSized And bMoveable And Not bSizing Then
    60.         If Button = vbLeftButton Then oControl.Move oControl.Left + X - lXoff, oControl.Top + Y - lYoff
    61.     End If
    62.  
    63. End Sub
    64.  
    65.  
    66. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    67.     DragControl Form1, Button, X, Y, True, True, True
    68. End Sub
    69.  
    70. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    71.     DragControl Form1, Button, X, Y, False, True, True
    72. End Sub

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    Adelaide, Australia
    Posts
    27

    Exclamation thanks

    thanks for that anyways, i will see what i can do with the code.

    chad

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