簡體   English   中英

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

[英]Size of controls when minimized (GetWindowPlacement)

似乎 GetWindowPlacement 只能返回最小化window的大小。

當 window 最小化時,是否可以獲得 window內部各個控件的大小?

WINDOWPLACEMENT .rcNormalPosition 定義為:

當 window 在恢復的 position 中時窗口的坐標。

要獲取當前大小,請使用GetWindowRect function。 Raymond Chen 也有一篇關於這個主題的有趣文章

以下程序給出了最小化 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);
}

真:-31948 -31335 -31923 -30761

GetWindowRect呢? 它為您提供 position 和尺寸。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM