码迷,mamicode.com
首页 > Windows程序 > 详细

Api代码收集

时间:2014-05-22 05:45:02      阅读:435      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   c   code   java   

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

bubuko.com,布布扣
 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
bubuko.com,布布扣

 

bubuko.com,布布扣
 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
bubuko.com,布布扣

 

Api代码收集,布布扣,bubuko.com

Api代码收集

标签:style   blog   class   c   code   java   

原文地址:http://www.cnblogs.com/knightyj/p/3738227.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!