Change Maximize behavior with Wndproc or Override

Asked

Viewed 29 times

1

I have a form without edge and need to maximize and restore it, but as you already know if I use Me.WindowState = FormWindowState.Maximized He stays on Full Screen.

I already have a way:

Dim tela As Screen = Screen.FromPoint(Me.Location) Me.Size = New Size(tela.WorkingArea.Size.Width, tela.WorkingArea.Size.Height) Me.Location = tela.WorkingArea.Location 'New Point(0, 0)

I would not like to do this put I would have to save the state (location and size) before the Form be "Maximized" by the code above, to restore it later. What I wanted was for him to execute the above code and think he’s Maximized.

I had already used the WndProc and Protected Overrides ReadOnly Property to solve some other problems. Ex:

'Minimiza da Taskbar
Private Const WS_MINIMIZEBOX As Integer = &H20000
Private Const CS_DBLCLKS As Integer = &H8

Protected Overrides ReadOnly Property CreateParams As CreateParams
    'Minimiza da Taskbar
    Get
        Dim cp As CreateParams = MyBase.CreateParams
        cp.Style = cp.Style Or WS_MINIMIZEBOX
        cp.ClassStyle = cp.ClassStyle Or CS_DBLCLKS
        Return cp
    End Get
End Property

And

    Protected Overrides Sub WndProc(ByRef m As Message)
        Dim p As Point = Me.PointToClient(MousePosition)

        If m.Msg = &H84 Then
            Dim pos As Point = New Point(m.LParam.ToInt32() And &HFFFF, m.LParam.ToInt32() >> 16)
            pos = Me.PointToClient(pos)

            'Move Form
            If  pos.Y <= 10 Then
                 m.Result = CType(2, IntPtr)
                Return
           End If
End Sub

But I don’t know the "value" of maximize, I’ve done some searches, but I haven’t found the value. So summarizing the question how I can give a "Override" so that when I maximize the program with Me.WindowState = FormWindowState.Maximized He runs the code I showed him at the beginning? And if possible a list with the existing "values", put still there are some that I need, but I can not find.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.