-1

I am not familiar with Windows API. I copy a code about resizing a userform using W.API but then I also want to bind the multipage's width to the userform while resizing it. Can I also use W.API to multipage or any other object? or its only for active window? .

Here is the code.

Private Sub MakeFormResizable()

Dim lStyle As Long
Dim hWnd As Long
Dim RetVal

Const WS_THICKFRAME = &H40000
Const GWL_STYLE As Long = (-16)

hWnd = GetActiveWindow


lStyle = GetWindowLong(hWnd, GWL_STYLE) Or WS_THICKFRAME


RetVal = SetWindowLong(hWnd, GWL_STYLE, lStyle)


SetLastError 0 
End Sub

Thanks!.

remoel
  • 175
  • 8
  • If a window isn't prepared to be resized, there's nothing the Windows API can do about it. Code is required to adjust the size and position of child controls in response to resizing a window. The Windows API won't create that code out of thin air for you. – IInspectable Dec 21 '17 at 00:49
  • is there any other way to to do it? any suggestion? I mean it can be done after I resized the window. but its kinda look bad seeing it delaying. :( – remoel Dec 21 '17 at 00:56

1 Answers1

0

You can change the width and height of a user form by setting the height and width properties. Given a userform called "frmDemo" with a multipage control called "mpFred" then this will change it

Sub MakeBigger()
    frmDemo.width = frmdemo.width + 100 'increase by 100 points
    frmDemo.Height = 650 'set to specific value
    frmDemo.Controls("mpfred").width =frmDemo.Controls("mpfred").width + 100
    frmDemo.Controls("mpfred").height = frmdemo,height - 20  'slightly shorter than the form

End Sub
Harassed Dad
  • 4,669
  • 1
  • 10
  • 12
  • Hi. Thanks for answering, but what I wanted to do is as I resize the userform, the multipage also resizing. It's like resizing your browser and somehow the content inside also change. I already have a running code after I'm finished resizing the userform. – remoel Jan 03 '18 at 01:58
  • This is what I'm looking for. Thanks.! – remoel Jan 04 '18 at 06:24