Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hai all..

I am facing one problem. I want to Prevent minimizing Border less form while clicking show desktop button or Win+D, Win+M

I searched google.. and got one same qustion..

Link[^]

In Delphi

I Got this:

SQL
procedure TForm1.WMShowWindow(var Msg: TWMShowWindow);
begin
  if not Msg.Show then
    Msg.Result := 0
  else
    inherited;
end;


But need the same in C#

I tried this code..

C#
protected override void DefWndProc(ref Message m)
{
    if (this.WindowState == FormWindowState.Minimized)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }
    this.Activate();
    this.Focus();

    base.DefWndProc(ref m);
}


but my form is always in top..

I tried

this.SendToBack();

this.TopLevel=false;


but it didn't helped me..

How can I solve this..?


Please help me..?
Posted
Updated 28-Sep-11 19:07pm
v4
Comments
André Kraak 28-Sep-11 3:11am    
Why would you want to change standard Windows behaviour? What is so special about your program that it should always be visible even when the user decides otherwise.
version_2.0 28-Sep-11 3:18am    
I wish to give such type of behavior to my form.. If you know the answer please help me..

1 solution

I agree with the comment above regarding changing standard Windows behavior. This is something you shouldn't do without a very good reason.

That said, you should be able to override this behavior by handling the window's resize event. If the window's state is minimized, change it to normal (I believe that's the name of the state, but you can figure it out).
 
Share this answer
 
Comments
version_2.0 29-Sep-11 0:30am    
My Application need this kind of behavior.. Handling windows resize event didn't helped me.. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900