Question : Windows Mobile, Visual Basic Need Code to Mimic MinimizeBox.Click

Hello

I have been trying for some time now to find or compose code that would "mimic" the action of "clicking" or "selecting" or "pendown" a form's MinimizeBox when the MinimizeBox is set to true and has an X on it. In other words, what code could be used with an event like button_click that would minimize a form like the user "clicked" the x on the form's minimize box. I'm not trying to close this form  or exist the application, just minimize so that when the user clicks the apps icon under  "program files" the app would start much faster than if closed.

Thank you for your consideration
drspmd

Answer : Windows Mobile, Visual Basic Need Code to Mimic MinimizeBox.Click

Hi Paul

You are right, your latest works like a charm. I actually took what you had given me earlier and found the following works as well.

Imports System.Runtime.InteropServices
Imports System.Text
Public Class Form1
    _
    Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean
     End Function
    Private Const SW_MINIMIZED As Integer = 6

    Private Sub Minimize()
        ' The Taskbar must be enabled to be able to do a Smart Minimize
        Me.FormBorderStyle = FormBorderStyle.FixedDialog
        Me.WindowState = FormWindowState.Normal
        Me.ControlBox = True
        Me.MinimizeBox = True
        Me.MaximizeBox = True

        ' Since there is no WindowState.Minimize, we have to P/Invoke ShowWindow
        ShowWindow(Me.Handle, SW_MINIMIZED)
    End Sub
   
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub

    Private Sub btnMinimize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMinimize.Click                'we use this as our close button
       
        Minimize()

    End Sub

End Class

Random Solutions  
 
programming4us programming4us