Add session to cache with both hostname and address.
[cyberduck.git] / source / ch / cyberduck / core / NativeMethods.cs
blob380bc73d1cb0870766514129b918dc13164260c9
1 //
2 // Copyright (c) 2010-2014 Yves Langisch. All rights reserved.
3 // http://cyberduck.ch/
4 //
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.
9 //
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.
14 //
15 // Bug fixes, suggestions and comments should be sent to:
16 // yves@cyberduck.ch
17 //
19 using System;
20 using System.Drawing;
21 using System.Runtime.InteropServices;
23 namespace Ch.Cyberduck.Core
25 [StructLayout(LayoutKind.Sequential)]
26 public struct APPBARDATA
28 public uint cbSize;
29 public IntPtr hWnd;
30 public uint uCallbackMessage;
31 public AppBarEdge uEdge;
32 public RECT rc;
33 public int lParam;
36 internal enum MousePositionCodes
38 HTERROR = (-2),
39 HTTRANSPARENT = (-1),
40 HTNOWHERE = 0,
41 HTCLIENT = 1,
42 HTCAPTION = 2,
43 HTSYSMENU = 3,
44 HTGROWBOX = 4,
45 HTSIZE = HTGROWBOX,
46 HTMENU = 5,
47 HTHSCROLL = 6,
48 HTVSCROLL = 7,
49 HTMINBUTTON = 8,
50 HTMAXBUTTON = 9,
51 HTLEFT = 10,
52 HTRIGHT = 11,
53 HTTOP = 12,
54 HTTOPLEFT = 13,
55 HTTOPRIGHT = 14,
56 HTBOTTOM = 15,
57 HTBOTTOMLEFT = 16,
58 HTBOTTOMRIGHT = 17,
59 HTBORDER = 18,
60 HTREDUCE = HTMINBUTTON,
61 HTZOOM = HTMAXBUTTON,
62 HTSIZEFIRST = HTLEFT,
63 HTSIZELAST = HTBOTTOMRIGHT,
64 HTOBJECT = 19,
65 HTCLOSE = 20,
66 HTHELP = 21
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
80 ABM_NEW = 0x00,
81 ABM_REMOVE = 0x01,
82 ABM_QUERYPOS = 0x02,
83 ABM_SETPOS = 0x03,
84 ABM_GETSTATE = 0x04,
85 ABM_GETTASKBARPOS = 0x05,
86 ABM_ACTIVATE = 0x06,
87 ABM_GETAUTOHIDEBAR = 0x07,
88 ABM_SETAUTOHIDEBAR = 0x08,
89 ABM_WINDOWPOSCHANGED = 0x09,
90 ABM_SETSTATE = 0x0a,
93 internal enum AppBarState
95 ABS_MANUAL = 0,
96 ABS_AUTOHIDE = 1,
97 ABS_ALWAYSONTOP = 2,
98 ABS_AUTOHIDEANDONTOP = 3,
101 internal enum AppBarNotification
103 ABN_STATECHANGE = 0,
104 ABN_POSCHANGED,
105 ABN_FULLSCREENAPP,
106 ABN_WINDOWARRANGE,
109 [StructLayout(LayoutKind.Sequential)]
110 public struct RECT
112 public int left;
113 public int top;
114 public int right;
115 public int bottom;
117 public RECT(int left, int top, int right, int bottom)
119 this.left = left;
120 this.top = top;
121 this.right = right;
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)]
137 public struct POINT
139 public int X;
140 public int Y;
142 public POINT(int x, int y)
144 X = x;
145 Y = 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);