zoukankan      html  css  js  c++  java
  • 获取任务栏大小

    实现效果;

      

    知识运用:

    API  FindWindow函数  //可用来返回任务栏所在窗口Shell_TrayWnd的句柄

       IpClassName :要返回的窗口的类名称字符串指针

      IpWindowName:要返回的窗口的名称

      GetWindowRect函数  //获取任何一个窗口的矩阵范围的函数

      hwnd:目标窗口的句柄

      IpRect:存储窗口区域的Rectangle结构变量

      

    实现代码:

            [DllImport("user32.dll")]
            public static extern int FindWindow(string IpClassName,string IpWindowName);
            [DllImport("user32.dll")]
            public static extern int GetWindowRect(int hwnd,ref Rectangle IpRect);
            Rectangle rect;
            private void button1_Click(object sender, EventArgs e)
            {
                if ((GetWindowRect(FindWindow("Shell_TrayWnd", null), ref rect)) == 0)
                    return;
                else
                {
                    textBox1.Text = Convert.ToString(rect.Left);
                    textBox2.Text = Convert.ToString(rect.Top);
                    textBox3.Text = Convert.ToString(rect.Right);
                    textBox4.Text = Convert.ToString(rect.Bottom);
                }
            }
    
  • 相关阅读:
    idea的常识
    开发工具
    常用的正则表达式
    比较器
    索引
    final区别
    GC
    String StringBuffer
    类库
    线程的操作状态
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10293275.html
Copyright © 2011-2022 走看看