Private Shared WM_SYSCOMMAND As Integer = &H112
Private Shared SC_MAXIMIZE As Integer = &HF030
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND AndAlso (m.WParam.ToInt32() And 65520) = SC_MAXIMIZE Then
Return
End If
MyBase.WndProc(m)
End Sub
You guys should keep in mind that with Logitech mice you can still maximize a window regarless if the MaximizeBox is disabled or removed from the title bar
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.WindowState = FormWindowState.Maximized Then
Me.WindowState = FormWindowState.Normal
End If
End Sub
You mean if i set MaximizeBox=False or if I use JohnH's code, still no effect?
For my knowledge can you name the model of that mouse?
as you said i tried this piece of code but it will maximize first and then it will become to normal state. I even tried ResizeBegin and ResizeEnd events but still the same.
VB.NET:Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize If Me.WindowState = FormWindowState.Maximized Then Me.WindowState = FormWindowState.Normal End If End Sub
All of them that have the "Maximize Window" option for any of the buttons, which is every model since 1999
I also found out it can be done with the Microsoft and Belkin mice as well
Module Win32
Declare Function SetWindowPlacement Lib "user32.dll" (ByVal hwnd As Int32, ByRef lpwndpl As WINDOWPLACEMENT) As Int32
Declare Function GetWindowPlacement Lib "user32.dll" (ByVal hwnd As Int32, ByRef lpwndpl As WINDOWPLACEMENT) As Int32
Structure WINDOWPLACEMENT
Public Length As Int32
Public flags As Int32
Public showCmd As Int32
Public ptMinPosition As POINTAPI
Public ptMaxPosition As POINTAPI
Public rcNormalPosition As RECT
End Structure
Structure POINTAPI
Public x As Int32
Public y As Int32
End Structure
Structure RECT
Public Left As Int32
Public Top As Int32
Public Right As Int32
Public Bottom As Int32
End Structure
Public Const SW_SHOWMAXIMIZED As Int32 = 3
Public Const WM_SYSCOMMAND As Integer = &H112
Public Const SC_MAXIMIZE As Integer = &HF030
Public Const WM_GETMINMAXINFO As Int32 = &H24
Structure MINMAXINFO
Public ptReserved As POINTAPI
Public ptMaxSize As POINTAPI
Public ptMaxPosition As POINTAPI
Public ptMinTrackSize As POINTAPI
Public ptMaxTrackSize As POINTAPI
End Structure
End Module
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim wp As WINDOWPLACEMENT
GetWindowPlacement(Me.Handle.ToInt32, wp)
wp.showCmd = SW_SHOWMAXIMIZED
SetWindowPlacement(Me.Handle.ToInt32, wp)
End Sub
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32() = SC_MAXIMIZE Then
Return
ElseIf m.Msg = WM_GETMINMAXINFO Then
Dim mm As MINMAXINFO = Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, GetType(MINMAXINFO))
mm.ptMaxSize.x = Me.Width
mm.ptMaxSize.y = Me.Height
mm.ptMaxPosition.x = Me.Location.X
mm.ptMaxPosition.y = Me.Location.Y
Runtime.InteropServices.Marshal.StructureToPtr(mm, m.LParam, True)
End If
MyBase.WndProc(m)
End Sub
All of them that have the "Maximize Window" option for any of the buttons, which is every model since 1999
I also found out it can be done with the Microsoft and Belkin mice as well
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.WindowState = FormWindowState.Maximized Then
Me.WindowState = FormWindowState.Normal
End If
End Sub