Terry Olsen wrote:[color=blue]
> I want to minimize my program to the tray when minimized. But
> there's no "minimize" event. So how can I catch this event and use
> it?[/color]
You have to override WndProc:
Const WM_SYSCOMMAND As Int32 = &H112
Const SC_MINIMIZE As Int32 = &HF020
Const SC_RESTORE As Int32 = &HF120
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
If m.WParam.ToInt3 2 = SC_MINIMIZE Then
'User clicked "minimize"
Debug.WriteLine ("Minimizing... ")
ElseIf m.WParam.ToInt3 2 = SC_RESTORE Then
'Restoring
Debug.WriteLine ("Restoring..." )
End If
End If
MyBase.WndProc( m)
End Sub
Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
MyBase.OnResize (e)
Select Case Me.WindowState
Case FormWindowState .Normal
MessageBox.Show ("Form was restored",
Application.Pro ductName)
Case FormWindowState .Minimized
MessageBox.Show ("Form was minimized",
Application.Pro ductName)
Case FormWindowState .Maximized
MessageBox.Show ("Form was maximized",
Application.Pro ductName)
End Select
End Sub
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Terry Olsen" <tolsen64@hotma il.com> wrote in message
news:uR8aLZZ6FH A.2576@TK2MSFTN GP09.phx.gbl...
|I want to minimize my program to the tray when minimized. But there's no
| "minimize" event. So how can I catch this event and use it?
|
|
Jay B. Harlow [MVP - Outlook] wrote:[color=blue]
> I normally simply handle the Resize event.
>
> Something like:
>
> Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
> MyBase.OnResize (e)
> Select Case Me.WindowState
> Case FormWindowState .Normal
> MessageBox.Show ("Form was restored",
> Application.Pro ductName)[/color]
"Arne Janning" <spam.me-here.iasyncresu lt@gmail.com> schrieb:[color=blue][color=green]
>> I normally simply handle the Resize event.
>>
>> Something like:
>>
>> Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
>> MyBase.OnResize (e)
>> Select Case Me.WindowState
>> Case FormWindowState .Normal
>> MessageBox.Show ("Form was restored",
>> Application.Pro ductName)[/color]
>
> What happens if the user really resizes the form?[/color]
A messagebox is shown and resizing stops... In .NET 2.0 forms have
additional 'ResizeBegin' and 'ResizeEnd' events.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried K. Wagner [MVP] wrote:[color=blue][color=green][color=darkred]
>>> Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
>>> MyBase.OnResize (e)
>>> Select Case Me.WindowState
>>> Case FormWindowState .Normal
>>> MessageBox.Show ("Form was restored",
>>> Application.Pro ductName)[/color]
>>
>> What happens if the user really resizes the form?[/color]
>
> A messagebox is shown and resizing stops...[/color]
Agreed.
[color=blue]
> In .NET 2.0 forms have
> additional 'ResizeBegin' and 'ResizeEnd' events.[/color]
So now you can decide whether you want to show that "Restoring"-MessageBox
at the beginning or the end of resizing ;-)
Arne,
(I thought I sent this last night, if this is a double post)
The window state will continue to be Normal.
If you prefer:
| > Case FormWindowState .Normal
| > MessageBox.Show ("Form was restored or resized",
| > Application.Pro ductName)
;-)
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Arne Janning" <spam.me-here.iasyncresu lt@gmail.com> wrote in message
news:%23L4CvEa6 FHA.2576@TK2MSF TNGP09.phx.gbl. ..
| Hi Jay!
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > I normally simply handle the Resize event.
| >
| > Something like:
| >
| > Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
| > MyBase.OnResize (e)
| > Select Case Me.WindowState
| > Case FormWindowState .Normal
| > MessageBox.Show ("Form was restored",
| > Application.Pro ductName)
|
| What happens if the user really resizes the form?
|
| Cheers
|
| Arne Janning
|
|
Herfried,
I would have expected Resizing & Resized events, so as to comply with the
"Framework Design Guidelines", although ResizeBegin & ResizeEnd sound
slightly better...
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:uUy3AJg6FH A.3876@TK2MSFTN GP09.phx.gbl...
| "Arne Janning" <spam.me-here.iasyncresu lt@gmail.com> schrieb:
| >> I normally simply handle the Resize event.
| >>
| >> Something like:
| >>
| >> Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
| >> MyBase.OnResize (e)
| >> Select Case Me.WindowState
| >> Case FormWindowState .Normal
| >> MessageBox.Show ("Form was restored",
| >> Application.Pro ductName)
| >
| > What happens if the user really resizes the form?
|
| A messagebox is shown and resizing stops... In .NET 2.0 forms have
| additional 'ResizeBegin' and 'ResizeEnd' events.
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
Comment