-2

Before starting the question, I apologize for not using English well.


I don't want to use Border and Minimized/Maximized/Closed buttons in the existing form.

FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

Then, I created Custom Minimized/Maximized/Closed Button.


        //Closed
        private void imgLblCloseProgram_Click(object sender, EventArgs e) {
            this.Close();
        }
        //Maximized
        private void imgLblMaximumProgram_Click(object sender, EventArgs e) {
            if(this.WindowState == FormWindowState.Maximized) {
                this.WindowState = FormWindowState.Normal;
            } else if(this.WindowState == FormWindowState.Normal) {
                //this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;   //★★★
                this.WindowState = FormWindowState.Maximized;                           //
            }
        }
        private void tbPnlTopBar_DoubleClick(object sender, EventArgs e) {
            imgLblMaximumProgram_Click(imgLblMaximumProgram, e);
        }
        //Minimized
        private void imgLblMinimumProgram_Click(object sender, EventArgs e) {
            this.WindowState = FormWindowState.Minimized;                               //
        }

When Clear the annotation, Maximizes without taking up space on the taskbar.
However, if more than one monitors are used, they do not work on screens other than the main screen.

In addition, for the Maximized/Minimized button, there seems to be a built-in animation provided by Windows.
When the Maximized/Minimized was changed via FormWindowState, I confirmed that the animation did not work.


The biggest reason why I want the Low-cost Maximized Button Event is that when I use more than one monitors, I have a issue.
Therefore, I need a way to maximize the form while displaying TaskBar on two or more monitors.

p.s. I want the animation of the maximized/minimized button as well, so the best way to run the maximized/minimized button's event is.

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
  • If I understand you correctly, you don't want to cover the taskbar when the form is maximized, correct? If so, use `this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;`. – 41686d6564 stands w. Palestine Apr 21 '21 at 01:37
  • As to your second question, see [this post](https://stackoverflow.com/q/31473489/8967612) (please be aware that you should ask one question per post though). – 41686d6564 stands w. Palestine Apr 21 '21 at 01:55
  • **when I use more than one monitors, I have a issue(they do not work on screens other than the main screen).** @41686d6564 – user15570679 Apr 21 '21 at 04:16
  • In the case of animation, the Border of Sizable is visible in a short moment when the FormStyle has changed. – user15570679 Apr 21 '21 at 04:17
  • The reason why anime disappears has become clear. The border itself contains animation when maximizing/minimizing changes. Thus, under FormBorderStyle == None, the animation effect may well disappear. – user15570679 Jun 29 '21 at 02:48

1 Answers1

0

I solved this.
when I use more than one monitors, I have a issue(they do not work on screens other than the main screen).

If you still want to use FormWindowState.Maximized on more than one monitor, this is likely to be an appropriate solution.

this.MaximizedBounds = new Rectangle(new Point(Screen.PrimaryScreen.WorkingArea.X, Screen.PrimaryScreen.WorkingArea.Y), new Size(Screen.FromHandle(this.Handle).WorkingArea.Width, Screen.FromHandle(this.Handle).WorkingArea.Height));
            

However, there is an error on the screen with higher resolution than the main monitor.