oafc0000 Posted January 28, 2003 Posted January 28, 2003 Hi guys and girls How do you put code behind the Form Control Box minimise and maximise buttons. Basically I want to minimise the Form so it goes into the system tray but having to do it with a button at the moment coz I cant do it using the forms Control Box. Any suggestions? Thanks Quote
TechnoTone Posted January 28, 2003 Posted January 28, 2003 Haven't tried this in .NET but in VB6 I would use the forms Resize event and check the status of its WindowsState property. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Experts* Nerseus Posted January 28, 2003 *Experts* Posted January 28, 2003 (edited) Yep - still the Resize event. You want the form's WindowState property, as in: private void Form1_Resize(object sender, System.EventArgs e) { if(this.WindowState==FormWindowState.Minimized) { // Do your custom minimize to tray Debug.WriteLine("min"); } } [edit]fixed code tags to use the [cs] [/cs] tags[/edit] -Nerseus Edited January 29, 2003 by John Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
indyapel Posted April 5, 2003 Posted April 5, 2003 try Inherits System.Windows.Forms.Form use Resize as Boolean = False with ResizeRedraw method Quote
solus Posted April 5, 2003 Posted April 5, 2003 Hey guys, I've been fighting with minimizing to the tray for a bit, here's what I've got: this.TrayIcon = new System.Windows.Forms.NotifyIcon(this.components); this.TrayIcon.ContextMenu = this.TrayMenu; this.TrayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("TrayIcon.Icon"))); this.TrayIcon.Text = "Remote File Manager"; this.TrayIcon.Visible = true; Now, when I minimize the application, it shows up on the botton left corner of the desktop: http://www.weblocke.net/rfm/example.png How can I get rid of that? Thanks for reading ^.^ Quote Can't afford to be neutral on a moving train...
wyrd Posted April 5, 2003 Posted April 5, 2003 (edited) I've never done Tray Icons before.. so this is just a shot in the dark. :) Would setting the form to visible = false work? edit; Browsing about (curious about Tray Icons now..) I found this; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp06102002.asp scroll down to the bottom... The first two steps to do this are easy. You set the ShowInTaskbar property to false and the WindowState to minimized, and the window vanishes. That's not the whole story, however, as you can still get to the window using the ALT+TAB key combination. After a few Google searches, I came across the code to fix this problem. You need to tell the window that it's a tool window, and then it isn't put into that list. I did that with a bit of code that calls out to the Win32® SendMessage() API. When I was writing this up, I was complaining to a co-worker that I had to do this to make the window disappear. We did some more searching and found that one of the border styles you can set for a form is FixedToolWindow. I used that code instead of my SendMessage() code, and the window was gone. I thought that was the solution, but it turns out that if you bring up another window in the application, the main window will reappear. However, the main window won't show up again if you use the SendMessage() solution, so that's what I've kept. If you aren't going to bring up other windows, setting the border style should work fine. Edited April 5, 2003 by wyrd Quote Gamer extraordinaire. Programmer wannabe.
solus Posted April 5, 2003 Posted April 5, 2003 Turning it to FixedToolWindow didn't work and I can't seem to find any of this code for SendMessage() to use as an example. You can't be serious in telling me something so seemingly simple is such a difficult feat for a programming language like c# =p Quote Can't afford to be neutral on a moving train...
solus Posted April 5, 2003 Posted April 5, 2003 Okay, so maybe it was fairly easy. And the visible thing did work. I thought it was only available for form items, not the form itself. this.Visible = false; Quote Can't afford to be neutral on a moving train...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.