Resizing the control in Runtime !?

Hello, I am a beginner of VB, I just got a problem...
I am writing a program and i want the listview/text box in the interface can be resized in runtime by using the mouse drap and drop.
Pls give me some suggestion !!! ..how can i do it ??
Pls give me a EXAMPLE and Descriptions!!!
THANX VERY MUCH!!!

Raymond
rngAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caraf_gCommented:
With thanks to waty:

1 - BAS Module Code

Option Explicit

'windows constants  
Public Const SWP_DRAWFRAME = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H4
Public Const SWP_FLAGS = SWP_NOZORDER Or SWP_NOSIZE Or _
                         SWP_NOMOVE Or SWP_DRAWFRAME
Public Const GWL_STYLE = (-16)
Public Const WS_THICKFRAME = &H40000


Public Declare Function GetWindowLong Lib _
    "user32" Alias "GetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong Lib _
    "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, _
     ByVal dwNewLong As Long) As Long

Public Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
     ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
     ByVal cy As Long, ByVal wFlags As Long) As Long


1 - Form Code

'To a form add a text box (Text1), a command '
'button (cmdEnd), 2 menu items (mnuSize & 
'mnuRestore), and 2 labels (Label1 & Label2).
'Add the following code to the form:

Option Explicit

  'initial Form_Load variables  
   Dim initBoxStyle As Long
   Dim initLeft As Integer
   Dim initTop As Integer
   Dim initWidth As Integer
   Dim initHeight As Integer

Private Sub Form_Load()

  'position the form  
   Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
 
  'set up a few variables needed later  
   initBoxStyle = GetWindowLong(Text1.hwnd, GWL_STYLE)
   initLeft = Text1.Left
   initTop = Text1.Top
   initWidth = Text1.Width
   initHeight = Text1.Height

  'make sure the defaults are set  
   SetControlStyle initBoxStyle, Text1
   
   Label1 = "Text Width  : " & Text1.Width
   Label2 = "Text Height : " & Text1.Height

End Sub


Private Sub Form_Unload(Cancel As Integer)

  'restore the control to a normal textbox  
   SetControlStyle initBoxStyle, Text1

End Sub


Private Sub Form_Click()

  'restore the control to a normal textbox  
   SetControlStyle initBoxStyle, Text1
   
   Label1 = "Text Width  : " & Text1.Width
   Label2 = "Text Height : " & Text1.Height
   
End Sub


Private Sub mnuSize_Click()

   Dim style As Long
 
  'get the current style attributes for the textbox  
   style = GetWindowLong(Text1.hwnd, GWL_STYLE)
 
  'modify the style to show the sizing frame  
   style = style Or WS_THICKFRAME
 
  'set the control to the chosen style  
   SetControlStyle style, Text1

End Sub


Private Sub mnuRestore_Click()

  'restore the control to a normal textbox  
   SetControlStyle initBoxStyle, Text1
   
End Sub


Private Sub cmdEnd_Click()
    Unload Me
    End
End Sub


Private Sub SetControlStyle(style, X As Control)
   
  Dim r
   
  If style Then
    Call SetWindowLong(X.hwnd, GWL_STYLE, style)
    Call SetWindowPos(X.hwnd, Form1.hwnd, 0, 0, 0, 0, SWP_FLAGS)
  End If

End Sub

'Comments
'Save the app & run. Clicking the 'Size' menu '
'item will cause the textbox border to change'
'into a sizeable frame. After resizing, clicking
'the form or selecting 'Restore' will return the
'textbox to the normal textbox style at the
'selected size and position.

'This same technique can also be successfully
'applied to lists, listviews, treeviews,
'pictureboxes ... pretty well most VB controls.


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.