1
// Copyright (c) 2006, Gustavo Franco
2
// Email: gustavo_franco@hotmail.com
3
// All rights reserved.
5
// Redistribution and use in source and binary forms, with or without modification,
6
// are permitted provided that the following conditions are met:
8
// Redistributions of source code must retain the above copyright notice,
9
// this list of conditions and the following disclaimer.
10
// Redistributions in binary form must reproduce the above copyright notice,
11
// this list of conditions and the following disclaimer in the documentation
12
// and/or other materials provided with the distribution.
14
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
15
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
16
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
17
// PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER
21
using System.Collections.Generic;
23
using System.Runtime.InteropServices;
25
namespace CustomControls.OS
27
[Author("Franco, Gustavo")]
28
public static class Win32
30
public const uint SHGFI_ICON = 0x100;
31
public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
32
public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
33
public const uint SHGFI_ICONLOCATION = 0x1000;
34
public const uint SHGFI_TYPENAME = 0x400;
37
public delegate bool EnumWindowsCallBack(IntPtr hWnd, int lParam);
41
[DllImport("user32.dll", CharSet = CharSet.Auto)]
42
public static extern IntPtr GetParent(IntPtr hWnd);
43
[DllImport("User32.Dll")]
44
public static extern int GetDlgCtrlID(IntPtr hWndCtl);
45
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
46
public static extern int MapWindowPoints(IntPtr hWnd, IntPtr hWndTo, ref POINT pt, int cPoints);
47
[DllImport("user32.dll", SetLastError = true)]
48
public static extern bool GetWindowInfo(IntPtr hwnd, out WINDOWINFO pwi);
49
[DllImport("User32.Dll")]
50
public static extern void GetWindowText(IntPtr hWnd, StringBuilder param, int length);
51
[DllImport("User32.Dll")]
52
public static extern void GetClassName(IntPtr hWnd, StringBuilder param, int length);
53
[DllImport("user32.Dll")]
54
public static extern bool EnumChildWindows(IntPtr hWndParent, EnumWindowsCallBack lpEnumFunc, int lParam);
55
[DllImport("user32.Dll")]
56
public static extern bool EnumWindows(EnumWindowsCallBack lpEnumFunc, int lParam);
57
[DllImport("User32.dll", CharSet = CharSet.Auto)]
58
public static extern bool ReleaseCapture();
59
[DllImport("user32.dll", CharSet = CharSet.Auto)]
60
public static extern IntPtr SetCapture(IntPtr hWnd);
61
[DllImport("user32.dll", CharSet = CharSet.Auto)]
62
public static extern IntPtr ChildWindowFromPointEx(IntPtr hParent, POINT pt, ChildFromPointFlags flags);
63
[DllImport("user32.dll", EntryPoint = "FindWindowExA", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
64
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
65
[DllImport("user32.dll")]
66
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
67
[DllImport("user32.dll", CharSet = CharSet.Auto)]
68
public static extern int PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
69
[DllImport("user32.dll", CharSet = CharSet.Auto)]
70
public static extern int PostMessage(IntPtr hWnd, int msg, int wParam, int lParam);
71
[DllImport("user32.dll", CharSet = CharSet.Auto)]
72
public static extern int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
73
[DllImport("user32.dll", CharSet = CharSet.Auto)]
74
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
75
[DllImport("user32.dll", CharSet = CharSet.Auto)]
76
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, StringBuilder param);
77
[DllImport("user32.dll", CharSet = CharSet.Auto)]
78
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, char[] chars);
79
[DllImport("user32.dll", CharSet = CharSet.Auto)]
80
public static extern IntPtr BeginDeferWindowPos(int nNumWindows);
81
[DllImport("user32.dll", CharSet = CharSet.Auto)]
82
public static extern IntPtr DeferWindowPos(IntPtr hWinPosInfo, IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int Width, int Height, SetWindowPosFlags flags);
83
[DllImport("user32.dll", CharSet = CharSet.Auto)]
84
public static extern bool EndDeferWindowPos(IntPtr hWinPosInfo);
85
[DllImport("user32.dll", CharSet = CharSet.Auto)]
86
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int Width, int Height, SetWindowPosFlags flags);
87
[DllImport("user32.dll")]
88
public static extern bool GetWindowRect(IntPtr hwnd, ref RECT rect);
89
[DllImport("user32.dll")]
90
public static extern bool GetClientRect(IntPtr hwnd, ref RECT rect);
91
[DllImport("shell32.dll")]
92
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);