當我用Google搜索找到改變窗口的風格我能找到「C」的代碼語言 我怎麼能在我的C#應用程序中使用下面的代碼片段的方式,這樣我可以隱藏標題外部應用程序?我沒有用「C」之前..用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));
}
你想改變一個窗口的風格? - 這是你的應用程序還是所有窗口? Winforms,ASP,WPF? 我注意到,這是一樣的,你有另一篇文章。 – ChrisBD 2010-05-14 06:31:40
@ChrisBD,我想隱藏的應用[第三方]它只有一個窗體的標題欄。而這個應用程序是由我的C#窗口應用程序啓動的。它不適用於所有窗口。 – Anuya 2010-05-14 06:35:14