Api code collection

Source: Internet
Author: User

Collect from the network to make it easy for others

1 # region hide the System scroll bar 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: financialas (UnmanagedType. bool)] 10 private static extern bool ShowScrollBar (IntPtr hWnd, int wBar, bool bShow); 11 # endregion

 

1 # region get the cursor position on the screen 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 ("u Ser32.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 = GetForegroundWindow (); 20 Point p = new Point (); 21 22 // get the position of Caret on the screen Set 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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.