|
-
Oct 7th, 2002, 09:22 AM
#1
Thread Starter
Addicted Member
Resize Form
I have form that I didnt care how big it gets but want to limit how small resize can be.
How is this acomplish?
Catholics Do It With Beads
-
Oct 7th, 2002, 09:30 AM
#2
Software Eng.
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-
-
Oct 7th, 2002, 09:30 AM
#3
Lively Member
Try this...
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
-
Oct 7th, 2002, 09:32 AM
#4
Software Eng.
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
-
Oct 7th, 2002, 09:33 AM
#5
Thread Starter
Addicted Member
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?
Catholics Do It With Beads
-
Oct 7th, 2002, 09:44 AM
#6
Software Eng.
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.
-
Oct 7th, 2002, 09:45 AM
#7
Thread Starter
Addicted Member
Many thank yous Mr. Megatron
Catholics Do It With Beads
-
Oct 7th, 2002, 09:48 AM
#8
Software Eng.
This link shows a basic example of subclassing.
-
Oct 7th, 2002, 11:04 AM
#9
Thread Starter
Addicted Member
THank you Mr. Megatron, but how do I sue this to stop resize from being to small?
Catholics Do It With Beads
-
Oct 8th, 2002, 06:07 AM
#10
Thread Starter
Addicted Member
Catholics Do It With Beads
-
Oct 8th, 2002, 06:19 AM
#11
Frenzied Member
Controling form resizing *FAQ*
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|