2 // Copyright (c) 2010-2014 Yves Langisch. All rights reserved.
3 // http://cyberduck.ch/
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // Bug fixes, suggestions and comments should be sent to:
21 using System
.Runtime
.InteropServices
;
23 namespace Ch
.Cyberduck
.Core
25 [StructLayout(LayoutKind
.Sequential
)]
26 public struct APPBARDATA
30 public uint uCallbackMessage
;
31 public AppBarEdge uEdge
;
36 internal enum MousePositionCodes
60 HTREDUCE
= HTMINBUTTON
,
63 HTSIZELAST
= HTBOTTOMRIGHT
,
69 public enum AppBarEdge
: uint
71 NotDocked
= UInt32
.MaxValue
,
72 ScreenLeft
= 0, // ABE_LEFT
73 ScreenTop
= 1, // ABE_TOP
74 ScreenRight
= 2, // ABE_RIGHT
75 ScreenBottom
= 3, // ABE_BOTTOM
78 public enum AppBarMessage
: uint
85 ABM_GETTASKBARPOS
= 0x05,
87 ABM_GETAUTOHIDEBAR
= 0x07,
88 ABM_SETAUTOHIDEBAR
= 0x08,
89 ABM_WINDOWPOSCHANGED
= 0x09,
93 internal enum AppBarState
98 ABS_AUTOHIDEANDONTOP
= 3,
101 internal enum AppBarNotification
109 [StructLayout(LayoutKind
.Sequential
)]
117 public RECT(int left
, int top
, int right
, int bottom
)
122 this.bottom
= bottom
;
125 public static implicit operator RECT(Rectangle r
)
127 return new RECT(r
.Left
, r
.Top
, r
.Right
, r
.Bottom
);
130 public static explicit operator Rectangle(RECT r
)
132 return new Rectangle(r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
);
136 [StructLayout(LayoutKind
.Sequential
)]
142 public POINT(int x
, int y
)
148 public static implicit operator Point(POINT p
)
150 return new Point(p
.X
, p
.Y
);
153 public static implicit operator POINT(Point p
)
155 return new POINT(p
.X
, p
.Y
);
159 public static class NativeMethods
161 [DllImport("shell32.dll", CallingConvention
= CallingConvention
.StdCall
)]
162 public static extern uint SHAppBarMessage(AppBarMessage dwMessage
, ref APPBARDATA pData
);
164 [DllImport("user32.dll", ExactSpelling
= true)]
165 public static extern bool MoveWindow(IntPtr hWnd
, int x
, int y
, int nWidth
, int nHeight
, bool bRepaint
);
167 [DllImport("user32.dll")]
168 public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType
.LPTStr
)] string lpString
);
170 [DllImport("user32.dll", EntryPoint
= "ReleaseCapture")]
171 public static extern bool StopMouseCapture();
173 [DllImport("user32.dll", EntryPoint
= "SetCapture")]
174 public static extern IntPtr
StartMouseCapture(IntPtr hWnd
);
176 [DllImport("user32.dll", EntryPoint
= "GetCapture")]
177 public static extern IntPtr
GetMouseCapture();
179 [DllImport("user32.dll")]
180 public static extern bool DragDetect(IntPtr hwnd
, POINT pt
);
182 [DllImport("user32.dll")]
183 public static extern void SendMessage(IntPtr hWnd
, int msg
, int wParam
, int lParam
);
185 [DllImport("user32.dll", EntryPoint
= "ShowCaret")]
186 public static extern long ShowCaret(IntPtr hwnd
);
188 [DllImport("user32.dll", EntryPoint
= "HideCaret")]
189 public static extern long HideCaret(IntPtr hwnd
);
191 [DllImport("kernel32.dll", SetLastError
= true)]
192 public static extern int IsValidLocale(int locale
, int dwFlags
);