473,494 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Capturing onMinimize event?

Jim
Hi,

I intend to set the form Visibility to false and show a taskbar icon
instead. I've done this on the FormClosing event but I want this to
happen when the form is minized too.

How do I capture this event?

Thanks in advance,
Mikhail
Nov 16 '05 #1
6 7914
On Wed, 07 Apr 2004 17:11:39 +0530, Jim wrote:
I intend to set the form Visibility to false and show a taskbar icon
instead. I've done this on the FormClosing event but I want this to
happen when the form is minized too.


declare the following somewhere in your form:

public event EventHandler Minimize;

and inside the constructor of your form, attach an event handler:

this.Minimize += new EventHandler(this.Form1_Minimize);

and finally, copy/paste this method to your form:

protected override void WndProc(ref Message msg) {
const int WM_SIZE = 0x0005;
const int SIZE_MINIMIZED = 1;

if ((msg.Msg == WM_SIZE) && ((int) msg.WParam == SIZE_MINIMIZED) &&
(this.Minimize != null)) {
this.Minimize(this, EventArgs.Empty);
}

base.WndProc(ref msg);
}

--
Asbjørn Ulsberg -=|=- as******@hotmail.com
"He's a loathsome offensive brute, yet I can't look away"
Nov 16 '05 #2
Jim
Works beautifully!

Thanks :-)

Asbjørn Ulsberg wrote:
On Wed, 07 Apr 2004 17:11:39 +0530, Jim wrote:
I intend to set the form Visibility to false and show a taskbar icon
instead. I've done this on the FormClosing event but I want this to
happen when the form is minized too.

declare the following somewhere in your form:

public event EventHandler Minimize;

and inside the constructor of your form, attach an event handler:

this.Minimize += new EventHandler(this.Form1_Minimize);

and finally, copy/paste this method to your form:

protected override void WndProc(ref Message msg) {
const int WM_SIZE = 0x0005;
const int SIZE_MINIMIZED = 1;

if ((msg.Msg == WM_SIZE) && ((int) msg.WParam == SIZE_MINIMIZED) &&
(this.Minimize != null)) {
this.Minimize(this, EventArgs.Empty);
}

base.WndProc(ref msg);
}

Nov 16 '05 #3
Hi,

Don't You know where i can search for integer representation
of Window messages and WParams?

Marcin
On Wed, 07 Apr 2004 17:11:39 +0530, Jim wrote:
I intend to set the form Visibility to false and show a taskbar icon
instead. I've done this on the FormClosing event but I want this to
happen when the form is minized too.

declare the following somewhere in your form:

public event EventHandler Minimize;

and inside the constructor of your form, attach an event handler:

this.Minimize += new EventHandler(this.Form1_Minimize);

and finally, copy/paste this method to your form:

protected override void WndProc(ref Message msg) {
const int WM_SIZE = 0x0005;
const int SIZE_MINIMIZED = 1;

if ((msg.Msg == WM_SIZE) && ((int) msg.WParam == SIZE_MINIMIZED) &&
(this.Minimize != null)) {
this.Minimize(this, EventArgs.Empty);
}

base.WndProc(ref msg);
}


Nov 16 '05 #4
On Wed, 07 Apr 2004 15:02:38 +0200, Marcin Grzębski wrote:
Don't You know where i can search for integer representation
of Window messages and WParams?


No, sorry. I found the example on The Code Project or something.

--
Asbjørn Ulsberg -=|=- as******@hotmail.com
"He's a loathsome offensive brute, yet I can't look away"
Nov 16 '05 #5
Actually, when the form is minimized a Form.Resize event is fired...
You can then check the WindowState property wether the form is
minimized in the event handler...
this.Resize += new EventHandler(HideForm);
[code:1:ba4f873ece]
void HideForm(object sender, EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
{
// put your code here...
}
}
[/code:1:ba4f873ece]

read more about the FormWindowState enumeration here...

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsFormWindowStateClassTopic.a sp?frame=true

Nov 16 '05 #6
Actually, when the form is minimized a Form.Resize event is fired...
You can then check the WindowState property wether the form is
minimized in the event handler...
this.Resize += new EventHandler(HideForm);
[code:1:ba4f873ece]
void HideForm(object sender, EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
{
// put your code here...
}
}
[/code:1:ba4f873ece]

read more about the FormWindowState enumeration here...

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsFormWindowStateClassTopic.a sp?frame=true

Nov 16 '05 #7

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

Similar topics

0
1345
by: Joecx | last post by:
I am capturing the click event using Overrides OnClick. This captures the click event in the open or unused areas of the form, but it doesn't capture the click event in the textboxes etc. Do I...
3
4940
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
3
1364
by: Jim | last post by:
Hi, I intend to set the form Visibility to false and show a taskbar icon instead. I've done this on the FormClosing event but I want this to happen when the form is minized too. How do I...
10
5995
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
5
4712
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.