1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
28 // $Log: XplatUIWin32.cs,v $
29 // Revision 1.43 2004/11/08 20:55:33 pbartok
30 // - Added argument to SetTopmost method
31 // - Fixed broken ClientToScreen function
33 // Revision 1.42 2004/10/20 03:58:05 pbartok
34 // - Small sanity check
36 // Revision 1.41 2004/10/18 05:17:32 pbartok
37 // - Removed VirtualKeys to XplatUIStructs
38 // - Implemented SetTopMost method
39 // - Implemented EnableWindow method
40 // - Bugfix in ScreenToClient()
41 // - Bugfixes in ClientToScreen()
43 // Revision 1.40 2004/10/13 20:18:21 pbartok
44 // - Added code to destroy a window
46 // Revision 1.39 2004/10/06 09:59:05 jordi
47 // removes warnings from compilation
49 // Revision 1.38 2004/10/02 19:08:38 pbartok
50 // - Added Win32EnableWindow method (test for implementing modal dialogs)
51 // - Added ClientToScreen method and imports
53 // Revision 1.37 2004/09/21 04:14:29 pbartok
54 // - Fixed accessibility level for Idle handler
56 // Revision 1.36 2004/09/21 00:54:15 jackson
57 // New message loop that uses poll so we don't get a busy loop
59 // Revision 1.35 2004/09/16 23:45:09 pbartok
60 // - Fixed sending a window to the front
61 // - Added overload for SetWindowPos to avoid casting
63 // Revision 1.34 2004/09/13 21:18:32 pbartok
64 // - Added Z-Ordering methods
66 // Revision 1.33 2004/09/11 00:57:35 pbartok
67 // - Added method to retrieve text from window
69 // Revision 1.32 2004/08/25 18:33:08 pbartok
70 // - Fixed timer handling, now seems to work
71 // - Improved error message for window creation
73 // Revision 1.31 2004/08/24 17:17:27 pbartok
74 // - Implemented SetTimer() and KillTimer()
76 // Revision 1.30 2004/08/24 11:29:44 jackson
77 // Move timers to the driver level. On X they are queued by the driver and checked on idle.
79 // Revision 1.29 2004/08/24 00:19:36 ravindra
80 // Removed the unwanted destructor.
82 // Revision 1.28 2004/08/23 19:39:30 pbartok
83 // - Added method to move mouse cursor
85 // Revision 1.27 2004/08/21 20:51:27 pbartok
86 // - Added method to get default display size
88 // Revision 1.26 2004/08/21 20:23:56 pbartok
89 // - Added method to query current grab state
90 // - Added argument to allow confining a grab to a window
92 // Revision 1.25 2004/08/21 18:35:38 pbartok
93 // - Fixed bug with Async message handling
94 // - Implemented getting the ModifierKeys
96 // Revision 1.24 2004/08/21 17:31:21 pbartok
97 // - Drivers now return proper mouse state
99 // Revision 1.23 2004/08/20 20:39:07 pbartok
100 // - Added jackson's Async code from X11 to Win32
102 // Revision 1.22 2004/08/20 20:02:45 pbartok
103 // - Added method for setting the background color
104 // - Added handling for erasing the window background
106 // Revision 1.21 2004/08/20 19:14:35 jackson
107 // Expose functionality to send async messages through the driver
109 // Revision 1.20 2004/08/20 01:37:47 pbartok
110 // - Added generation of MouseEnter, MouseLeave and MouseHover events
111 // - Added cleanup on EndPaint
113 // Revision 1.19 2004/08/18 19:16:53 jordi
114 // Move colors to a table
116 // Revision 1.18 2004/08/17 21:24:03 pbartok
117 // - Finished IsVisible
118 // - Added Win32GetWindowPlacement
120 // Revision 1.17 2004/08/13 21:42:15 pbartok
121 // - Changed signature for GetCursorPos
123 // Revision 1.16 2004/08/13 19:00:15 jordi
124 // implements PointToClient (ScreenToClient)
126 // Revision 1.15 2004/08/13 18:53:57 pbartok
127 // - Changed GetWindowPos to also provide client area size
128 // - Fixed broken prototypes for several win32 functions
130 // Revision 1.14 2004/08/12 22:59:03 pbartok
131 // - Implemented method to get current mouse position
133 // Revision 1.13 2004/08/11 22:20:59 pbartok
136 // Revision 1.12 2004/08/11 19:41:38 jordi
139 // Revision 1.11 2004/08/11 19:19:44 pbartok
140 // - We had SetWindowPos and MoveWindow to set window positions and size,
141 // removed MoveWindow. We have GetWindowPos, so it made sense to keep
142 // SetWindowPos as matching counterpart
143 // - Added some X11 sanity checking
145 // Revision 1.10 2004/08/11 18:55:46 pbartok
146 // - Added method to calculate difference between decorated window and raw
149 // Revision 1.9 2004/08/10 18:47:16 jordi
150 // Calls InvalidateRect before UpdateWindow
152 // Revision 1.8 2004/08/10 17:36:17 pbartok
153 // - Implemented several methods
155 // Revision 1.7 2004/08/09 20:55:59 pbartok
156 // - Removed Run method, was only required for initial development
158 // Revision 1.6 2004/08/09 20:51:25 pbartok
159 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
161 // Revision 1.5 2004/08/09 16:05:16 jackson
162 // These properties are handled by the theme now.
164 // Revision 1.4 2004/08/06 15:53:39 jordi
165 // X11 keyboard navigation
167 // Revision 1.3 2004/08/04 20:11:24 pbartok
168 // - Added Invalidate handling
170 // Revision 1.2 2004/07/21 16:19:17 jordi
171 // LinkLabel control implementation
173 // Revision 1.1 2004/07/09 05:21:25 pbartok
174 // - Initial check-in
181 using System.Drawing;
182 using System.ComponentModel;
183 using System.Collections;
184 using System.Diagnostics;
185 using System.Runtime.InteropServices;
189 namespace System.Windows.Forms {
190 internal class XplatUIWin32 : XplatUIDriver {
191 #region Local Variables
192 private static XplatUIWin32 instance;
193 private static int ref_count;
194 private static IntPtr FosterParent;
196 internal static MouseButtons mouse_state;
197 internal static Point mouse_position;
198 internal static bool grab_confined;
199 internal static IntPtr grab_hwnd;
200 internal static Rectangle grab_area;
201 internal static WndProc wnd_proc;
202 internal static IntPtr prev_mouse_hwnd;
204 internal static bool themes_enabled;
205 private static Hashtable handle_data;
206 private Hashtable timer_list;
207 #endregion // Local Variables
209 #region Private Structs
210 [StructLayout(LayoutKind.Sequential)]
\r
211 private struct WNDCLASS {
\r
212 internal int style;
\r
213 internal WndProc lpfnWndProc;
\r
214 internal int cbClsExtra;
\r
215 internal int cbWndExtra;
\r
216 internal IntPtr hInstance;
\r
217 internal IntPtr hIcon;
\r
218 internal IntPtr hCursor;
\r
219 internal IntPtr hbrBackground;
\r
220 internal string lpszMenuName;
\r
221 internal string lpszClassName;
\r
224 [StructLayout(LayoutKind.Sequential)]
\r
225 private struct RECT {
\r
228 internal int right;
\r
229 internal int bottom;
\r
232 [StructLayout(LayoutKind.Sequential)]
\r
233 private struct POINT {
\r
238 internal enum WindowPlacementFlags {
242 SW_SHOWMINIMIZED = 2,
\r
243 SW_SHOWMAXIMIZED = 3,
\r
245 SW_SHOWNOACTIVATE = 4,
\r
248 SW_SHOWMINNOACTIVE = 7,
\r
251 SW_SHOWDEFAULT = 10,
\r
252 SW_FORCEMINIMIZE = 11,
\r
256 [StructLayout(LayoutKind.Sequential)]
\r
257 private struct WINDOWPLACEMENT {
\r
258 internal uint length;
\r
259 internal uint flags;
\r
260 internal WindowPlacementFlags showCmd;
\r
261 internal POINT ptMinPosition;
\r
262 internal POINT ptMaxPosition;
\r
263 internal RECT rcNormalPosition;
\r
267 private enum TMEFlags {
\r
268 TME_HOVER = 0x00000001,
\r
269 TME_LEAVE = 0x00000002,
\r
270 TME_QUERY = unchecked((int)0x40000000),
\r
271 TME_CANCEL = unchecked((int)0x80000000)
\r
274 [StructLayout(LayoutKind.Sequential)]
\r
275 private struct TRACKMOUSEEVENT {
\r
277 internal TMEFlags dwFlags;
\r
278 internal IntPtr hWnd;
\r
279 internal int dwHoverTime;
\r
282 [StructLayout(LayoutKind.Sequential)]
\r
283 private struct PAINTSTRUCT {
\r
284 internal IntPtr hdc;
\r
285 internal int fErase;
\r
286 internal RECT rcPaint;
\r
287 internal int fRestore;
\r
288 internal int fIncUpdate;
\r
289 internal int Reserved1;
\r
290 internal int Reserved2;
\r
291 internal int Reserved3;
\r
292 internal int Reserved4;
\r
293 internal int Reserved5;
\r
294 internal int Reserved6;
\r
295 internal int Reserved7;
\r
296 internal int Reserved8;
\r
299 internal enum ClassStyle {
\r
300 CS_VREDRAW = 0x00000001,
\r
301 CS_HREDRAW = 0x00000002,
\r
302 CS_KEYCVTWINDOW = 0x00000004,
\r
303 CS_DBLCLKS = 0x00000008,
\r
304 CS_OWNDC = 0x00000020,
\r
305 CS_CLASSDC = 0x00000040,
\r
306 CS_PARENTDC = 0x00000080,
\r
307 CS_NOKEYCVT = 0x00000100,
\r
308 CS_NOCLOSE = 0x00000200,
\r
309 CS_SAVEBITS = 0x00000800,
\r
310 CS_BYTEALIGNCLIENT = 0x00001000,
\r
311 CS_BYTEALIGNWINDOW = 0x00002000,
\r
312 CS_GLOBALCLASS = 0x00004000,
\r
313 CS_IME = 0x00010000
\r
316 internal enum PeekMessageFlags {
\r
317 PM_NOREMOVE = 0x00000000,
\r
318 PM_REMOVE = 0x00000001,
\r
319 PM_NOYIELD = 0x00000002
\r
322 internal enum SetWindowPosZOrder {
330 internal enum SetWindowPosFlags {
331 SWP_ASYNCWINDOWPOS = 0x4000,
332 SWP_DEFERERASE = 0x2000,
333 SWP_DRAWFRAME = 0x0020,
334 SWP_FRAMECHANGED = 0x0020,
335 SWP_HIDEWINDOW = 0x0080,
336 SWP_NOACTIVATE = 0x0010,
337 SWP_NOCOPYBITS = 0x0100,
339 SWP_NOOWNERZORDER = 0x0200,
340 SWP_NOREDRAW = 0x0008,
341 SWP_NOREPOSITION = 0x0200,
342 SWP_NOENDSCHANGING = 0x0400,
344 SWP_NOZORDER = 0x0004,
345 SWP_SHOWWINDOW = 0x0040
348 internal enum GetSysColorIndex {
\r
349 COLOR_SCROLLBAR =0,
\r
350 COLOR_BACKGROUND =1,
\r
351 COLOR_ACTIVECAPTION =2,
\r
352 COLOR_INACTIVECAPTION =3,
\r
355 COLOR_WINDOWFRAME =6,
\r
357 COLOR_WINDOWTEXT =8,
\r
358 COLOR_CAPTIONTEXT =9,
\r
359 COLOR_ACTIVEBORDER =10,
\r
360 COLOR_INACTIVEBORDER =11,
\r
361 COLOR_APPWORKSPACE =12,
\r
362 COLOR_HIGHLIGHT =13,
\r
363 COLOR_HIGHLIGHTTEXT =14,
\r
365 COLOR_BTNSHADOW =16,
\r
366 COLOR_GRAYTEXT =17,
\r
368 COLOR_INACTIVECAPTIONTEXT =19,
\r
369 COLOR_BTNHIGHLIGHT =20,
\r
370 COLOR_3DDKSHADOW =21,
\r
372 COLOR_INFOTEXT =23,
\r
376 COLOR_3DSHADOW =16,
\r
377 COLOR_3DHIGHLIGHT =20,
\r
378 COLOR_3DHILIGHT =20,
\r
379 COLOR_BTNHILIGHT =20,
380 COLOR_MAXVALUE =24,/* Maximum value */
\r
383 private enum LoadCursorType {
\r
388 IDC_UPARROW =32516,
\r
391 IDC_SIZENWSE =32642,
\r
392 IDC_SIZENESW =32643,
\r
395 IDC_SIZEALL =32646,
\r
398 IDC_APPSTARTING =32650,
\r
403 private enum WindowLong {
\r
405 GWL_HINSTANCE = -6,
\r
406 GWL_HWNDPARENT = -8,
\r
409 GWL_USERDATA = -21,
\r
414 private enum LogBrushStyle {
\r
421 BS_DIBPATTERNPT = 6,
\r
423 BS_DIBPATTERN8X8 = 8,
\r
428 private enum LogBrushHatch {
\r
429 HS_HORIZONTAL = 0, /* ----- */
\r
430 HS_VERTICAL = 1, /* ||||| */
\r
431 HS_FDIAGONAL = 2, /* \\\\\ */
\r
432 HS_BDIAGONAL = 3, /* ///// */
\r
433 HS_CROSS = 4, /* +++++ */
\r
434 HS_DIAGCROSS = 5, /* xxxxx */
\r
437 private struct COLORREF {
\r
444 [StructLayout(LayoutKind.Sequential)]
\r
445 private struct LOGBRUSH {
\r
446 internal LogBrushStyle lbStyle;
\r
447 internal COLORREF lbColor;
\r
448 internal LogBrushHatch lbHatch;
\r
452 #region Constructor & Destructor
453 private XplatUIWin32() {
457 // Handle singleton stuff first
460 // Now regular initialization
461 mouse_state = MouseButtons.None;
462 mouse_position = Point.Empty;
464 themes_enabled = false;
466 // Prepare 'our' window class
467 wnd_proc = new WndProc(NativeWindow.WndProc);
468 wndClass.style = (int)(ClassStyle.CS_OWNDC | ClassStyle.CS_DBLCLKS);
469 wndClass.lpfnWndProc = wnd_proc;
470 wndClass.cbClsExtra = 0;
471 wndClass.cbWndExtra = 0;
472 wndClass.hbrBackground = IntPtr.Zero;
473 wndClass.hCursor = Win32LoadCursor(IntPtr.Zero, LoadCursorType.IDC_ARROW);
474 wndClass.hIcon = IntPtr.Zero;
475 wndClass.hInstance = IntPtr.Zero;
476 wndClass.lpszClassName = XplatUI.DefaultClassName;
477 wndClass.lpszMenuName = "";
479 result=Win32RegisterClass(ref wndClass);
481 Win32MessageBox(IntPtr.Zero, "Could not register the "+XplatUI.DefaultClassName+" window class, win32 error " + Win32GetLastError().ToString(), "Oops", 0);
484 FosterParent=Win32CreateWindow(0, "static", "Foster Parent Window", (int)WindowStyles.WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
486 if (FosterParent==IntPtr.Zero) {
487 Win32MessageBox(IntPtr.Zero, "Could not create foster window, win32 error " + Win32GetLastError().ToString(), "Oops", 0);
490 handle_data = new Hashtable ();
491 timer_list = new Hashtable ();
493 #endregion // Constructor & Destructor
495 #region Private Support Methods
496 private static IntPtr DefWndProc(IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) {
497 return Win32DefWindowProc(hWnd, msg, wParam, lParam);
500 private void EraseWindowBackground(IntPtr hWnd, IntPtr hDc) {
507 argb = (uint)Win32GetWindowLong(hWnd, WindowLong.GWL_USERDATA);
510 lb.lbColor.B = (byte)((argb & 0xff0000)>>16);
511 lb.lbColor.G = (byte)((argb & 0xff00)>>8);
512 lb.lbColor.R = (byte)(argb & 0xff);
514 lb.lbStyle = LogBrushStyle.BS_SOLID;
515 hbr = Win32CreateBrushIndirect(ref lb);
516 Win32GetClientRect(hWnd, out rect);
517 Win32FillRect(hDc, ref rect, hbr);
518 Win32DeleteObject(hbr);
521 #endregion // Private Support Methods
523 #region Static Properties
524 internal override Keys ModifierKeys {
529 key_state = Keys.None;
531 state = Win32GetKeyState(VirtualKeys.VK_SHIFT);
532 if ((state & 0x8000) != 0) {
533 key_state |= Keys.Shift;
535 state = Win32GetKeyState(VirtualKeys.VK_CONTROL);
536 if ((state & 0x8000) != 0) {
537 key_state |= Keys.Control;
543 internal override MouseButtons MouseButtons {
549 internal override Point MousePosition {
551 return mouse_position;
555 internal override bool DropTarget {
562 throw new NotImplementedException("Need to figure out D'n'D for Win32");
566 #endregion // Static Properties
568 #region Singleton Specific Code
569 public static XplatUIWin32 GetInstance() {
570 if (instance==null) {
571 instance=new XplatUIWin32();
577 public int Reference {
584 #region Public Static Methods
585 internal override IntPtr InitializeDriver() {
\r
586 mouse_state=MouseButtons.None;
587 mouse_position=Point.Empty;
589 Console.WriteLine("#region #line XplatUI Win32 Constructor called");
591 return IntPtr.Zero;
\r
594 internal override void ShutdownDriver(IntPtr token) {
\r
595 Console.WriteLine("XplatUIWin32 ShutdownDriver called");
599 internal void Version() {
600 Console.WriteLine("Xplat version $revision: $");
603 internal override void Exit() {
604 Win32PostQuitMessage(0);
607 internal override void GetDisplaySize(out Size size) {
610 Win32GetWindowRect(Win32GetDesktopWindow(), out rect);
612 size = new Size(rect.right - rect.left, rect.bottom - rect.top);
615 internal override void EnableThemes() {
619 internal override IntPtr CreateWindow(CreateParams cp) {
623 ParentHandle=cp.Parent;
625 if ((ParentHandle==IntPtr.Zero) && (cp.Style & (int)(WindowStyles.WS_CHILD))!=0) {
626 // We need to use our foster parent window until this poor child gets it's parent assigned
627 ParentHandle=FosterParent;
629 WindowHandle = Win32CreateWindow((uint)cp.ExStyle, cp.ClassName, cp.Caption, (uint)cp.Style, cp.X, cp.Y, cp.Width, cp.Height, ParentHandle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
631 if (WindowHandle==IntPtr.Zero) {
632 uint error = Win32GetLastError();
634 Win32MessageBox(IntPtr.Zero, "Error : " + error.ToString(), "Failed to create window, class '"+cp.ClassName+"'", 0);
637 Win32SetWindowLong(WindowHandle, WindowLong.GWL_USERDATA, (IntPtr)ThemeEngine.Current.DefaultControlBackColor.ToArgb());
642 internal override IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
643 CreateParams create_params = new CreateParams();
645 create_params.Caption = "";
648 create_params.Width = Width;
649 create_params.Height = Height;
651 create_params.ClassName=XplatUI.DefaultClassName;
652 create_params.ClassStyle = 0;
653 create_params.ExStyle=0;
654 create_params.Parent=IntPtr.Zero;
655 create_params.Param=0;
657 return CreateWindow(create_params);
660 internal override void DestroyWindow(IntPtr handle) {
661 Win32DestroyWindow(handle);
665 internal override void RefreshWindow(IntPtr handle) {
666 Win32InvalidateRect(handle, IntPtr.Zero, true);
667 Win32UpdateWindow(handle);
670 internal override void SetWindowBackground(IntPtr handle, Color color) {
671 Win32SetWindowLong(handle, WindowLong.GWL_USERDATA, (IntPtr)color.ToArgb());
674 [MonoTODO("Add support for internal table of windows/DCs for cleanup")]
675 internal override PaintEventArgs PaintEventStart(IntPtr handle) {
678 PaintEventArgs paint_event;
682 clip_rect = new Rectangle();
684 ps = new PAINTSTRUCT();
686 if (Win32GetUpdateRect(handle, ref rect, false)) {
689 hdc = Win32BeginPaint(handle, ref ps);
691 data = (HandleData) handle_data [0];
693 data = new HandleData();
694 handle_data[0] = data;
697 data.DeviceContext=(Object)ps;
699 // FIXME: Figure out why the rectangle is always 0 size
700 clip_rect = new Rectangle(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top);
701 // clip_rect = new Rectangle(rect.top, rect.left, rect.right-rect.left, rect.bottom-rect.top);
704 EraseWindowBackground(handle, hdc);
707 hdc = Win32GetDC(handle);
708 // FIXME: Add the DC to internal list
709 clip_rect = new Rectangle(rect.top, rect.left, rect.right-rect.left, rect.bottom-rect.top);
712 paint_event = new PaintEventArgs(Graphics.FromHdc(hdc), clip_rect);
717 internal override void PaintEventEnd(IntPtr handle) {
\r
721 data = (HandleData) handle_data [0];
723 data = new HandleData();
724 handle_data[0] = data;
727 //paint_event.Graphics.Dispose();
728 if (data.DeviceContext != null) {
729 ps = (PAINTSTRUCT)data.DeviceContext;
730 Win32EndPaint(handle, ref ps);
735 internal override void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
736 Win32MoveWindow(handle, x, y, width, height, true);
740 internal override void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
744 Win32GetWindowRect(handle, out rect);
745 width = rect.right - rect.left;
746 height = rect.bottom - rect.top;
750 Win32ScreenToClient(Win32GetParent(handle), ref pt);
754 Win32GetClientRect(handle, out rect);
755 client_width = rect.right - rect.left;
756 client_height = rect.bottom - rect.top;
760 internal override void Activate(IntPtr handle) {
761 Win32SetActiveWindow(handle);
764 internal override void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
770 rect.bottom=rc.Bottom;
771 Win32InvalidateRect(handle, ref rect, clear);
774 internal override IntPtr DefWndProc(ref Message msg) {
775 msg.Result=Win32DefWindowProc(msg.HWnd, (Msg)msg.Msg, msg.WParam, msg.LParam);
779 internal override void HandleException(Exception e) {
780 StackTrace st = new StackTrace(e);
781 Win32MessageBox(IntPtr.Zero, e.Message+st.ToString(), "Exception", 0);
782 Console.WriteLine("{0}{1}", e.Message, st.ToString());
785 internal override void DoEvents() {
788 while (Win32PeekMessage(ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)!=true) {
789 if (msg.message==Msg.WM_PAINT) {
790 XplatUI.TranslateMessage(ref msg);
791 XplatUI.DispatchMessage(ref msg);
796 internal override bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
797 return Win32PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
800 internal override bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
803 data = (HandleData) handle_data [0];
804 if ((data!=null) && data.GetMessage(ref msg)) {
808 result = Win32GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
810 // We need to fake WM_MOUSE_ENTER/WM_MOUSE_LEAVE
811 switch (msg.message) {
812 case Msg.WM_LBUTTONDOWN: {
813 mouse_state |= MouseButtons.Left;
817 case Msg.WM_MBUTTONDOWN: {
818 mouse_state |= MouseButtons.Middle;
822 case Msg.WM_RBUTTONDOWN: {
823 mouse_state |= MouseButtons.Right;
827 case Msg.WM_LBUTTONUP: {
828 mouse_state &= ~MouseButtons.Left;
832 case Msg.WM_MBUTTONUP: {
833 mouse_state &= ~MouseButtons.Middle;
837 case Msg.WM_RBUTTONUP: {
838 mouse_state &= ~MouseButtons.Right;
842 case Msg.WM_ERASEBKGND: {
843 EraseWindowBackground(msg.hwnd, msg.wParam);
847 case Msg.WM_ASYNC_MESSAGE: {
848 GCHandle handle = (GCHandle)msg.lParam;
849 AsyncMethodData asyncdata = (AsyncMethodData) handle.Target;
850 AsyncMethodResult asyncresult = asyncdata.Result.Target as AsyncMethodResult;
851 object ret = asyncdata.Method.DynamicInvoke (asyncdata.Args);
852 if (asyncresult != null) {
853 asyncresult.Complete (ret);
859 case Msg.WM_MOUSEMOVE: {
860 if (msg.hwnd != prev_mouse_hwnd) {
864 data = new HandleData();
865 handle_data[0] = data;
868 // The current message will be sent out next time around
869 data.StoreMessage(ref msg);
871 // This is the message we want to send at this point
872 msg.message = Msg.WM_MOUSE_ENTER;
874 prev_mouse_hwnd = msg.hwnd;
876 tme = new TRACKMOUSEEVENT();
877 tme.size = Marshal.SizeOf(tme);
879 tme.dwFlags = TMEFlags.TME_LEAVE | TMEFlags.TME_HOVER;
880 Win32TrackMouseEvent(ref tme);
886 case Msg.WM_MOUSELEAVE: {
887 prev_mouse_hwnd = IntPtr.Zero;
888 msg.message=Msg.WM_MOUSE_LEAVE;
893 Timer timer=(Timer)timer_list[(int)msg.wParam];
905 internal override bool TranslateMessage(ref MSG msg) {
906 return Win32TranslateMessage(ref msg);
909 internal override IntPtr DispatchMessage(ref MSG msg) {
910 return Win32DispatchMessage(ref msg);
913 internal override bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom) {
915 Win32SetWindowPos(hWnd, SetWindowPosZOrder.HWND_TOP, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
917 } else if (!Bottom) {
918 Win32SetWindowPos(hWnd, AfterhWnd, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
920 Win32SetWindowPos(hWnd, (IntPtr)SetWindowPosZOrder.HWND_BOTTOM, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
926 internal override bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled) {
928 Win32SetWindowPos(hWnd, SetWindowPosZOrder.HWND_TOPMOST, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
931 Win32SetWindowPos(hWnd, SetWindowPosZOrder.HWND_NOTOPMOST, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
936 internal override bool Text(IntPtr handle, string text) {
937 Win32SetWindowText(handle, text);
941 internal override bool GetText(IntPtr handle, out string text) {
944 sb = new StringBuilder(256);
945 Win32GetWindowText(handle, sb, sb.Capacity);
946 text = sb.ToString();
950 internal override bool SetVisible(IntPtr handle, bool visible) {
952 Win32ShowWindow(handle, WindowPlacementFlags.SW_SHOWNORMAL);
954 Win32ShowWindow(handle, WindowPlacementFlags.SW_HIDE);
959 internal override bool IsVisible(IntPtr handle) {
960 WINDOWPLACEMENT wndpl;
962 wndpl = new WINDOWPLACEMENT();
963 wndpl.length=(uint)Marshal.SizeOf(wndpl);
964 Win32GetWindowPlacement(handle, ref wndpl);
965 if ((wndpl.showCmd == WindowPlacementFlags.SW_SHOWMINIMIZED)) {
971 internal override IntPtr SetParent(IntPtr handle, IntPtr parent) {
972 return Win32SetParent(handle, parent);
975 internal override IntPtr GetParent(IntPtr handle) {
976 return Win32GetParent(handle);
979 internal override void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd) {
981 Win32SetCapture(hWnd);
984 internal override void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea) {
986 GrabConfined = grab_confined;
987 GrabArea = grab_area;
990 internal override void ReleaseWindow(IntPtr hWnd) {
991 Win32ReleaseCapture();
992 grab_hwnd = IntPtr.Zero;
995 internal override bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
998 rect.left=ClientRect.Left;
999 rect.top=ClientRect.Top;
1000 rect.right=ClientRect.Right;
1001 rect.bottom=ClientRect.Bottom;
1003 if (!Win32AdjustWindowRectEx(ref rect, Style, HasMenu, 0)) {
1004 WindowRect = new Rectangle(ClientRect.Left, ClientRect.Top, ClientRect.Width, ClientRect.Height);
1008 WindowRect = new Rectangle(rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
1012 internal override void SetCursorPos(IntPtr handle, int x, int y) {
1013 Win32SetCursorPos(x, y);
1016 internal override void EnableWindow(IntPtr handle, bool Enable) {
1017 Win32EnableWindow(handle, Enable);
1020 internal override void SetModal(IntPtr handle, bool Modal) {
1021 // we do nothing on Win32; Application.cs simulates modal dialogs by disabling all toplevel windows
1024 internal override void GetCursorPos(IntPtr handle, out int x, out int y) {
1027 Win32GetCursorPos(out pt);
1029 if (handle!=IntPtr.Zero) {
1030 Win32ScreenToClient(handle, ref pt);
1037 internal override void ScreenToClient(IntPtr handle, ref int x, ref int y)
1039 POINT pnt = new POINT();
1043 Win32ScreenToClient (handle, ref pnt);
1049 internal override void ClientToScreen(IntPtr handle, ref int x, ref int y) {
1050 POINT pnt = new POINT();
1055 Win32ClientToScreen(handle, ref pnt);
1061 internal override void SendAsyncMethod (AsyncMethodData method)
1063 Win32PostMessage(FosterParent, Msg.WM_ASYNC_MESSAGE, IntPtr.Zero, (IntPtr)GCHandle.Alloc (method));
1066 internal override void SetTimer (Timer timer)
1070 index = timer.GetHashCode();
1073 timer_list[index]=timer;
1076 Win32SetTimer(FosterParent, index, (uint)timer.Interval, IntPtr.Zero);
1079 internal override void KillTimer (Timer timer)
1083 index = timer.GetHashCode();
1085 Win32KillTimer(FosterParent, index);
1088 timer_list.Remove(index);
1093 private void CaretCallback(object sender, EventArgs e) {
\r
1094 Console.WriteLine("CaretCallback hit");
\r
1097 internal override void CreateCaret(IntPtr hwnd, int width, int height) {
1098 Win32CreateCaret(hwnd, IntPtr.Zero, width, height);
1101 internal override void DestroyCaret(IntPtr hwnd) {
1102 Win32DestroyCaret();
1105 internal override void SetCaretPos(IntPtr hwnd, int x, int y) {
1106 Win32SetCaretPos(x, y);
1109 internal override void CaretVisible(IntPtr hwnd, bool visible) {
1111 Win32ShowCaret(hwnd);
1113 Win32HideCaret(hwnd);
1117 internal override int KeyboardSpeed {
1119 Console.WriteLine ("KeyboardSpeed: need to query Windows");
1122 // Return values range from 0 to 31 which map to 2.5 to 30 repetitions per second.
1128 internal override int KeyboardDelay {
1130 Console.WriteLine ("KeyboardDelay: need to query Windows");
1133 // Return values must range from 0 to 4, 0 meaning 250ms,
1134 // and 4 meaning 1000 ms.
1140 internal override event EventHandler Idle;
1142 // Santa's little helper
1143 static void Where() {
1144 Console.WriteLine("Here: {0}", new StackTrace().ToString());
1146 #endregion // Public Static Methods
1148 #region Win32 Imports
1149 [DllImport ("kernel32.dll", EntryPoint="GetLastError", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1150 private extern static uint Win32GetLastError();
1152 [DllImport ("user32.dll", EntryPoint="CreateWindowExA", CallingConvention=CallingConvention.StdCall)]
1153 internal extern static IntPtr Win32CreateWindow(uint dwExStyle, string lpClassName, string lpWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lParam);
1155 [DllImport ("user32.dll", EntryPoint="DestroyWindow", CallingConvention=CallingConvention.StdCall)]
1156 internal extern static bool Win32DestroyWindow(IntPtr hWnd);
1158 [DllImport ("user32.dll", EntryPoint="PeekMessageA", CallingConvention=CallingConvention.StdCall)]
1159 internal extern static bool Win32PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
1161 [DllImport ("user32.dll", EntryPoint="GetMessageA", CallingConvention=CallingConvention.StdCall)]
1162 internal extern static bool Win32GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
1164 [DllImport ("user32.dll", EntryPoint="TranslateMessage", CallingConvention=CallingConvention.StdCall)]
1165 internal extern static bool Win32TranslateMessage(ref MSG msg);
1167 [DllImport ("user32.dll", EntryPoint="DispatchMessageA", CallingConvention=CallingConvention.StdCall)]
1168 internal extern static IntPtr Win32DispatchMessage(ref MSG msg);
1170 [DllImport ("user32.dll", EntryPoint="MoveWindow", CallingConvention=CallingConvention.StdCall)]
1171 internal extern static bool Win32MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
1173 [DllImport ("user32.dll", EntryPoint="SetWindowPos", CallingConvention=CallingConvention.StdCall)]
1174 internal extern static bool Win32SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags Flags);
1176 [DllImport ("user32.dll", EntryPoint="SetWindowPos", CallingConvention=CallingConvention.StdCall)]
1177 internal extern static bool Win32SetWindowPos(IntPtr hWnd, SetWindowPosZOrder pos, int x, int y, int cx, int cy, SetWindowPosFlags Flags);
1179 [DllImport ("user32.dll", EntryPoint="SetWindowTextA", CallingConvention=CallingConvention.StdCall)]
1180 internal extern static bool Win32SetWindowText(IntPtr hWnd, string lpString);
1182 [DllImport ("user32.dll", EntryPoint="GetWindowTextA", CallingConvention=CallingConvention.StdCall)]
1183 internal extern static bool Win32GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
1185 [DllImport ("user32.dll", EntryPoint="SetParent", CallingConvention=CallingConvention.StdCall)]
1186 internal extern static IntPtr Win32SetParent(IntPtr hWnd, IntPtr hParent);
1188 [DllImport ("user32.dll", EntryPoint="RegisterClassA", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1189 private extern static bool Win32RegisterClass(ref WNDCLASS wndClass);
1191 [DllImport ("user32.dll", EntryPoint="LoadCursorA", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1192 private extern static IntPtr Win32LoadCursor(IntPtr hInstance, LoadCursorType type);
1194 [DllImport ("user32.dll", EntryPoint="DefWindowProcA", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1195 private extern static IntPtr Win32DefWindowProc(IntPtr hWnd, Msg Msg, IntPtr wParam, IntPtr lParam);
1197 [DllImport ("user32.dll", EntryPoint="DefDlgProcA", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1198 private extern static IntPtr Win32DefDlgProc(IntPtr hWnd, Msg Msg, IntPtr wParam, IntPtr lParam);
1200 [DllImport ("user32.dll", EntryPoint="PostQuitMessage", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1201 private extern static IntPtr Win32PostQuitMessage(int nExitCode);
1203 [DllImport ("user32.dll", EntryPoint="UpdateWindow", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1204 private extern static IntPtr Win32UpdateWindow(IntPtr hWnd);
1206 [DllImport ("user32.dll", EntryPoint="GetUpdateRect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1207 private extern static bool Win32GetUpdateRect(IntPtr hWnd, ref RECT rect, bool erase);
1209 [DllImport ("user32.dll", EntryPoint="BeginPaint", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1210 private extern static IntPtr Win32BeginPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
1212 [DllImport ("user32.dll", EntryPoint="EndPaint", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1213 private extern static bool Win32EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
1215 [DllImport ("user32.dll", EntryPoint="GetDC", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1216 private extern static IntPtr Win32GetDC(IntPtr hWnd);
1218 [DllImport ("user32.dll", EntryPoint="ReleaseDC", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1219 private extern static IntPtr Win32ReleaseDC(IntPtr hWnd, IntPtr hDC);
1221 [DllImport ("user32.dll", EntryPoint="MessageBoxA", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1222 private extern static IntPtr Win32MessageBox(IntPtr hParent, string pText, string pCaption, uint uType);
1224 [DllImport ("user32.dll", EntryPoint="InvalidateRect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1225 private extern static IntPtr Win32InvalidateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);
1227 [DllImport ("user32.dll", EntryPoint="InvalidateRect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1228 private extern static IntPtr Win32InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
1230 [DllImport ("user32.dll", EntryPoint="SetCapture", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1231 private extern static IntPtr Win32SetCapture(IntPtr hWnd);
1233 [DllImport ("user32.dll", EntryPoint="ReleaseCapture", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1234 private extern static IntPtr Win32ReleaseCapture();
1236 [DllImport ("user32.dll", EntryPoint="GetWindowRect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1237 private extern static IntPtr Win32GetWindowRect(IntPtr hWnd, out RECT rect);
1239 [DllImport ("user32.dll", EntryPoint="GetClientRect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1240 private extern static IntPtr Win32GetClientRect(IntPtr hWnd, out RECT rect);
1242 [DllImport ("user32.dll", EntryPoint="ScreenToClient", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1243 private extern static bool Win32ScreenToClient(IntPtr hWnd, ref POINT pt);
1245 [DllImport ("user32.dll", EntryPoint="ClientToScreen", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1246 private extern static bool Win32ClientToScreen(IntPtr hWnd, ref POINT pt);
1248 [DllImport ("user32.dll", EntryPoint="GetParent", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1249 private extern static IntPtr Win32GetParent(IntPtr hWnd);
1251 [DllImport ("user32.dll", EntryPoint="SetActiveWindow", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1252 private extern static IntPtr Win32SetActiveWindow(IntPtr hWnd);
1254 [DllImport ("user32.dll", EntryPoint="PostQuitMessage", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1255 private extern static IntPtr Win32PostQuitMessage(IntPtr hWnd);
1257 [DllImport ("user32.dll", EntryPoint="AdjustWindowRectEx", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1258 private extern static bool Win32AdjustWindowRectEx(ref RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
1260 [DllImport ("user32.dll", EntryPoint="GetCursorPos", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1261 private extern static bool Win32GetCursorPos(out POINT lpPoint);
1263 [DllImport ("user32.dll", EntryPoint="SetCursorPos", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1264 private extern static bool Win32SetCursorPos(int x, int y);
1266 [DllImport ("user32.dll", EntryPoint="GetWindowPlacement", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1267 private extern static bool Win32GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
1269 [DllImport ("user32.dll", EntryPoint="TrackMouseEvent", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1270 private extern static bool Win32TrackMouseEvent(ref TRACKMOUSEEVENT tme);
1272 [DllImport ("gdi32.dll", EntryPoint="CreateBrushIndirect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1273 private extern static IntPtr Win32CreateBrushIndirect(ref LOGBRUSH lb);
1275 [DllImport ("user32.dll", EntryPoint="FillRect", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1276 private extern static int Win32FillRect(IntPtr hdc, ref RECT rect, IntPtr hbr);
1278 [DllImport ("user32.dll", EntryPoint="SetWindowLong", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1279 private extern static IntPtr Win32SetWindowLong(IntPtr hwnd, WindowLong index, IntPtr value);
1281 [DllImport ("user32.dll", EntryPoint="GetWindowLong", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1282 private extern static IntPtr Win32GetWindowLong(IntPtr hwnd, WindowLong index);
1284 [DllImport ("gdi32.dll", EntryPoint="DeleteObject", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1285 private extern static bool Win32DeleteObject(IntPtr o);
1287 [DllImport ("user32.dll", EntryPoint="PostMessage", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1288 private extern static bool Win32PostMessage(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
1290 [DllImport ("user32.dll", EntryPoint="GetKeyState", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1291 private extern static short Win32GetKeyState(VirtualKeys nVirtKey);
1293 [DllImport ("user32.dll", EntryPoint="GetDesktopWindow", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1294 private extern static IntPtr Win32GetDesktopWindow();
1296 [DllImport ("user32.dll", EntryPoint="SetTimer", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1297 private extern static IntPtr Win32SetTimer(IntPtr hwnd, int nIDEvent, uint uElapse, IntPtr timerProc);
1299 [DllImport ("user32.dll", EntryPoint="KillTimer", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1300 private extern static IntPtr Win32KillTimer(IntPtr hwnd, int nIDEvent);
1302 [DllImport ("user32.dll", EntryPoint="ShowWindow", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1303 private extern static IntPtr Win32ShowWindow(IntPtr hwnd, WindowPlacementFlags nCmdShow);
1305 [DllImport ("user32.dll", EntryPoint="EnableWindow", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1306 private extern static IntPtr Win32EnableWindow(IntPtr hwnd, bool Enabled);
1308 [DllImport ("user32.dll", EntryPoint="SetFocus", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1309 internal extern static IntPtr Win32SetFocus(IntPtr hwnd);
1311 [DllImport ("user32.dll", EntryPoint="CreateCaret", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1312 internal extern static bool Win32CreateCaret(IntPtr hwnd, IntPtr hBitmap, int nWidth, int nHeight);
1314 [DllImport ("user32.dll", EntryPoint="DestroyCaret", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1315 internal extern static bool Win32DestroyCaret();
1317 [DllImport ("user32.dll", EntryPoint="ShowCaret", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1318 internal extern static bool Win32ShowCaret(IntPtr hwnd);
1320 [DllImport ("user32.dll", EntryPoint="HideCaret", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1321 internal extern static bool Win32HideCaret(IntPtr hwnd);
1323 [DllImport ("user32.dll", EntryPoint="SetCaretPos", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1324 internal extern static bool Win32SetCaretPos(int X, int Y);
1326 [DllImport ("user32.dll", EntryPoint="GetCaretBlinkTime", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
1327 internal extern static uint Win32GetCaretBlinkTime();