OSDN Git Service

use boost_1_56_0 and build by VS2013
[yamy/yamy.git] / windowstool.h
index bb06975..b307993 100644 (file)
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// windowstool.h
-
-
-#ifndef _WINDOWSTOOL_H
-#  define _WINDOWSTOOL_H
-
-
-#  include "stringtool.h"
-#  include <windows.h>
-
-
-/// instance handle of this application
-extern HINSTANCE g_hInst;
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// resource
-
-/// load resource string
-extern tstring loadString(UINT i_id);
-
-/// load small icon resource (it must be deleted by DestroyIcon())
-extern HICON loadSmallIcon(UINT i_id);
-
-///load big icon resource (it must be deleted by DestroyIcon())
-extern HICON loadBigIcon(UINT i_id);
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// window
-
-/// resize the window (it does not move the window)
-extern bool resizeWindow(HWND i_hwnd, int i_w, int i_h, bool i_doRepaint);
-
-/** get rect of the window in client coordinates.
-    @return rect of the window in client coordinates */
-extern bool getChildWindowRect(HWND i_hwnd, RECT *o_rc);
-
-/** set small icon to the specified window.
-    @return handle of previous icon or NULL */
-extern HICON setSmallIcon(HWND i_hwnd, UINT i_id);
-
-/** set big icon to the specified window.
-    @return handle of previous icon or NULL */
-extern HICON setBigIcon(HWND i_hwnd, UINT i_id);
-
-/// remove icon from a window that is set by setSmallIcon
-extern void unsetSmallIcon(HWND i_hwnd);
-
-/// remove icon from a window that is set by setBigIcon
-extern void unsetBigIcon(HWND i_hwnd);
-
-/// get toplevel (non-child) window
-extern HWND getToplevelWindow(HWND i_hwnd, bool *io_isMDI);
-
-/// move window asynchronously
-extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y);
-
-/// move window asynchronously
-extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y, int i_w, int i_h);
-
-/// resize asynchronously
-extern void asyncResize(HWND i_hwnd, int i_w, int i_h);
-
-/// get dll version
-extern DWORD getDllVersion(const _TCHAR *i_dllname);
-#define PACKVERSION(major, minor) MAKELONG(minor, major)
-
-// workaround of SetForegroundWindow
-extern bool setForegroundWindow(HWND i_hwnd);
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// dialog
-
-/// get/set GWL_USERDATA
-template <class T> inline T getUserData(HWND i_hwnd, T *i_wc)
-{
-#ifdef MAYU64
-  return (*i_wc = reinterpret_cast<T>(GetWindowLongPtr(i_hwnd, GWLP_USERDATA)));
-#else
-  return (*i_wc = reinterpret_cast<T>(GetWindowLong(i_hwnd, GWL_USERDATA)));
-#endif
-}
-
-///
-template <class T> inline T setUserData(HWND i_hwnd, T i_wc)
-{
-#ifdef MAYU64
-  SetWindowLongPtr(i_hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(i_wc));
-#else
-  SetWindowLong(i_hwnd, GWL_USERDATA, reinterpret_cast<long>(i_wc));
-#endif
-  return i_wc;
-}
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// RECT
-
-///
-inline int rcWidth(const RECT *i_rc) { return i_rc->right - i_rc->left; }
-
-///
-inline int rcHeight(const RECT *i_rc) { return i_rc->bottom - i_rc->top; }
-
-///
-inline bool isRectInRect(const RECT *i_rcin, const RECT *i_rcout)
-{
-  return (i_rcout->left <= i_rcin->left &&
-         i_rcin->right <= i_rcout->right &&
-         i_rcout->top <= i_rcin->top &&
-         i_rcin->bottom <= i_rcout->bottom);
-}
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// edit control
-
-/// returns bytes of text
-extern size_t editGetTextBytes(HWND i_hwnd);
-
-/// delete a line
-extern void editDeleteLine(HWND i_hwnd, size_t i_n);
-
-/// insert text at last
-extern void editInsertTextAtLast(HWND i_hwnd, const tstring &i_text,
-                                size_t i_threshold);
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// Windows2000/XP specific API
-
-/// SetLayeredWindowAttributes API
-typedef BOOL (WINAPI *SetLayeredWindowAttributes_t)
-  (HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
-extern SetLayeredWindowAttributes_t setLayeredWindowAttributes;
-
-/// MonitorFromWindow API
-extern HMONITOR (WINAPI *monitorFromWindow)(HWND hwnd, DWORD dwFlags);
-
-/// GetMonitorInfo API
-extern BOOL (WINAPI *getMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO lpmi);
-
-/// EnumDisplayMonitors API
-extern BOOL (WINAPI *enumDisplayMonitors)
-  (HDC hdc, LPRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData);
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// WindowsXP specific API
-
-/// WTSRegisterSessionNotification API
-typedef BOOL (WINAPI *WTSRegisterSessionNotification_t)
-  (HWND hWnd, DWORD dwFlags);
-extern WTSRegisterSessionNotification_t wtsRegisterSessionNotification;
-
-/// WTSUnRegisterSessionNotification API
-typedef BOOL (WINAPI *WTSUnRegisterSessionNotification_t)(HWND hWnd);
-extern WTSUnRegisterSessionNotification_t wtsUnRegisterSessionNotification;
-
-/// WTSGetActiveConsoleSessionId API
-typedef DWORD (WINAPI *WTSGetActiveConsoleSessionId_t)(void);
-extern WTSGetActiveConsoleSessionId_t wtsGetActiveConsoleSessionId;
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// Utility
-
-// PathRemoveFileSpec()
-tstring pathRemoveFileSpec(const tstring &i_path);
-
-
-#endif // _WINDOWSTOOL_H
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// windowstool.h\r
+\r
+\r
+#ifndef _WINDOWSTOOL_H\r
+#  define _WINDOWSTOOL_H\r
+\r
+\r
+#  include "stringtool.h"\r
+#  include <windows.h>\r
+\r
+\r
+/// instance handle of this application\r
+extern HINSTANCE g_hInst;\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// resource\r
+\r
+/// load resource string\r
+extern tstring loadString(UINT i_id);\r
+\r
+/// load small icon resource (it must be deleted by DestroyIcon())\r
+extern HICON loadSmallIcon(UINT i_id);\r
+\r
+///load big icon resource (it must be deleted by DestroyIcon())\r
+extern HICON loadBigIcon(UINT i_id);\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// window\r
+\r
+/// resize the window (it does not move the window)\r
+extern bool resizeWindow(HWND i_hwnd, int i_w, int i_h, bool i_doRepaint);\r
+\r
+/** get rect of the window in client coordinates.\r
+    @return rect of the window in client coordinates */\r
+extern bool getChildWindowRect(HWND i_hwnd, RECT *o_rc);\r
+\r
+/** set small icon to the specified window.\r
+    @return handle of previous icon or NULL */\r
+extern HICON setSmallIcon(HWND i_hwnd, UINT i_id);\r
+\r
+/** set big icon to the specified window.\r
+    @return handle of previous icon or NULL */\r
+extern HICON setBigIcon(HWND i_hwnd, UINT i_id);\r
+\r
+/// remove icon from a window that is set by setSmallIcon\r
+extern void unsetSmallIcon(HWND i_hwnd);\r
+\r
+/// remove icon from a window that is set by setBigIcon\r
+extern void unsetBigIcon(HWND i_hwnd);\r
+\r
+/// get toplevel (non-child) window\r
+extern HWND getToplevelWindow(HWND i_hwnd, bool *io_isMDI);\r
+\r
+/// move window asynchronously\r
+extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y);\r
+\r
+/// move window asynchronously\r
+extern void asyncMoveWindow(HWND i_hwnd, int i_x, int i_y, int i_w, int i_h);\r
+\r
+/// resize asynchronously\r
+extern void asyncResize(HWND i_hwnd, int i_w, int i_h);\r
+\r
+/// get dll version\r
+extern DWORD getDllVersion(const _TCHAR *i_dllname);\r
+#define PACKVERSION(major, minor) MAKELONG(minor, major)\r
+\r
+// workaround of SetForegroundWindow\r
+extern bool setForegroundWindow(HWND i_hwnd);\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// dialog\r
+\r
+/// get/set GWL_USERDATA\r
+template <class T> inline T getUserData(HWND i_hwnd, T *i_wc)\r
+{\r
+#ifdef MAYU64\r
+       return (*i_wc = reinterpret_cast<T>(GetWindowLongPtr(i_hwnd, GWLP_USERDATA)));\r
+#else\r
+       return (*i_wc = reinterpret_cast<T>(GetWindowLong(i_hwnd, GWL_USERDATA)));\r
+#endif\r
+}\r
+\r
+///\r
+template <class T> inline T setUserData(HWND i_hwnd, T i_wc)\r
+{\r
+#ifdef MAYU64\r
+       SetWindowLongPtr(i_hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(i_wc));\r
+#else\r
+       SetWindowLong(i_hwnd, GWL_USERDATA, reinterpret_cast<long>(i_wc));\r
+#endif\r
+       return i_wc;\r
+}\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// RECT\r
+\r
+///\r
+inline int rcWidth(const RECT *i_rc)\r
+{\r
+       return i_rc->right - i_rc->left;\r
+}\r
+\r
+///\r
+inline int rcHeight(const RECT *i_rc)\r
+{\r
+       return i_rc->bottom - i_rc->top;\r
+}\r
+\r
+///\r
+inline bool isRectInRect(const RECT *i_rcin, const RECT *i_rcout)\r
+{\r
+       return (i_rcout->left <= i_rcin->left &&\r
+                       i_rcin->right <= i_rcout->right &&\r
+                       i_rcout->top <= i_rcin->top &&\r
+                       i_rcin->bottom <= i_rcout->bottom);\r
+}\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// edit control\r
+\r
+/// returns bytes of text\r
+extern size_t editGetTextBytes(HWND i_hwnd);\r
+\r
+/// delete a line\r
+extern void editDeleteLine(HWND i_hwnd, size_t i_n);\r
+\r
+/// insert text at last\r
+extern void editInsertTextAtLast(HWND i_hwnd, const tstring &i_text,\r
+                                                                        size_t i_threshold);\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// Windows2000/XP specific API\r
+\r
+/// SetLayeredWindowAttributes API\r
+typedef BOOL (WINAPI *SetLayeredWindowAttributes_t)\r
+(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);\r
+extern SetLayeredWindowAttributes_t setLayeredWindowAttributes;\r
+\r
+/// MonitorFromWindow API\r
+extern HMONITOR (WINAPI *monitorFromWindow)(HWND hwnd, DWORD dwFlags);\r
+\r
+/// GetMonitorInfo API\r
+extern BOOL (WINAPI *getMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO lpmi);\r
+\r
+/// EnumDisplayMonitors API\r
+extern BOOL (WINAPI *enumDisplayMonitors)\r
+       (HDC hdc, LPRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData);\r
+\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// WindowsXP specific API\r
+\r
+/// WTSRegisterSessionNotification API\r
+typedef BOOL (WINAPI *WTSRegisterSessionNotification_t)\r
+(HWND hWnd, DWORD dwFlags);\r
+extern WTSRegisterSessionNotification_t wtsRegisterSessionNotification;\r
+\r
+/// WTSUnRegisterSessionNotification API\r
+typedef BOOL (WINAPI *WTSUnRegisterSessionNotification_t)(HWND hWnd);\r
+extern WTSUnRegisterSessionNotification_t wtsUnRegisterSessionNotification;\r
+\r
+/// WTSGetActiveConsoleSessionId API\r
+typedef DWORD (WINAPI *WTSGetActiveConsoleSessionId_t)(void);\r
+extern WTSGetActiveConsoleSessionId_t wtsGetActiveConsoleSessionId;\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// Utility\r
+\r
+// PathRemoveFileSpec()\r
+tstring pathRemoveFileSpec(const tstring &i_path);\r
+\r
+// check Windows version i_major.i_minor or later\r
+BOOL checkWindowsVersion(DWORD i_major, DWORD i_minor);\r
+\r
+#endif // _WINDOWSTOOL_H\r