473,806 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: How can I catch an event of minimize or maximize button pressin

hi,

Now, I'm creating window based applicaton.
In this application, I want to put some traps(code) before form minimizing
or maximizing event, but I only can get events after form minimized or
maximized.

I tried to test these 2 codes below:

1.
Form f = new Form();
f.SizeChanged += new EventHandler(Si zeChangedDelega te);

Result of this code is MessageBox showed after form minimized or maximized.
2.
Form f = new Form();
f.ResizeBegin += new EventHandler(Si zeChangedDelega te);
f.Resize += new EventHandler(Si zeChangedDelega te);
f.ResizeEnd += new EventHandler(Si zeChangedDelega te);

Result of this code is
a) ResizeBegin event did not handled while minimizing or maximizing.
b) Resize event handled after minimizing or maximizing.
c) ResizeEnd event did not handled while minimizing or maximizing.

NOTICE: delegate method of SizeChangedDele gate is like below for sample:
void SizeChangedDele gate(object sender, EventArgs args) {
MessageBox.Show ("Handling AdditionalDeleg ateOfSizeChange d");
}

Now, I do not know how to solve this, and also do not know possible or not.
I cannot find the answer in MSDN documentation.

Would someone help me, please?

Thanks,

Hide



Nov 17 '05 #1
2 11773
Hide,

In order to do this, you will have to override the WndProc method on
your Form class. In it, you would check the Msg property of the Message
parameter m passed into the method. If that value is 0x46, which
corresponds to the WM_WINDOWPOSCHA NGING message, then the form is being
maximized or minimized.

At that point, you will have to marshal the WINDOWPOS structure (it
should be defined on http://www.pinvoke.net) from the pointer in the lParam
property on the Message structure. Then, based on the cx and cy parameters,
you can tell if the window is maximizing or minimizing.

Make sure when you are done you call the base implementation of WndProc.

Unfortunately, there no more specific way (AFAIK) to indicate when a
window is minimizing or maximizing.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Hide" <Hi**@discussio ns.microsoft.co m> wrote in message
news:40******** *************** ***********@mic rosoft.com...
hi,

Now, I'm creating window based applicaton.
In this application, I want to put some traps(code) before form minimizing
or maximizing event, but I only can get events after form minimized or
maximized.

I tried to test these 2 codes below:

1.
Form f = new Form();
f.SizeChanged += new EventHandler(Si zeChangedDelega te);

Result of this code is MessageBox showed after form minimized or
maximized.
2.
Form f = new Form();
f.ResizeBegin += new EventHandler(Si zeChangedDelega te);
f.Resize += new EventHandler(Si zeChangedDelega te);
f.ResizeEnd += new EventHandler(Si zeChangedDelega te);

Result of this code is
a) ResizeBegin event did not handled while minimizing or maximizing.
b) Resize event handled after minimizing or maximizing.
c) ResizeEnd event did not handled while minimizing or maximizing.

NOTICE: delegate method of SizeChangedDele gate is like below for sample:
void SizeChangedDele gate(object sender, EventArgs args) {
MessageBox.Show ("Handling AdditionalDeleg ateOfSizeChange d");
}

Now, I do not know how to solve this, and also do not know possible or
not.
I cannot find the answer in MSDN documentation.

Would someone help me, please?

Thanks,

Hide


Nov 17 '05 #2
Hide,

In addition to what I said, if you are only interested in capturing when
the min/max button is pressed (or selected from the system menu), then you
can capture the WM_SYSCOMMAND message in the WndProc override, looking for
the SC_MINIMIZE or SC_MAXIMIZE commands. However, these are not going to be
passed to you when the WindowState property on the Form class is set to
Maximized.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Hide" <Hi**@discussio ns.microsoft.co m> wrote in message
news:40******** *************** ***********@mic rosoft.com...
hi,

Now, I'm creating window based applicaton.
In this application, I want to put some traps(code) before form minimizing
or maximizing event, but I only can get events after form minimized or
maximized.

I tried to test these 2 codes below:

1.
Form f = new Form();
f.SizeChanged += new EventHandler(Si zeChangedDelega te);

Result of this code is MessageBox showed after form minimized or
maximized.
2.
Form f = new Form();
f.ResizeBegin += new EventHandler(Si zeChangedDelega te);
f.Resize += new EventHandler(Si zeChangedDelega te);
f.ResizeEnd += new EventHandler(Si zeChangedDelega te);

Result of this code is
a) ResizeBegin event did not handled while minimizing or maximizing.
b) Resize event handled after minimizing or maximizing.
c) ResizeEnd event did not handled while minimizing or maximizing.

NOTICE: delegate method of SizeChangedDele gate is like below for sample:
void SizeChangedDele gate(object sender, EventArgs args) {
MessageBox.Show ("Handling AdditionalDeleg ateOfSizeChange d");
}

Now, I do not know how to solve this, and also do not know possible or
not.
I cannot find the answer in MSDN documentation.

Would someone help me, please?

Thanks,

Hide


Nov 17 '05 #3

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

Similar topics

1
29281
by: Prashant Joshi | last post by:
Hi all, I am using javascript to open a popup window. Is there any way we can disable the minimize button in this window? The maximize button is disabled. I want the same for the minimize button. Here is the javascript code that opens the window : child = window.open('NewWindow.aspx', null, 'width=850, height=450, directories=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, directories=no');
1
2901
by: Sumit | last post by:
Hi all, I have an MDI form in which i open some other forms. I dont want the Control Box (having minimize, restore/maximize and close button) Even though I have set the controlbox property of my child forms as false & the respective minimize & maximize box property to false, i get the control box with restore button as enabled (when i dock my child form in the MDI form with dockstyle as fill) which restores the
3
8395
by: Paul Welter | last post by:
I'm building a MDI application that has child forms. I'm trying to find a way to hide the inner boarder of the child frame area. Setting the FormBoarderStyle of the child form has no effect. Also, when the parent form's FormBoarderStyle is set to nothing, then the child form is maximized, I get the minimize and maximize buttons at the top of the parent from even though the boarder style is set to none for both forms. How do I prevent...
0
486
by: Bill | last post by:
Hi I have a parent child forms. I want the close, maximize, and minimize buttons to be removed. One the child form I have set the maximize and minimize buttons to false. I have the child form mamiximze in the parent form. So then the maximized button is still active. But I want the child form to fill the parent form without the ability to close minimize or maximize the form like a default page.
4
2680
by: iwdu15 | last post by:
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
4
3699
by: Linda | last post by:
My environment is Windows Server 2003, .NET Visual Studio Academic 2003, ASP.NET. I need to create a page with no top title bar, no mimize button, no maximize button, no close button. It is for a student exam system. I don't want students to be able to copy from other windows. I have put a close button on the page in order to close the page. I have been searching though the website, all I can do now is to diable the maximize button, the...
4
13461
by: EmilH | last post by:
Hi, Can anybody show me how to minimize/maximize a window dynamically? I placed buttons for each of these commands and want to place the code which will minimize and maximize the window. Thanks in advance. Emil.
5
2310
by: David Jackson | last post by:
Hello, I have a WinForms app (VS.NET 2005 + SP1) where the FormBorderStyle of the main form is set to FixedDialog. I've added a NotifyIcon, so have set the form's MinimizeBox property to true; This enables the form's minimize button, obviously, and the NotifyIcon stuff is working.
0
1258
by: clkurtz | last post by:
I'm working on an windows application, framework 2, language c#. I'm debugging on Windows Vista and XP. I need to have the button in the caption bar, but also minimize box and maximize box. The only way to have the button visible is to disable minimize and maximize box. Okay, this is by design, but this is not acceptable to me, so I need to find another solution. The idea is to put another button, a normal button called "buttonHelp"...
0
9598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10371
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.