Rubrik: Oberfläche · Fenster | VB-Versionen: VB4, VB5, VB6 | 04.12.00 |
MinMax-Buttons in Dialogfenstern Fenster mit der Eigenschaft BorderStyle = 3 - Fester Dialog haben bekanntlich keinen Minimieren- oder Maximieren Button in der Titelleiste. Mit der ... | ||
Autor: Dieter Otter | Bewertung: | Views: 13.273 |
www.tools4vb.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Fenster mit der Eigenschaft BorderStyle = 3 - Fester Dialog haben bekanntlich keinen Minimieren- oder Maximieren Button in der Titelleiste. Mit der nachfolgenden Routine können Sie dem Fenster diese Buttons jederzeit hinzufügen.
' zunächst die benötigten Deklarationen Private Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" ( _ ByVal hwnd As Long, _ ByVal nIndex 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 Const GWL_STYLE = (-16) Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_MAXIMIZEBOX = &H10000 ' Setzen der Minimieren bzw. Maximieren-Buttons Public Sub FormAddMinMaxButtons(hWnd As Long, _ Optional ByVal MinBtn As Boolean = True, _ Optional ByVal MaxBtn As Boolean = True) Dim lStyle As Long lStyle = GetWindowLong(hWnd, GWL_STYLE) ' Minimieren-Button hinzufügen If (MinBtn) Then _ lStyle = (lStyle Or WS_MINIMIZEBOX) ' Maximieren-Button hinzufügen If (MaxBtn) Then _ lStyle = (lStyle Or WS_MAXIMIZEBOX) Call SetWindowLong(hWnd, GWL_STYLE, lStyle) End Sub
Beispiel:
Private Sub Form_Load() ' Nur Minimieren-Button hinzufügen FormAddMinMaxButtons Me.hWnd, True, False End Sub