1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 # define _WINDOWSTOOL_H
9 # include "stringtool.h"
13 /// instance handle of this application
14 extern HINSTANCE g_hInst;
17 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 /// load resource string
21 extern tstring loadString(UINT i_id);
23 /// load small icon resource (it must be deleted by DestroyIcon())
24 extern HICON loadSmallIcon(UINT i_id);
26 ///load big icon resource (it must be deleted by DestroyIcon())
27 extern HICON loadBigIcon(UINT i_id);
30 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33 /// resize the window (it does not move the window)
34 extern bool resizeWindow(HWND i_hwnd, int i_w, int i_h, bool i_doRepaint);
36 /** get rect of the window in client coordinates.
37 @return rect of the window in client coordinates */
38 extern bool getChildWindowRect(HWND i_hwnd, RECT *o_rc);
40 /** set small icon to the specified window.
41 @return handle of previous icon or NULL */
42 extern HICON setSmallIcon(HWND i_hwnd, UINT i_id);
44 /** set big icon to the specified window.
45 @return handle of previous icon or NULL */
46 extern HICON setBigIcon(HWND i_hwnd, UINT i_id);
48 /// remove icon from a window that is set by setSmallIcon
49 extern void unsetSmallIcon(HWND i_hwnd);
51 /// remove icon from a window that is set by setBigIcon
52 extern void unsetBigIcon(HWND i_hwnd);
54 /// get toplevel (non-child) window
55 extern HWND getToplevelWindow(HWND i_hwnd, bool *io_isMDI);
57 /// move window asynchronously
58 extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y);
60 /// move window asynchronously
61 extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y, int i_w, int i_h);
63 /// resize asynchronously
64 extern void asyncResize(HWND i_hwnd, int i_w, int i_h);
67 extern DWORD getDllVersion(const _TCHAR *i_dllname);
68 #define PACKVERSION(major, minor) MAKELONG(minor, major)
70 // workaround of SetForegroundWindow
71 extern bool setForegroundWindow(HWND i_hwnd);
73 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 /// get/set GWL_USERDATA
77 template <class T> inline T getUserData(HWND i_hwnd, T *i_wc)
79 return (*i_wc = reinterpret_cast<T>(GetWindowLong(i_hwnd, GWL_USERDATA)));
83 template <class T> inline T setUserData(HWND i_hwnd, T i_wc)
85 SetWindowLong(i_hwnd, GWL_USERDATA, reinterpret_cast<long>(i_wc));
90 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94 inline int rcWidth(const RECT *i_rc) { return i_rc->right - i_rc->left; }
97 inline int rcHeight(const RECT *i_rc) { return i_rc->bottom - i_rc->top; }
100 inline bool isRectInRect(const RECT *i_rcin, const RECT *i_rcout)
102 return (i_rcout->left <= i_rcin->left &&
103 i_rcin->right <= i_rcout->right &&
104 i_rcout->top <= i_rcin->top &&
105 i_rcin->bottom <= i_rcout->bottom);
109 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112 /// returns bytes of text
113 extern size_t editGetTextBytes(HWND i_hwnd);
116 extern void editDeleteLine(HWND i_hwnd, size_t i_n);
118 /// insert text at last
119 extern void editInsertTextAtLast(HWND i_hwnd, const tstring &i_text,
123 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124 // Windows2000/XP specific API
126 /// SetLayeredWindowAttributes API
127 typedef BOOL (WINAPI *SetLayeredWindowAttributes_t)
128 (HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
129 extern SetLayeredWindowAttributes_t setLayeredWindowAttributes;
131 /// MonitorFromWindow API
132 extern HMONITOR (WINAPI *monitorFromWindow)(HWND hwnd, DWORD dwFlags);
134 /// GetMonitorInfo API
135 extern BOOL (WINAPI *getMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO lpmi);
137 /// EnumDisplayMonitors API
138 extern BOOL (WINAPI *enumDisplayMonitors)
139 (HDC hdc, LPRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData);
142 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143 // WindowsXP specific API
145 /// WTSRegisterSessionNotification API
146 typedef BOOL (WINAPI *WTSRegisterSessionNotification_t)
147 (HWND hWnd, DWORD dwFlags);
148 extern WTSRegisterSessionNotification_t wtsRegisterSessionNotification;
150 /// WTSUnRegisterSessionNotification API
151 typedef BOOL (WINAPI *WTSUnRegisterSessionNotification_t)(HWND hWnd);
152 extern WTSUnRegisterSessionNotification_t wtsUnRegisterSessionNotification;
154 /// WTSGetActiveConsoleSessionId API
155 typedef DWORD (WINAPI *WTSGetActiveConsoleSessionId_t)(void);
156 extern WTSGetActiveConsoleSessionId_t wtsGetActiveConsoleSessionId;
158 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161 // PathRemoveFileSpec()
162 tstring pathRemoveFileSpec(const tstring &i_path);
165 #endif // _WINDOWSTOOL_H