S
Scott Abel
Hello,
I am trying to create a new form class that has a new property
LastWindowState. I need this in my MDI app because I have a non-modal child
form that I only want opened once. If the user selects the option from the
menu I want to restore the form to its last known state, if it is minimized.
To do that I need a new property etc. Anyway, I have been able to capture
the min/max/restore by overriding the WndProc() method and looking for
message WM_SYSCOMMAND and looking at the value for WParam to see if it is
SC_MINIMIZE, SC_MAXIMIXE, or SC_RESTORE. All works ok. Here is the issue
though.
When other programmers use this class they might use the WindowState
property to change the window state. The WndProc() does not capture those
messages and the LastWindowState is left in a confused state
What is the message, wparam, and lParam I could use in WndProc() to grab the
current window state before passing to the message on to base.WndProc()?
I have tried overriding the WindowState with the following code but got an
error when compiling saying:
cannot override inherited member 'System.Windows.Forms.Form.WindowState.get'
because it is not marked virtual, abstract, or override
public override FormWindowState WindowState
{
get
{
WindowState = base.WindowState;
}
set
{
MessageBox.Show("Current Window State = " +
this.WindowState);
base.WindowState = value;
}
}
I have tried using protected keyword but I get a different message saying I
can't change access modifiers when overriding a public member.
Any Ideas?
Thanks
Scott
I am trying to create a new form class that has a new property
LastWindowState. I need this in my MDI app because I have a non-modal child
form that I only want opened once. If the user selects the option from the
menu I want to restore the form to its last known state, if it is minimized.
To do that I need a new property etc. Anyway, I have been able to capture
the min/max/restore by overriding the WndProc() method and looking for
message WM_SYSCOMMAND and looking at the value for WParam to see if it is
SC_MINIMIZE, SC_MAXIMIXE, or SC_RESTORE. All works ok. Here is the issue
though.
When other programmers use this class they might use the WindowState
property to change the window state. The WndProc() does not capture those
messages and the LastWindowState is left in a confused state
What is the message, wparam, and lParam I could use in WndProc() to grab the
current window state before passing to the message on to base.WndProc()?
I have tried overriding the WindowState with the following code but got an
error when compiling saying:
cannot override inherited member 'System.Windows.Forms.Form.WindowState.get'
because it is not marked virtual, abstract, or override
public override FormWindowState WindowState
{
get
{
WindowState = base.WindowState;
}
set
{
MessageBox.Show("Current Window State = " +
this.WindowState);
base.WindowState = value;
}
}
I have tried using protected keyword but I get a different message saying I
can't change access modifiers when overriding a public member.
Any Ideas?
Thanks
Scott