Size of controls when minimized (GetWindowPlacement)
It seems that GetWindowPlacement can only return the size of a minimized window.
Is it possible to get the size of the individual controls inside that window when the win开发者_如何学Pythondow is minimized?
WINDOWPLACEMENT.rcNormalPosition is defined as:
The window's coordinates when the window is in the restored position.
To get the current size use the GetWindowRect function. There is also an interesting article by Raymond Chen on this topic.
The following program gives correct size of a control in a minimized window:
using System.Runtime.InteropServices;
using System;
[StructLayout(LayoutKind.Sequential)]
struct RECT
{
public int L;
public int T;
public int R;
public int B;
}
static class Program
{
void Main()
{
RECT r;
bool result = GetWindowRect(0x00120E34, out r);
Console.WriteLine("{0}: {1} {2} {3} {4}", r.T, r.L, r.B, r.R);
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
extern bool GetWindowRect(int hwnd, out RECT lpRect);
}
True: -31948 -31335 -31923 -30761
What about GetWindowRect? It gives you position and size.
精彩评论