zoukankan      html  css  js  c++  java
  • C#调用WindowsAPI之GetClientRect用法

        函数功能:该函数获取窗口客户区的坐标。客户区坐标指定客户区的左上角和右下角。由于客户区坐标是相对子窗口客户区的左上角而言的,因此左上角坐标为(0,0)

        函数原型:BOOL GetClientRect(HWND hWnd,LPRECT lpRect);

        参数:

        GetLastError 函数。

        备注:Windows CE:命令条包含在客户区中。

        速查:Windows NT: 3.1以上版本:Windows:95以上版本: Windows CE:1.0以上版本:头文件:winuser.h;库文件:user32.lib

    第一步,声明结构


    public struct RECT
    {
        public uint Left;
        public uint Top;
        public uint Right;
        public uint Bottom;
    }

    第二步,导入user32.dll

    [DllImport("user32")]
    public static extern bool GetClientRect(
        IntPtr hwnd, 
        out RECT lpRect
        );

    第三步,设定一个RECT

    RECT rect = new RECT();

    第四步,应用

    bool result = GetClientRect(this.Handle,out RECT rect);

    注:GetClientRect 函数所取得的 LeftTop 值是 0RightBottom 值是 widthheight。也就是说,Right的就是宽度,Bottom的值就是高度了

  • 相关阅读:
    yum安装8.0mysql数据库
    free命令详细介绍
    linux 自定义美女欢迎界面
    shll脚本常用格式和规则使用
    liunx常用知识基本命令大全
    liunx系统二进制包安装编译mysql数据库
    CentOS7更改网卡名称
    老男孩教育100道面试题
    非关系型数据库(NoSQL)
    iptables
  • 原文地址:https://www.cnblogs.com/zhuiyi/p/2595309.html
Copyright © 2011-2022 走看看