|
-
Jul 17th, 2001, 05:10 PM
#1
Thread Starter
PowerPoster
Restrict Form Resizing
Does anyone know how to not let the user make the form smaller than a certain size?
I don't really want to use:
VB Code:
If Me.Width <= 5115 Then
Me.Width = 5115
End If
since it flickers when the size is smaller than the one specified.
Any solutions and/or other ways of doing this?
-
Jul 17th, 2001, 06:15 PM
#2
Hyperactive Member
Try using the API
if u use ShowWindow then you can holt the resize in much the same effect.
I'm not to sure of the code now, but I'll post it later, but I know it uses this function.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 17th, 2001, 06:16 PM
#3
Registered User
-
Jul 17th, 2001, 06:17 PM
#4
Lively Member
I am trying to do the same thing also but I subclassed my form and looked for the WM_SIZING msg
Dim r As RECT
Select Case msg
Case WM_SIZING
CopyMemory r, lParam, Len(r)
If (r.Bottom - r.Top) > 441 Or (r.Right - r.Left) > 672 Then
WndProc = CallWindowProc(MainSubclassRet, hwnd, msg, wParam, lParam)
Else
WndProc = 0
End If
Case Else
WndProc = CallWindowProc(MainSubclassRet, hwnd, msg, wParam, lParam)
End Select
The only problem w/ this is that it doesn't stop it once the dimensions are what it is supposed to be at. if you could figure this one out and reply that'd be great
-
Jul 17th, 2001, 07:15 PM
#5
Thread Starter
PowerPoster
Nucleus, that works okay, but the subclassing crashes very often.
-
Jul 17th, 2001, 07:22 PM
#6
Registered User
Don't press the stop button while subclassing else it will crash, unload the form instead.
-
Jul 17th, 2001, 09:38 PM
#7
Try this:
VB Code:
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Dim LockWindow As Boolean
Dim iWidth As Integer
Private Sub Form_Load()
iWidth = Me.Width '5115
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
LockWindowUpdate 0&
End Sub
Private Sub Form_Resize()
On Error Resume Next
Static FirstLoad
If FirstLoad = False Then
FirstLoad = True
LockWindow = True
Exit Sub
End If
If Me.Width <= iWidth Then
If LockWindow = True Then
Me.Width = iWidth
LockWindowUpdate Me.hWnd
End If
End If
End Sub
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
|