zoukankan      html  css  js  c++  java
  • Api代码收集

    收集自网络,方便自己,方便他人 

     1     #region 隐藏系统滚动条
     2     protected override void WndProc(ref System.Windows.Forms.Message m)
     3     {
     4       ShowScrollBar(this.Handle, 3, false);//0:horizontal,1:vertical,3:both
     5       base.WndProc(ref m);
     6     }
     7 
     8     [DllImport("user32.dll")]
     9     [return: MarshalAs(UnmanagedType.Bool)]
    10     private static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);
    11     #endregion
     1     #region 得到光标在屏幕上的位置
     2    [DllImport("user32")]
     3     public static extern bool GetCaretPos(out Point lpPoint);
     4     [DllImport("user32.dll")]
     5     private static extern IntPtr GetForegroundWindow();
     6     [DllImport("user32.dll")]
     7     private static extern IntPtr GetFocus();
     8     [DllImport("user32.dll")]
     9     private static extern IntPtr AttachThreadInput(IntPtr idAttach, IntPtr idAttachTo, int fAttach);
    10     [DllImport("user32.dll")]
    11     private static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);
    12     [DllImport("kernel32.dll")]
    13     private static extern IntPtr GetCurrentThreadId();
    14     [DllImport("user32.dll")]
    15     private static extern void ClientToScreen(IntPtr hWnd, ref Point p);
    16 
    17     private Point CaretPos()
    18     {
    19         IntPtr ptr = GetForegroundWindow();
    20         Point p = new Point();
    21 
    22         //得到Caret在屏幕上的位置   
    23       if (ptr.ToInt32() != 0)
    24         {
    25             IntPtr targetThreadID = GetWindowThreadProcessId(ptr, IntPtr.Zero);
    26             IntPtr localThreadID = GetCurrentThreadId();
    27 
    28             if (localThreadID != targetThreadID)
    29             {
    30                 AttachThreadInput(localThreadID, targetThreadID, 1);
    31                 ptr = GetFocus();
    32                 if (ptr.ToInt32() != 0)
    33                 {
    34                     GetCaretPos(out   p);
    35                     ClientToScreen(ptr, ref   p);
    36                 }
    37                 AttachThreadInput(localThreadID, targetThreadID, 0);
    38             }
    39         }
    40         return p;
    41     }
    42     #endregion
     1 //如何在全屏时notifyIcon依然能够弹出ShowBalloonTip
     2 [DllImport("user32.dll",EntryPoint = "GetForegroundWindow", CharSet = CharSet.Auto, ExactSpelling = true)]
     3 public static extern IntPtr GetForegroundWindow(); //获得本窗体的句柄
     4 [DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
     5 public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体
     6 
     7 if (this.Handle != GetForegroundWindow())
     8 {
     9     SetForegroundWindow(this.Handle);
    10     notifyIcon1.ShowBalloonTip(1500,"注意注意","XXXXXXX!",ToolTipIcon.Warning);
    11 }
  • 相关阅读:
    计算几何 val.3
    项目中常用的19条MySQL优化
    九年测试老鸟给测试新人的6条忠告
    敏捷软件测试常见的七个误区
    JEMTER简单的测试计划
    你真的会搭建测试环境吗?
    使用 Fiddler工具模拟post四种请求数据
    性能测试方案及性能测试流程
    Appium的环境搭建和配置
    Python :编写条件分支代码的技巧
  • 原文地址:https://www.cnblogs.com/knightyj/p/3738227.html
Copyright © 2011-2022 走看看