Visual Basic Forum

Visual Basic Forum
für VB6 und VB.NET Programmierer
 
RegistrierenRegistrieren  LoginLogin

Neues Thema eröffnen   Neue Antwort erstellen    Visual Basic Forum Foren-Übersicht -> [VB6] Source Codes
Autor
Nachricht
ZiG
Überflieger
Überflieger

Anmeldedatum: 16.04.2008
Beiträge: 421

Fenstergröße limitieren
Verfasst am: 18.06.2009, 11:51

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))

MM.ptMaxPosition.x = 0
MM.ptMaxPosition.y = 0
MM.ptMaxSize.x = Screen.Width / Screen.TwipsPerPixelX
MM.ptMaxSize.y = Screen.Height / Screen.TwipsPerPixelY

MM.ptMinTrackSize.x = spR.xMin
MM.ptMinTrackSize.y = spR.yMin
MM.ptMaxTrackSize.x = spR.xMax
MM.ptMaxTrackSize.y = spR.yMax

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.

mfg, ZiG
_________________
 
Neues Thema eröffnen   Neue Antwort erstellen    Visual Basic Forum Foren-Übersicht -> [VB6] Source Codes

Tags: fenstergröße festlegen, visual basic, vb6

 
 Verwandte Themen   Aufrufe   Letzter Beitrag 
Keine neuen Beiträge Wie kann ich mich bei euch anmelden?? 796 20.05.2002, 00:28
Keine neuen Beiträge Eine kleine Frage an euch.. 906 30.09.2007, 08:57
Keine neuen Beiträge TopMost Funktion unter DirectX 921 27.07.2007, 10:48
Keine neuen Beiträge Wie Funktion nutzen ? 1098 29.06.2007, 20:59
Keine neuen Beiträge update funktion einbauen 1341 28.01.2007, 23:11
 



[ Time: 0.1281s ][ Queries: 81 (0.0217s) ][ GZIP on - Debug on ]