I have form that I didnt care how big it gets but want to limit how small resize can be.
How is this acomplish?
Printable View
I have form that I didnt care how big it gets but want to limit how small resize can be.
How is this acomplish?
You'd have to subclass, and catch the WM_SIZING message. Then just do something like:
If myform.width < x and myform.height < y then
myform.width=x
myform.height=y
exit function
end if-
Private Sub Form_Resize()
If Me.Height < 5000 Then
Me.Height = 5000
End If
If Me.Width < 5000 Then
Me.Width = 5000
End If
End Sub
messy but works
Actually this would work too.
Code:Private Sub Form_Resize()
If Me.Width < 2000 Then Me.Width = 2000
If Me.Height < 2000 Then Me.Height = 2000
End Sub
Mr. Megatron that you. I am reading many of your writings and you are very good.
How is this subclassing you speak of done? I would like to learn?
It's done via SetWindowLong. I don't have my ApiViewer on this machine, but I'll try to find an example on the net for you.
Many thank yous Mr. Megatron
This link shows a basic example of subclassing.
THank you Mr. Megatron, but how do I sue this to stop resize from being to small?
Is there noone to help?
Using the EventVB.dll it can be done thus:
VB Code:
Option Explicit Dim WithEvents vbLink As EventVB.APIFunctions Dim WithEvents vbWnd As EventVB.ApiWindow Const WNDMINWIDTH = 200 Const WNDMINHEIGHT = 200 Const WNDMAXWIDTH = 400 Const WNDMAXHEIGHT = 400 Private Sub Form_Load() Set vbLink = New APIFunctions Set vbWnd = New ApiWindow vbWnd.hWnd = Me.hWnd vbLink.SubclassedWindows.Add vbWnd End Sub Private Sub vbLink_ApiError(ByVal Number As Long, ByVal Source As String, ByVal Description As String) Debug.Print Description & " - " & Source End Sub Private Sub vbWnd_MinMaxSize(MaxHeight As Long, MaxWidth As Long, MaxPositionTop As Long, MaxPositionLeft As Long, MinTrackWidth As Long, MinTrackheight As Long, MaxTrackWidth As Long, MaxTrackHeight As Long) MaxHeight = WNDMAXHEIGHT MaxWidth = WNDMAXWIDTH End Sub Private Sub vbWnd_Sizing(ByVal SizeEdges As EventVB.WindowSizingEdges, DragRectangle As EventVB.APIRect) With DragRectangle If .Bottom - .Top < WNDMINHEIGHT Then If SizeEdges = WMSZ_BOTTOM Or SizeEdges = WMSZ_BOTTOMLEFT Or SizeEdges = WMSZ_BOTTOMRIGHT Then .Bottom = .Top + WNDMINHEIGHT Else .Top = .Bottom - WNDMINHEIGHT End If ElseIf .Bottom - .Top > WNDMAXHEIGHT Then If SizeEdges = WMSZ_BOTTOM Or SizeEdges = WMSZ_BOTTOMLEFT Or SizeEdges = WMSZ_BOTTOMRIGHT Then .Bottom = .Top + WNDMAXHEIGHT Else .Top = .Bottom - WNDMAXHEIGHT End If End If If .Right - .Left < WNDMINWIDTH Then If SizeEdges = WMSZ_RIGHT Or SizeEdges = WMSZ_BOTTOMRIGHT Or SizeEdges = WMSZ_TOPRIGHT Then .Right = .Left + WNDMINWIDTH Else .Left = .Right - WNDMINWIDTH End If ElseIf .Right - .Left > WNDMAXWIDTH Then If SizeEdges = WMSZ_RIGHT Or SizeEdges = WMSZ_BOTTOMRIGHT Or SizeEdges = WMSZ_TOPRIGHT Then .Right = .Left + WNDMAXWIDTH Else .Left = .Right - WNDMAXWIDTH End If End If End With End Sub
Hope this helps,
Duncan