Ich hab mir mal gedacht ich poste euch diesen source, da es sicher einige gibt die ihn gebrauchen können.
Hiermit kann man also ein Minumum und Maximum der Fenstergröße festlegen.
Code in ein Modul einfügen. Visual Basic: [code] Option Explicit
Private Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Sub CopyMemory1 Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Declare Sub CopyMemory2 Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Any, Source As Any, ByVal Length As Long)
Private Type POINTAPI x As Long y As Long End Type
Private Type MINMAXINFO ptReserved As POINTAPI ptMaxSize As POINTAPI ptMaxPosition As POINTAPI ptMinTrackSize As POINTAPI ptMaxTrackSize As POINTAPI End Type
Public Type SIZEPAR xMin As Long yMin As Long xMax As Long yMax As Long End Type
Private Const GWL_WNDPROC As Long = -4& Private Const WM_GETMINMAXINFO As Long = &H24&
Private WinOldProc As Long Private spR As SIZEPAR Private Frm As Form
Public Sub Init(F As Form, R As SIZEPAR) spR = R Set Frm = F WinOldProc = SetWindowLong(Frm.hWnd, GWL_WNDPROC, AddressOf WindowProc) End Sub
Public Sub UnHook() Call SetWindowLong(Frm.hWnd, GWL_WNDPROC, WinOldProc) End Sub
Private Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam&) As Long Dim Result As Long Dim MM As MINMAXINFO
If uMsg = WM_GETMINMAXINFO And Frm.WindowState = 0 Then Call CopyMemory1(MM, lParam, Len(MM))
Call CopyMemory2(lParam&, MM, Len(MM)) Result = DefWindowProc(hWnd, uMsg, wParam, lParam) Else Result = CallWindowProc(WinOldProc, hWnd, uMsg, wParam, lParam) End If
WindowProc = Result End Function [/code] Benutzung: Code in Form_Load einfügen. Visual Basic: [code] 'Form limitieren '####################### Dim R As SIZEPAR With R .xMax = Screen.Width 15 .yMax = Screen.Height 15 .xMin = 725 .yMin = 560 End With Call Init(main_frm, R) '####################### [/code]Bei xMin und yMin könnt ihr dann die Größe festlegen. xMax und yMax wird in diesem Fall die Maximale Größe des Bildschirmes übergeben.
Achtung Beim debuggen verursacht diese Funktion Probleme. Vb6 hängt, bzw. stürzt dann ab. Am besten beim coden als Kommentar einfügen und erst vorm kompilieren aktivieren.