Avatar billede sorenstrom Nybegynder
07. november 2003 - 13:45 Der er 4 kommentarer og
1 løsning

Fjerne Maximer på MDI-form

Kan det lade sig gøre, at fjerne muligheden for at kunne maximere en MDI-form?

/Søren
Avatar billede sjh Nybegynder
08. november 2003 - 04:36 #1
'---------------------------------- MIDForm1 ----------------------------------
Option Explicit

Private Const GWL_STYLE      As Long = (-16)
Private Const WS_MAXIMIZEBOX As Long = &H10000
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 Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetParent Lib "user32" ( _
                                      ByVal hWndChild As Long, _
                                      ByVal hWndNewParent 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 SetParent(hWnd, GetParent(hWnd))
  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)
End Sub
'---------------------------------- MIDForm1 ----------------------------------
Avatar billede sjh Nybegynder
08. november 2003 - 21:34 #2
du behøver ikke disse linjer:

'Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
'Private Declare Function SetParent Lib "user32" ( _
                                      ByVal hWndChild As Long, _
                                      ByVal hWndNewParent As Long) As Long

'Call SetParent(hWnd, GetParent(hWnd))
Avatar billede sorenstrom Nybegynder
09. november 2003 - 19:53 #3
>> sjh
Jeg kan desværre ikke få det til at virke
Avatar billede sjh Nybegynder
09. november 2003 - 22:55 #4
har du prøvet på en ny MIDForm1??
Avatar billede sjh Nybegynder
09. november 2003 - 22:57 #5
husk at der er forskel på ...MDIForm_Load() og ...Form_Load()

undre load:
  Call DisableMax(Me.hWnd)
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