473,385 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

catch minimization

hi, how can i catch when the user clicks the minimize button on the form and
do a certain event then? what im looking to do is when the user minimizes the
form, to put the form on the system tray. i kno how to put it on the tray but
how do i catch when its been minimized? thanks
--
-iwdu15
Nov 21 '05 #1
4 2653
jdm
=?Utf-8?B?aXdkdTE1?= <iw****@discussions.microsoft.com> wrote in
news:B3**********************************@microsof t.com:
hi, how can i catch when the user clicks the minimize button on the
form and do a certain event then? what im looking to do is when the
user minimizes the form, to put the form on the system tray. i kno how
to put it on the tray but how do i catch when its been minimized?
thanks


there's an example here
http://www.visualbasicforum.com/showthread.php?t=241017

:

Protected Overrides Sub WndProc(ByRef m As _
System.Windows.Forms.Message)
Const WM_SYSCOMMAND As Long = &H112
Const SC_MINIMIZE As Long = &HF020&
Const SC_MAXIMIZE As Long = &HF030&
' See if this is WM_SYSCOMMAND.
If m.Msg = WM_SYSCOMMAND Then
' Ignore SC_MINIMIZE and SC_MAXIMIZE commands.
If (m.WParam.ToInt32 And &HFFF0&) = SC_MINIMIZE Then
MsgBox("Can't Minimize!!")
Exit Sub
End If
If (m.WParam.ToInt32 And &HFFF0&) = SC_MAXIMIZE Then
MsgBox("Can't Maximize!!")
Exit Sub
End If
End If
MyBase.WndProc(m)
End Sub
Nov 21 '05 #2
awsome thanks
Nov 21 '05 #3
"jdm" <nu**@invalid.com> schrieb:
Protected Overrides Sub WndProc(ByRef m As _
System.Windows.Forms.Message)
Const WM_SYSCOMMAND As Long = &H112
Const SC_MINIMIZE As Long = &HF020&
Const SC_MAXIMIZE As Long = &HF030&


Note that 'Long' is a 64-bit datatype in VB.NET. Thus you'll have to change
the longs to ints:

\\\
Private Const WM_SYSCOMMAND As Int32 = &H112

Private Const SC_MAXIMIZE As Int32 = &HF030
Private Const SC_MINIMIZE As Int32 = &HF020
Private Const SC_RESTORE As Int32 = &HF120
Private Const SC_CLOSE As Int32 = &HF060

Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
Select Case m.WParam.ToInt32()
Case SC_MAXIMIZE
Debug.WriteLine("Form gets maximized.")
Case SC_MINIMIZE
Debug.WriteLine("Form gets minimized.")
Case SC_RESTORE
Debug.WriteLine("Form gets restored.")
Case SC_CLOSE
Debug.WriteLine("Form gets closed.")
End Select
End If
MyBase.WndProc(m)
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
iwdu15,
In addition to the other comments.

I normally simply handle the Resize event.

Something like:

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)
Select Case Me.WindowState
Case FormWindowState.Normal
MessageBox.Show("Form was restored",
Application.ProductName)
Case FormWindowState.Minimized
MessageBox.Show("Form was minimized",
Application.ProductName)
Case FormWindowState.Maximized
MessageBox.Show("Form was maximized",
Application.ProductName)
End Select
End Sub
--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
| hi, how can i catch when the user clicks the minimize button on the form
and
| do a certain event then? what im looking to do is when the user minimizes
the
| form, to put the form on the system tray. i kno how to put it on the tray
but
| how do i catch when its been minimized? thanks
| --
| -iwdu15
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
6
by: laniik | last post by:
hi. does anyone know if there is a good/free/popular c++ library for nonlinear conjugate gradient minimization? i.e. somthing that takes a f(x)=y and minimize for x. i also need it to be able...
4
by: Abhishek Srivastava | last post by:
Hello All, I have seen code snippets like try { ..... } catch {
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
3
by: markscala | last post by:
Is anyone aware of python library that does function minimization a la Minuit (http://wwwasdoc.web.cern.ch/wwwasdoc/minuit/) used by CERN? thanks
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.