OSDN Git Service

invoke yamy{64,32} and yamyd32 from same directory of yamy.exe instead of current...
[yamy/yamy.git] / windowstool.h
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
2 // windowstool.h\r
3 \r
4 \r
5 #ifndef _WINDOWSTOOL_H\r
6 #  define _WINDOWSTOOL_H\r
7 \r
8 \r
9 #  include "stringtool.h"\r
10 #  include <windows.h>\r
11 \r
12 \r
13 /// instance handle of this application\r
14 extern HINSTANCE g_hInst;\r
15 \r
16 \r
17 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
18 // resource\r
19 \r
20 /// load resource string\r
21 extern tstring loadString(UINT i_id);\r
22 \r
23 /// load small icon resource (it must be deleted by DestroyIcon())\r
24 extern HICON loadSmallIcon(UINT i_id);\r
25 \r
26 ///load big icon resource (it must be deleted by DestroyIcon())\r
27 extern HICON loadBigIcon(UINT i_id);\r
28 \r
29 \r
30 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
31 // window\r
32 \r
33 /// resize the window (it does not move the window)\r
34 extern bool resizeWindow(HWND i_hwnd, int i_w, int i_h, bool i_doRepaint);\r
35 \r
36 /** get rect of the window in client coordinates.\r
37     @return rect of the window in client coordinates */\r
38 extern bool getChildWindowRect(HWND i_hwnd, RECT *o_rc);\r
39 \r
40 /** set small icon to the specified window.\r
41     @return handle of previous icon or NULL */\r
42 extern HICON setSmallIcon(HWND i_hwnd, UINT i_id);\r
43 \r
44 /** set big icon to the specified window.\r
45     @return handle of previous icon or NULL */\r
46 extern HICON setBigIcon(HWND i_hwnd, UINT i_id);\r
47 \r
48 /// remove icon from a window that is set by setSmallIcon\r
49 extern void unsetSmallIcon(HWND i_hwnd);\r
50 \r
51 /// remove icon from a window that is set by setBigIcon\r
52 extern void unsetBigIcon(HWND i_hwnd);\r
53 \r
54 /// get toplevel (non-child) window\r
55 extern HWND getToplevelWindow(HWND i_hwnd, bool *io_isMDI);\r
56 \r
57 /// move window asynchronously\r
58 extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y);\r
59 \r
60 /// move window asynchronously\r
61 extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y, int i_w, int i_h);\r
62 \r
63 /// resize asynchronously\r
64 extern void asyncResize(HWND i_hwnd, int i_w, int i_h);\r
65 \r
66 /// get dll version\r
67 extern DWORD getDllVersion(const _TCHAR *i_dllname);\r
68 #define PACKVERSION(major, minor) MAKELONG(minor, major)\r
69 \r
70 // workaround of SetForegroundWindow\r
71 extern bool setForegroundWindow(HWND i_hwnd);\r
72 \r
73 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
74 // dialog\r
75 \r
76 /// get/set GWL_USERDATA\r
77 template <class T> inline T getUserData(HWND i_hwnd, T *i_wc)\r
78 {\r
79 #ifdef MAYU64\r
80         return (*i_wc = reinterpret_cast<T>(GetWindowLongPtr(i_hwnd, GWLP_USERDATA)));\r
81 #else\r
82         return (*i_wc = reinterpret_cast<T>(GetWindowLong(i_hwnd, GWL_USERDATA)));\r
83 #endif\r
84 }\r
85 \r
86 ///\r
87 template <class T> inline T setUserData(HWND i_hwnd, T i_wc)\r
88 {\r
89 #ifdef MAYU64\r
90         SetWindowLongPtr(i_hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(i_wc));\r
91 #else\r
92         SetWindowLong(i_hwnd, GWL_USERDATA, reinterpret_cast<long>(i_wc));\r
93 #endif\r
94         return i_wc;\r
95 }\r
96 \r
97 \r
98 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
99 // RECT\r
100 \r
101 ///\r
102 inline int rcWidth(const RECT *i_rc)\r
103 {\r
104         return i_rc->right - i_rc->left;\r
105 }\r
106 \r
107 ///\r
108 inline int rcHeight(const RECT *i_rc)\r
109 {\r
110         return i_rc->bottom - i_rc->top;\r
111 }\r
112 \r
113 ///\r
114 inline bool isRectInRect(const RECT *i_rcin, const RECT *i_rcout)\r
115 {\r
116         return (i_rcout->left <= i_rcin->left &&\r
117                         i_rcin->right <= i_rcout->right &&\r
118                         i_rcout->top <= i_rcin->top &&\r
119                         i_rcin->bottom <= i_rcout->bottom);\r
120 }\r
121 \r
122 \r
123 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
124 // edit control\r
125 \r
126 /// returns bytes of text\r
127 extern size_t editGetTextBytes(HWND i_hwnd);\r
128 \r
129 /// delete a line\r
130 extern void editDeleteLine(HWND i_hwnd, size_t i_n);\r
131 \r
132 /// insert text at last\r
133 extern void editInsertTextAtLast(HWND i_hwnd, const tstring &i_text,\r
134                                                                          size_t i_threshold);\r
135 \r
136 \r
137 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
138 // Windows2000/XP specific API\r
139 \r
140 /// SetLayeredWindowAttributes API\r
141 typedef BOOL (WINAPI *SetLayeredWindowAttributes_t)\r
142 (HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);\r
143 extern SetLayeredWindowAttributes_t setLayeredWindowAttributes;\r
144 \r
145 /// MonitorFromWindow API\r
146 extern HMONITOR (WINAPI *monitorFromWindow)(HWND hwnd, DWORD dwFlags);\r
147 \r
148 /// GetMonitorInfo API\r
149 extern BOOL (WINAPI *getMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO lpmi);\r
150 \r
151 /// EnumDisplayMonitors API\r
152 extern BOOL (WINAPI *enumDisplayMonitors)\r
153         (HDC hdc, LPRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData);\r
154 \r
155 \r
156 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
157 // WindowsXP specific API\r
158 \r
159 /// WTSRegisterSessionNotification API\r
160 typedef BOOL (WINAPI *WTSRegisterSessionNotification_t)\r
161 (HWND hWnd, DWORD dwFlags);\r
162 extern WTSRegisterSessionNotification_t wtsRegisterSessionNotification;\r
163 \r
164 /// WTSUnRegisterSessionNotification API\r
165 typedef BOOL (WINAPI *WTSUnRegisterSessionNotification_t)(HWND hWnd);\r
166 extern WTSUnRegisterSessionNotification_t wtsUnRegisterSessionNotification;\r
167 \r
168 /// WTSGetActiveConsoleSessionId API\r
169 typedef DWORD (WINAPI *WTSGetActiveConsoleSessionId_t)(void);\r
170 extern WTSGetActiveConsoleSessionId_t wtsGetActiveConsoleSessionId;\r
171 \r
172 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
173 // Utility\r
174 \r
175 // PathRemoveFileSpec()\r
176 tstring pathRemoveFileSpec(const tstring &i_path);\r
177 \r
178 // check Windows version i_major.i_minor or later\r
179 BOOL checkWindowsVersion(DWORD i_major, DWORD i_minor);\r
180 \r
181 #endif // _WINDOWSTOOL_H\r