简体   繁体   English

最小化时控件的大小 (GetWindowPlacement)

[英]Size of controls when minimized (GetWindowPlacement)

It seems that GetWindowPlacement can only return the size of a minimized window .似乎 GetWindowPlacement 只能返回最小化window的大小。

Is it possible to get the size of the individual controls inside that window when the window is minimized?当 window 最小化时,是否可以获得 window内部各个控件的大小?

WINDOWPLACEMENT .rcNormalPosition is defined as: WINDOWPLACEMENT .rcNormalPosition 定义为:

The window's coordinates when the window is in the restored position.当 window 在恢复的 position 中时窗口的坐标。

To get the current size use the GetWindowRect function.要获取当前大小,请使用GetWindowRect function。 There is also an interesting article by Raymond Chen on this topic. Raymond Chen 也有一篇关于这个主题的有趣文章

The following program gives correct size of a control in a minimized window:以下程序给出了最小化 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真:-31948 -31335 -31923 -30761

What about GetWindowRect ? GetWindowRect呢? It gives you position and size.它为您提供 position 和尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM