Lorsque j'ai recherché sur Google comment changer le style de la fenêtre, je pouvais trouver le code en langage "C" Comment puis-je utiliser l'extrait ci-dessous dans mon application C#, pour cacher le titre Barre d'application externe? Je ne l'ai pas utilisé « C » avant ..Utilisation du code C dans C#
//Finds a window by class name
[DllImport("USER32.DLL")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//Sets a window to be a child window of another window
[DllImport("USER32.DLL")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
//Sets window attributes
[DllImport("USER32.DLL")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
//Gets window attributes
[DllImport("USER32.DLL")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
//assorted constants needed
public static int GWL_STYLE = -16;
public static int WS_CHILD = 0x40000000; //child window
public static int WS_BORDER = 0x00800000; //window with border
public static int WS_DLGFRAME = 0x00400000; //window with double border but no title
public static int WS_CAPTION= WS_BORDER | WS_DLGFRAME; //window with a title bar
/*
This function sets the parent of the window with class
ClassClass to the form/control the method is in.
*/
public void Reparent()
{
//get handle of parent form (.net property)
IntPtr par = this.Handle;
//get handle of child form (win32)
IntPtr child = FindWindow("ClassClass", null);
//set parent of child form
SetParent(child, par);
//get current window style of child form
int style = GetWindowLong(child, GWL_STYLE);
//take current window style and remove WS_CAPTION from it
SetWindowLong(child, GWL_STYLE, (style & ~WS_CAPTION));
}
Vous voulez changer un style de fenêtres? - est-ce pour votre application ou toutes les fenêtres? Winforms, ASP, WPF? Je remarque que c'est la même chose qu'un autre post que vous avez. – ChrisBD
@ChrisBD, je veux cacher la barre de titre d'une application [Third party] qui n'a qu'un seul formulaire. Et cette application est démarrée par mon application C# windows. Ce n'est pas pour toutes les fenêtres. – Anuya