我想每次启动我的窗口形式,他设在屏幕的底部(任务栏上面)定位窗口形式
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