Avatar billede steffen8260 Nybegynder
26. januar 2004 - 12:18 Der er 2 løsninger

Maximize & minimize knap på mdiform

Hej
Hvordan kan jeg fjerne maximize & minimize knappen på en mdiform?

steffen@sbrandsborg.dk
Avatar billede sjh Nybegynder
26. januar 2004 - 12:21 #1
Avatar billede sjh Nybegynder
26. januar 2004 - 12:28 #2
'---------------------------------- MIDForm1 ----------------------------------
Option Explicit

Private Const GWL_STYLE      As Long = (-16)
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_MINIMIZEBOX As Long = &H20000

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 HWND_NOTOPMOST  As Long = (-2)
Private Const SWP_NOZORDER    As Long = &H4
Private Const SWP_NOSIZE      As Long = &H1
Private Const SWP_NOMOVE      As Long = &H2
Private Const SWP_FRAMECHANGED As Long = &H20
Private Declare Function SetWindowPos Lib "user32" ( _
                                      ByVal hWnd As Long, _
                                      ByVal hWndInsertAfter As Long, _
                                      ByVal x As Long, _
                                      ByVal y As Long, _
                                      ByVal cx As Long, _
                                      ByVal cy As Long, _
                                      ByVal wFlags As Long) As Long

Public Sub DisableMax(ByVal hWnd As Long)
Dim lStyle As Long
  lStyle = GetWindowLong(hWnd, GWL_STYLE)
  lStyle = (lStyle And Not WS_MAXIMIZEBOX)
  Call SetWindowLong(hWnd, GWL_STYLE, lStyle)
  Call SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
                              SWP_NOZORDER Or SWP_NOSIZE Or _
                              SWP_NOMOVE Or SWP_FRAMECHANGED)
End Sub

Public Sub DisableMin(ByVal hWnd As Long)
Dim lStyle As Long
  lStyle = GetWindowLong(hWnd, GWL_STYLE)
  lStyle = (lStyle And Not WS_MINIMIZEBOX)
  Call SetWindowLong(hWnd, GWL_STYLE, lStyle)
  Call SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
                              SWP_NOZORDER Or SWP_NOSIZE Or _
                              SWP_NOMOVE Or SWP_FRAMECHANGED)
End Sub

Private Sub MDIForm_Load()
  Call DisableMax(Me.hWnd)
  Call DisableMin(Me.hWnd)
End Sub
'---------------------------------- MIDForm1 ----------------------------------
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester