本文整理汇总了C#中WINDOWPLACEMENT类的典型用法代码示例。如果您正苦于以下问题:C# WINDOWPLACEMENT类的具体用法?C# WINDOWPLACEMENT怎么用?C# WINDOWPLACEMENT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WINDOWPLACEMENT类属于命名空间,在下文中一共展示了WINDOWPLACEMENT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: load
public void load()
{
Debug.Print("" + ht.Values.Count);
foreach (DictionaryEntry de in ht)
{
try
{
IntPtr hWnd = (IntPtr)de.Key;
if (IsWindowVisible(hWnd) == 0) continue;
WINDOWPLACEMENT wp = (WINDOWPLACEMENT)de.Value;
SetWindowPlacement(hWnd, ref wp);
Debug.Print("" + wp.showCmd);
if (wp.showCmd == 1)
{
WINDOWPLACEMENT wp2 = new WINDOWPLACEMENT();
GetWindowPlacement(hWnd, ref wp2);
if (wp2.rcNormalPosition.left == wp.rcNormalPosition.left)
{
RECT r = wp.rcNormalPosition;
MoveWindow(hWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, 1);
}
}
}
catch
{
}
}
}
示例2: GetVisible
public static bool GetVisible()
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
GetWindowPlacement(Process.GetCurrentProcess().MainWindowHandle, ref placement);
return placement.showCmd != SW_HIDE;
}
示例3: GetMinimized
public static bool GetMinimized()
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
GetWindowPlacement(Process.GetCurrentProcess().MainWindowHandle, ref placement);
return placement.showCmd == SW_SHOWMINIMIZED;
}
示例4: GetWindowPlacement
public static WINDOWPLACEMENT GetWindowPlacement(IntPtr handle)
{
WINDOWPLACEMENT windowPlacement = new WINDOWPLACEMENT();
if (!GetWindowPlacement(handle, ref windowPlacement))
throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
return windowPlacement;
}
示例5: save
public void save()
{
EnumWindows(new EnumWindowsDelegate(delegate(IntPtr hWnd, int lParam)
{
StringBuilder sb = new StringBuilder(0x1024);
if (IsWindowVisible(hWnd) != 0 && GetWindowText(hWnd, sb, sb.Capacity) != 0)
{
try
{
string title = sb.ToString();
int pid;
GetWindowThreadProcessId(hWnd, out pid);
Process p = Process.GetProcessById(pid);
WINDOWPLACEMENT wndpl = new WINDOWPLACEMENT();
wndpl.Length = Marshal.SizeOf(wndpl);
GetWindowPlacement(hWnd, ref wndpl);
ht[hWnd] = wndpl;
}
catch
{
}
}
return 1;
}), 0);
}
示例6: GetWindowPlacement
public static WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
GetWindowPlacement(hwnd, ref placement);
return placement;
}
示例7: FormObject_FormClosed
//save the placement...
private void FormObject_FormClosed(object sender, FormClosedEventArgs e)
{
//save placement.
//all the "tough work" is handled above, and by the INIDataItem Extension methods. Here we
//can simply use SetValue<> and set the value. Nice and clean.
WINDOWPLACEMENT grabplacement = new WINDOWPLACEMENT();
GetWindowPlacement(FormObject.Handle, ref grabplacement);
Configuration[usesectionName][FormObject.Name].SetValue(grabplacement);
}
示例8: isWindowMinimized
public static bool isWindowMinimized(IntPtr hWnd)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
var result = GetWindowPlacement(hWnd, ref placement);
if (result)
{
return placement.showCmd == SW_SHOWMINIMIZED;
}
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not get window placement");
}
示例9: ActivateInternet
/// <summary>
/// Переключается в браузер:
/// </summary>
private static void ActivateInternet()
{
//System.Threading.Thread.Sleep(3000);
IntPtr handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Chrome_WidgetWin_1", null);
//IntPtr hide_handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Chrome_WidgetWin_1", null);
//System.Threading.Thread.Sleep(5000);
if (handle != IntPtr.Zero)
{
//System.Threading.Thread.Sleep(1000);
IntPtr current_active = GetForegroundWindow();
handle = FindWindowEx(IntPtr.Zero, handle, "Chrome_WidgetWin_1", null);
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.Length = Marshal.SizeOf(placement);
GetWindowPlacement((IntPtr)handle, out placement);
if (placement.ShowCmd == 3 || placement.ShowCmd == 1)//maximized || normal
{
ShowWindow((IntPtr)handle, Constants.SW_MINIMIZE);
//UpdateWindow((IntPtr)handle);
return;
}
//if (current_active != handle)
else if (placement.ShowCmd == 2)//minimized
{
//handle = FindWindowEx(IntPtr.Zero, handle, "Chrome_WidgetWin_1", null);
ShowWindow((IntPtr)handle, Constants.SW_SHOW);
ShowWindow((IntPtr)handle, Constants.SW_MAXIMIZE);
UpdateWindow((IntPtr)handle);
SetActiveWindow((IntPtr)handle);
SetFocus((IntPtr)handle);
//SetWindowPos((IntPtr)handle, (IntPtr)Constants.HWND_TOP, 0, 0, 0, 0, Constants.SWP_NOMOVE | Constants.SWP_NOSIZE | Constants.SWP_FRAMECHANGED);
SetForegroundWindow(handle);
return;
}
else if (false)//normal
{
SetForegroundWindow(handle);
//handle = FindWindowEx(IntPtr.Zero, handle, "Chrome_WidgetWin_1", null);
ShowWindow((IntPtr)handle, Constants.SW_MINIMIZE);
//ShowWindow((IntPtr)handle, Constants.SW_HIDE);
//ShowWindow((IntPtr)handle, Constants.SW_RESTORE);
//UpdateWindow((IntPtr)handle);
return;
}
}
else
{
Process.Start("chrome.exe", "www.yandex.ru");
System.Threading.Thread.Sleep(1000);
}
//System.Threading.Thread.Sleep(1000);
}
示例10: GetPlacement
public static Point GetPlacement(IntPtr handle)
{
var placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
if (GetWindowPlacement(handle, ref placement))
{
var location = placement.rcNormalPosition;
return new Point(location.X + location.Width/2, location.Y + location.Height / 2);
}
Logger.Write("placement not found.");
return new Point(0, 0);
}
示例11: FocusWindow
public static void FocusWindow(IntPtr hwnd)
{
try
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
if (GetWindowPlacement(hwnd, ref placement))
{
if (placement.showCmd == ShowCmds.Minimized)
NativeMethods.ShowWindow(hwnd, NativeMethods.SW_RESTORE);
SetForegroundWindow(hwnd);
}
}
catch
{ }
}
示例12: Restore
public static void Restore(Window window, XElement xml)
{
var placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
placement.flags = 0;
placement.showCmd = (int)xml.Element(ShowCommandElementName);
placement.ptMinPosition.x = (int)xml.Element(MinPositionElementName).Attribute(XAttributeName);
placement.ptMinPosition.y = (int)xml.Element(MinPositionElementName).Attribute(YAttributeName);
placement.ptMaxPosition.x = (int)xml.Element(MaxPositionElementName).Attribute(XAttributeName);
placement.ptMaxPosition.y = (int)xml.Element(MaxPositionElementName).Attribute(YAttributeName);
placement.rcNormalPosition.left = (int)xml.Element(NormalPositionElementName).Attribute(LeftAttributeName);
placement.rcNormalPosition.top = (int)xml.Element(NormalPositionElementName).Attribute(TopAttributeName);
placement.rcNormalPosition.right = (int)xml.Element(NormalPositionElementName).Attribute(RightAttributeName);
placement.rcNormalPosition.bottom = (int)xml.Element(NormalPositionElementName).Attribute(BottomAttributeName);
var windowInteropHelper = new WindowInteropHelper(window);
SetWindowPlacement(windowInteropHelper.Handle, ref placement);
}
示例13: Save
public static XElement Save(Window window)
{
var windowInteropHelper = new WindowInteropHelper(window);
var placement = new WINDOWPLACEMENT();
GetWindowPlacement(windowInteropHelper.Handle, out placement);
return
new XElement(WindowPlacementElementName,
new XElement(ShowCommandElementName, (placement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : placement.showCmd)),
new XElement(MinPositionElementName,
new XAttribute(XAttributeName, placement.ptMinPosition.x),
new XAttribute(YAttributeName, placement.ptMinPosition.y)),
new XElement(MaxPositionElementName,
new XAttribute(XAttributeName, placement.ptMaxPosition.x),
new XAttribute(YAttributeName, placement.ptMaxPosition.y)),
new XElement(NormalPositionElementName,
new XAttribute(LeftAttributeName, placement.rcNormalPosition.left),
new XAttribute(TopAttributeName, placement.rcNormalPosition.top),
new XAttribute(RightAttributeName, placement.rcNormalPosition.right),
new XAttribute(BottomAttributeName, placement.rcNormalPosition.bottom)));
}
示例14: FormObject_Load
//Load event: load the form placement, if present, from the INI file we were given in our constructor.
private void FormObject_Load(object sender, EventArgs e)
{
WINDOWPLACEMENT currplacement = new WINDOWPLACEMENT();
GetWindowPlacement(FormObject.Handle, ref currplacement);
//default is wherever it is now if there is a parse problem.
WINDOWPLACEMENT getplacement =
Configuration[usesectionName][FormObject.Name].GetValue(currplacement);
//check for previous instances, and offset if there are.
String thisproc = Process.GetCurrentProcess().ProcessName;
Process[] existing = Process.GetProcessesByName(thisproc);
if (existing.Length > 1)
{
//more than one, so offset...
OffsetRect(ref getplacement.rcNormalPosition, 16*existing.Length, 16*existing.Length);
}
SetWindowPlacement(FormObject.Handle, ref getplacement);
//load placement...
}
示例15: GetWindowPlacement
private static extern bool GetWindowPlacement(
IntPtr hWnd,
ref WINDOWPLACEMENT lpwndpl);