H
H
h1_0ne2020-05-28 04:25:46
C++ / C#
h1_0ne, 2020-05-28 04:25:46

How to trigger native form animations when using BorderStyle None?

Good afternoon. I need to change the color of the form's top border, as I found out, the best way to do this is to set the BorderStyle property to None. I created the top panel, but when switching WindowState, minimization/maximization occurs abruptly, i.e. without animation. How to trigger or play this animation?
I also use the following code to move the form

public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();

private void MyTopPanel_MouseDown(object sender, MouseEventArgs e)
{
    ReleaseCapture();
    SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); 
}


If the application is in full screen mode (WindowState Maximize), then after trying to move it, it goes to normal, but if you move the form to the edges of the screen, it will not expand to full screen, as it would be with the default BorderStyle value. How to implement this feature?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-05-28
@SaNNy32

No relatives. This is what the operating system does. It will be difficult to implement such functionality on your own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question