我想每次啓動我的窗口形式,他設在屏幕的底部(任務欄上面)定位窗口形式
public void goBottomWindow(Form targetForm)
{
targetForm.WindowState = FormWindowState.Maximized;
targetForm.FormBorderStyle = FormBorderStyle.None;
targetForm.TopMost = true;
WinApi.SetWinFullScreen(targetForm.Handle);
}
public class WinApi
{
[DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
public static extern int GetSystemMetrics(int which);
[DllImport("user32.dll")]
public static extern void
SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
int X, int Y, int width, int height, uint flags);
private const int SM_CXSCREEN = 0;
private const int SM_CYSCREEN = 1;
private static IntPtr HWND_TOP = IntPtr.Zero;
private const int SWP_SHOWWINDOW = 64; // 0x0040
public static int ScreenX
{
get { return GetSystemMetrics(SM_CXSCREEN); }
}
public static int ScreenY
{
get {return 60;}
}
public static void SetWinFullScreen(IntPtr hwnd)
{
SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
}
}
使用此代碼,它離開我的窗口形式在屏幕上方....但我需要的是位於下方的窗體窗口。 有可能做到這一點?
對不起,我的英語很不好:(
你嘗試過'StartPostion'嗎? – chouaib 2015-02-12 01:13:02
是的,不起作用,爲什麼它也放置在下面的窗口窗體需要她佔據屏幕100%的寬度(它已經在運行)。 – JoaoFelipe 2015-02-12 01:14:39