1 // Win32++ Version 7.3
\r
2 // Released: 30th November 2011
\r
6 // url: https://sourceforge.net/projects/win32-framework
\r
9 // Copyright (c) 2005-2011 David Nash
\r
11 // Permission is hereby granted, free of charge, to
\r
12 // any person obtaining a copy of this software and
\r
13 // associated documentation files (the "Software"),
\r
14 // to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify,
\r
16 // merge, publish, distribute, sublicense, and/or sell
\r
17 // copies of the Software, and to permit persons to whom
\r
18 // the Software is furnished to do so, subject to the
\r
19 // following conditions:
\r
21 // The above copyright notice and this permission notice
\r
22 // shall be included in all copies or substantial portions
\r
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
\r
26 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
\r
27 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
\r
28 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
\r
29 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
\r
30 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
31 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
32 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
\r
33 // OR OTHER DEALINGS IN THE SOFTWARE.
\r
35 ////////////////////////////////////////////////////////
\r
37 #ifndef _WIN32XX_WINUTILS_H_
\r
38 #define _WIN32XX_WINUTILS_H_
\r
41 // define useful macros from WindowsX.h
\r
42 #ifndef GET_X_LPARAM
\r
43 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
\r
45 #ifndef GET_Y_LPARAM
\r
46 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
\r
49 // Define our own MIN and MAX macros
\r
50 // this avoids inconsistencies with Dev-C++ and other compilers, and
\r
51 // avoids conflicts between typical min/max macros and std::min/std::max
\r
52 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
\r
53 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
\r
58 // Forward declarations
\r
62 void TRACE(LPCTSTR str);
\r
65 /////////////////////////////////////////
\r
66 // Definition of the CSize class
\r
67 // This class can be used to replace the SIZE structure
\r
68 class CSize : public SIZE
\r
71 CSize() { cx = 0; cy = 0; }
\r
72 CSize(int CX, int CY) { cx = CX; cy = CY; }
\r
73 CSize(SIZE sz) { cx = sz.cx; cy = sz.cy; }
\r
74 CSize(POINT pt) { cx = pt.x; cy = pt.y; }
\r
75 CSize(DWORD dw) { cx = (short)LOWORD(dw); cy = (short)HIWORD(dw); }
\r
76 void SetSize(int CX, int CY) { cx = CX; cy = CY; }
\r
79 operator LPSIZE() { return this; }
\r
80 BOOL operator == (SIZE sz) const { return (cx == sz.cx && cy == sz.cy); }
\r
81 BOOL operator != (SIZE sz) const { return (cx != sz.cx || cy != sz.cy); }
\r
82 void operator += (SIZE sz) { cx += sz.cx; cy += sz.cy; }
\r
83 void operator -= (SIZE sz) { cx -= sz.cx; cy -= sz.cy; }
\r
85 // Operators returning CSize
\r
86 CSize operator - () const { return CSize (-cx, -cy); }
\r
87 CSize operator + (SIZE sz) const { return CSize (cx + sz.cx, cy + sz.cy); }
\r
88 CSize operator - (SIZE sz) const { return CSize (cx - sz.cx, cy - sz.cy); }
\r
90 // Operators returning CPoint
\r
91 CPoint operator + (POINT point) const;
\r
92 CPoint operator - (POINT point) const;
\r
94 // Operators returning CRect
\r
95 CRect operator + (RECT rc) const;
\r
96 CRect operator - (RECT rc) const;
\r
100 /////////////////////////////////////////
\r
101 // Definition of the CPoint class
\r
102 // This class can be used to replace the POINT structure
\r
103 class CPoint : public POINT
\r
106 CPoint() { x = 0; y = 0; }
\r
107 CPoint(int X, int Y) { x = X; y = Y; }
\r
108 CPoint(POINT pt) { x = pt.x ; y = pt.y; }
\r
109 CPoint(POINTS pts) { x = pts.x; y = pts.y; }
\r
110 CPoint(SIZE sz) { x = sz.cx; y = sz.cy; }
\r
111 CPoint(DWORD dw) { x = (short) LOWORD(dw); y = (short) HIWORD(dw); }
\r
113 void Offset(int dx, int dy) { x += dx; y += dy; }
\r
114 void Offset(POINT pt) { x += pt.x; y += pt.y; }
\r
115 void Offset(SIZE sz) { x += sz.cx; y += sz.cy; }
\r
116 void SetPoint(int X, int Y) { x = X; y = Y; }
\r
119 operator LPPOINT() { return this; }
\r
120 BOOL operator == (POINT pt) const { return ((x == pt.x) && (y == pt.y)); }
\r
121 BOOL operator != (POINT pt) const { return ((x != pt.x) || (y != pt.y)); }
\r
122 void operator += (SIZE sz) { x += sz.cx; y += sz.cy; }
\r
123 void operator -= (SIZE sz) { x -= sz.cx; y -= sz.cy; }
\r
124 void operator += (POINT pt) { x += pt.x; y += pt.y; }
\r
125 void operator -= (POINT pt) { x -= pt.x; y -= pt.y; }
\r
127 // Operators returning CPoint
\r
128 CPoint operator - () const { return CPoint(-x, -y); }
\r
129 CPoint operator + (SIZE sz) const { return CPoint(x + sz.cx, y + sz.cy); }
\r
130 CPoint operator - (SIZE sz) const { return CPoint(x - sz.cx, y - sz.cy); }
\r
131 CPoint operator + (POINT pt) const { return CPoint(x + pt.x, y + pt.y); }
\r
132 CPoint operator - (POINT pt) const { return CPoint(x - pt.x, y - pt.y); }
\r
134 // Operators returning CRect
\r
135 CRect operator + (RECT rc) const;
\r
136 CRect operator - (RECT rc) const;
\r
140 /////////////////////////////////////////
\r
141 // Definition of the CRect class
\r
142 // This class can be used to replace the RECT structure.
\r
143 class CRect : public RECT
\r
146 CRect() { left = top = right = bottom = 0; }
\r
147 CRect(int l, int t, int r, int b) { left = l; top = t; right = r; bottom = b; }
\r
148 CRect(RECT rc) { left = rc.left; top = rc.top; right = rc.right; bottom = rc.bottom; }
\r
149 CRect(POINT pt, SIZE sz) { right = (left = pt.x) + sz.cx; bottom = (top = pt.y) + sz.cy; }
\r
150 CRect(POINT topLeft, POINT bottomRight) { left = topLeft.x; top = topLeft.y; right = bottomRight.x; bottom = bottomRight.y; }
\r
152 BOOL CopyRect(RECT rc) { return ::CopyRect(this, &rc); }
\r
153 BOOL DeflateRect(int x, int y) { return ::InflateRect(this, -x, -y); }
\r
154 BOOL DeflateRect(SIZE size) { return ::InflateRect(this, -size.cx, -size.cy); }
\r
155 BOOL DeflateRect(RECT rc) { return ::InflateRect(this, rc.left - rc.right, rc.top - rc.bottom); }
\r
156 BOOL DeflateRect(int l, int t, int r, int b){ return ::InflateRect(this, l - r, t - b); }
\r
157 BOOL EqualRect(RECT rc) const { return ::EqualRect(&rc, this); }
\r
158 BOOL InflateRect(int dx, int dy) { return ::InflateRect(this, dx, dy); }
\r
159 BOOL InflateRect(SIZE sz) { return ::InflateRect(this, sz.cx, sz.cy); }
\r
160 BOOL InflateRect(RECT rc) { return ::InflateRect(this, rc.right - rc.left, rc.bottom - rc.top); }
\r
161 BOOL InflateRect(int l, int t, int r, int b){ return ::InflateRect(this, r - l, b - t); }
\r
162 BOOL IntersectRect(RECT rc1, RECT rc2) { return ::IntersectRect(this, &rc1, &rc2); }
\r
163 BOOL IsRectEmpty() const { return ::IsRectEmpty(this);}
\r
164 BOOL IsRectNull() const { return (left == 0 && right == 0 && top == 0 && bottom == 0); }
\r
165 CRect MulDiv(int nMult, int nDiv) const { return CRect ((left * nMult) / nDiv, (top * nMult) / nDiv,
\r
166 (right * nMult) / nDiv, (bottom * nMult) / nDiv); }
\r
167 void NormalizeRect() { int nTemp; if (left > right) { nTemp = left; left = right; right = nTemp; }
\r
168 if (top > bottom) { nTemp = top; top = bottom; bottom = nTemp; } }
\r
169 BOOL OffsetRect(int dx, int dy) { return ::OffsetRect(this, dx, dy); }
\r
170 BOOL OffsetRect(POINT pt) { return ::OffsetRect(this, pt.x, pt.y); }
\r
171 BOOL OffsetRect(SIZE size) { return ::OffsetRect(this, size.cx, size.cy); }
\r
172 BOOL PtInRect(POINT pt) const { return ::PtInRect(this, pt); }
\r
173 BOOL SetRect(int l, int t, int r, int b) { return ::SetRect(this, l, t, r, b); }
\r
174 BOOL SetRect(POINT TopLeft, POINT BtmRight) { return ::SetRect(this, TopLeft.x, TopLeft.y, BtmRight.x, BtmRight.y); }
\r
175 BOOL SetRectEmpty() { return ::SetRectEmpty(this); }
\r
176 BOOL SubtractRect(RECT rc1, RECT rc2) { return ::SubtractRect(this, &rc1, &rc2); }
\r
177 BOOL UnionRect(RECT rc1, RECT rc2) { return ::UnionRect(this, &rc1, &rc2); }
\r
179 // Reposition rectangle
\r
180 void MoveToX (int x) { right = Width() + x; left = x; }
\r
181 void MoveToY (int y) { bottom = Height() + y; top = y; }
\r
182 void MoveToXY (int x, int y) { MoveToX(x); MoveToY(y); }
\r
183 void MoveToXY (POINT pt) { MoveToX (pt.x); MoveToY (pt.y); }
\r
186 int Height() const { return bottom - top; }
\r
187 int Width() const { return right - left; }
\r
188 CSize Size() const { return CSize(Width(), Height()); }
\r
189 CPoint CenterPoint() const { return CPoint((left + right) / 2, (top + bottom) / 2); }
\r
190 CPoint TopLeft() const { return CPoint(left, top); }
\r
191 CPoint BottomRight() const { return CPoint(right, bottom); }
\r
194 operator LPRECT() { return this; }
\r
195 BOOL operator == (RECT rc) const { return ::EqualRect(this, &rc); }
\r
196 BOOL operator != (RECT rc) const { return !::EqualRect(this, &rc); }
\r
197 void operator += (POINT pt) { ::OffsetRect(this, pt.x, pt.y); }
\r
198 void operator += (SIZE size) { ::OffsetRect(this, size.cx, size.cy); }
\r
199 void operator += (RECT rc) { ::InflateRect(this, rc.right - rc.left, rc.bottom - rc.top); }
\r
200 void operator -= (RECT rc) { ::InflateRect(this, rc.left - rc.right, rc.top - rc.bottom); }
\r
201 void operator -= (POINT pt) { ::OffsetRect(this, -pt.x, -pt.y); }
\r
202 void operator -= (SIZE sz) { ::OffsetRect(this, -sz.cx, -sz.cy); }
\r
203 void operator &= (RECT rc) { ::IntersectRect(this, this, &rc); }
\r
204 void operator |= (RECT rc) { ::UnionRect(this, this, &rc); }
\r
206 // Operators returning CRect
\r
207 CRect operator + (POINT pt) const { CRect rc(*this); ::OffsetRect(&rc, pt.x, pt.y); return rc; }
\r
208 CRect operator - (POINT pt) const { CRect rc(*this); ::OffsetRect(&rc, -pt.x, -pt.y); return rc; }
\r
209 CRect operator + (SIZE sz) const { CRect rc(*this); ::OffsetRect(&rc, sz.cx, sz.cy); return rc; }
\r
210 CRect operator - (SIZE sz) const { CRect rc(*this); ::OffsetRect(&rc, -sz.cx, -sz.cy); return rc; }
\r
211 CRect operator + (RECT rc) const { CRect rc1(*this); rc1.InflateRect(rc); return rc1; }
\r
212 CRect operator - (RECT rc) const { CRect rc1(*this); rc1.DeflateRect(rc); return rc1; }
\r
213 CRect operator & (RECT rc) const { CRect rc1; ::IntersectRect(&rc1, this, &rc); return rc1; }
\r
214 CRect operator | (RECT rc) const { CRect rc1; ::UnionRect(&rc1, this, &rc); return rc1; }
\r
217 // CSize member function definitions
\r
218 inline CPoint CSize::operator + (POINT pt) const { return CPoint(pt) + *this; }
\r
219 inline CPoint CSize::operator - (POINT pt) const { return CPoint(pt) - *this; }
\r
220 inline CRect CSize::operator + (RECT rc) const { return CRect(rc) + *this; }
\r
221 inline CRect CSize::operator - (RECT rc) const { return CRect(rc) - *this; }
\r
223 // CPoint member function definitions
\r
224 inline CRect CPoint::operator + (RECT rc) const { return CRect(rc) + *this; }
\r
225 inline CRect CPoint::operator - (RECT rc) const { return CRect(rc) - *this; }
\r
228 ////////////////////////////////////////////////////////
\r
229 // Classes and functions (typedefs) for text conversions
\r
231 // This section defines the following text conversions:
\r
232 // A2BSTR ANSI to BSTR
\r
233 // A2OLE ANSI to OLE
\r
234 // A2T ANSI to TCHAR
\r
235 // A2W ANSI to WCHAR
\r
236 // OLE2A OLE to ANSI
\r
237 // OLE2T OLE to TCHAR
\r
238 // OLE2W OLE to WCHAR
\r
239 // T2A TCHAR to ANSI
\r
240 // T2BSTR TCHAR to BSTR
\r
241 // T2OLE TCHAR to OLE
\r
242 // T2W TCHAR to WCHAR
\r
243 // W2A WCHAR to ANSI
\r
244 // W2BSTR WCHAR to BSTR
\r
245 // W2OLE WCHAR to OLE
\r
246 // W2T WCHAR to TCHAR
\r
248 // About different character and string types:
\r
249 // ------------------------------------------
\r
250 // char (or CHAR) character types are ANSI (8 bits).
\r
251 // wchar_t (or WCHAR) character types are Unicode (16 bits).
\r
252 // TCHAR characters are Unicode if the _UNICODE macro is defined, otherwise they are ANSI.
\r
253 // BSTR (Basic String) is a type of string used in Visual Basic and COM programming.
\r
254 // OLE is the same as WCHAR. It is used in Visual Basic and COM programming.
\r
257 // Forward declarations of our classes. They are defined later.
\r
265 // typedefs for the well known text conversions
\r
268 typedef CW2BSTR W2BSTR;
\r
269 typedef CA2BSTR A2BSTR;
\r
270 typedef CW2A BSTR2A;
\r
271 typedef CW2W BSTR2W;
\r
278 typedef CW2BSTR T2BSTR;
\r
279 typedef BSTR2W BSTR2T;
\r
285 typedef CA2BSTR T2BSTR;
\r
286 typedef BSTR2A BSTR2T;
\r
291 typedef CW2W W2OLE;
\r
294 typedef CW2W OLE2W;
\r
299 CA2W(LPCSTR pStr) : m_pStr(pStr)
\r
303 // Resize the vector and assign null WCHAR to each element
\r
304 int length = (int)strlen(pStr)+1;
\r
305 m_vWideArray.assign(length, L'\0');
\r
307 // Fill our vector with the converted WCHAR array
\r
308 MultiByteToWideChar(CP_ACP, 0, pStr, -1, &m_vWideArray[0], length);
\r
312 operator LPCWSTR() { return m_pStr? &m_vWideArray[0] : NULL; }
\r
313 operator LPOLESTR() { return m_pStr? (LPOLESTR)&m_vWideArray[0] : (LPOLESTR)NULL; }
\r
317 CA2W& operator= (const CA2W&);
\r
318 std::vector<wchar_t> m_vWideArray;
\r
325 CW2A(LPCWSTR pWStr) : m_pWStr(pWStr)
\r
327 // Resize the vector and assign null char to each element
\r
328 int length = (int)wcslen(pWStr)+1;
\r
329 m_vAnsiArray.assign(length, '\0');
\r
331 // Fill our vector with the converted char array
\r
332 WideCharToMultiByte(CP_ACP, 0, pWStr, -1, &m_vAnsiArray[0], length, NULL,NULL);
\r
336 operator LPCSTR() { return m_pWStr? &m_vAnsiArray[0] : NULL; }
\r
340 CW2A& operator= (const CW2A&);
\r
341 std::vector<char> m_vAnsiArray;
\r
348 CW2W(LPCWSTR pWStr) : m_pWStr(pWStr) {}
\r
349 operator LPCWSTR() { return (LPWSTR)m_pWStr; }
\r
350 operator LPOLESTR() { return (LPOLESTR)m_pWStr; }
\r
354 CW2W& operator= (const CW2W&);
\r
362 CA2A(LPCSTR pStr) : m_pStr(pStr) {}
\r
363 operator LPCSTR() { return (LPSTR)m_pStr; }
\r
367 CA2A& operator= (const CA2A&);
\r
375 CW2BSTR(LPCWSTR pWStr) { m_bstrString = ::SysAllocString(pWStr); }
\r
376 ~CW2BSTR() { ::SysFreeString(m_bstrString); }
\r
377 operator BSTR() { return m_bstrString;}
\r
380 CW2BSTR(const CW2BSTR&);
\r
381 CW2BSTR& operator= (const CW2BSTR&);
\r
388 CA2BSTR(LPCSTR pStr) { m_bstrString = ::SysAllocString(A2W(pStr)); }
\r
389 ~CA2BSTR() { ::SysFreeString(m_bstrString); }
\r
390 operator BSTR() { return m_bstrString;}
\r
393 CA2BSTR(const CA2BSTR&);
\r
394 CA2BSTR& operator= (const CA2BSTR&);
\r
399 ////////////////////////////////////////
\r
400 // Global Functions
\r
403 inline CWnd* FromHandle(HWND hWnd)
\r
404 // Returns the CWnd object associated with the window handle
\r
406 assert( GetApp() );
\r
407 CWnd* pWnd = hWnd? GetApp()->GetCWndFromMap(hWnd) : 0;
\r
408 if ( hWnd != NULL && pWnd == 0 )
\r
410 GetApp()->AddTmpWnd(hWnd);
\r
411 pWnd = GetApp()->GetCWndFromMap(hWnd);
\r
412 ::PostMessage(hWnd, UWM_CLEANUPTEMPS, 0, 0);
\r
419 inline CWinApp* GetApp()
\r
420 // Returns a pointer to the CWinApp derrived class
\r
422 return CWinApp::SetnGetThis();
\r
425 inline CPoint GetCursorPos()
\r
428 ::GetCursorPos(&pt);
\r
432 inline HBITMAP LoadBitmap (LPCTSTR lpszName)
\r
436 HBITMAP hBitmap = (HBITMAP)::LoadImage (GetApp()->GetResourceHandle(), lpszName, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
\r
440 inline HBITMAP LoadBitmap (int nID)
\r
442 return LoadBitmap(MAKEINTRESOURCE(nID));
\r
446 inline void TRACE(LPCTSTR str)
\r
447 // TRACE sends a string to the debug/output pane, or an external debugger
\r
450 OutputDebugString(str);
\r
452 UNREFERENCED_PARAMETER(str); // no-op
\r
456 #ifndef _WIN32_WCE // for Win32/64 operating systems, not WinCE
\r
458 inline int GetWinVersion()
\r
460 DWORD dwVersion = GetVersion();
\r
461 int Platform = (dwVersion < 0x80000000)? 2:1;
\r
462 int MajorVer = LOBYTE(LOWORD(dwVersion));
\r
463 int MinorVer = HIBYTE(LOWORD(dwVersion));
\r
465 int nVersion = 1000*Platform + 100*MajorVer + MinorVer;
\r
467 // Return values and window versions:
\r
472 // 2500 Windows 2000
\r
474 // 2502 Windows Server 2003
\r
475 // 2600 Windows Vista and Windows Server 2008
\r
481 inline int GetComCtlVersion()
\r
483 // Load the Common Controls DLL
\r
484 HMODULE hComCtl = ::LoadLibraryA("COMCTL32.DLL");
\r
488 int ComCtlVer = 400;
\r
490 if (::GetProcAddress(hComCtl, "InitCommonControlsEx"))
\r
492 // InitCommonControlsEx is unique to 4.7 and later
\r
495 if (::GetProcAddress(hComCtl, "DllGetVersion"))
\r
497 typedef HRESULT CALLBACK DLLGETVERSION(DLLVERSIONINFO*);
\r
498 DLLGETVERSION* pfnDLLGetVersion = NULL;
\r
500 pfnDLLGetVersion = (DLLGETVERSION*)::GetProcAddress(hComCtl, "DllGetVersion");
\r
501 if(pfnDLLGetVersion)
\r
503 DLLVERSIONINFO dvi;
\r
504 dvi.cbSize = sizeof dvi;
\r
505 if(NOERROR == pfnDLLGetVersion(&dvi))
\r
507 DWORD dwVerMajor = dvi.dwMajorVersion;
\r
508 DWORD dwVerMinor = dvi.dwMinorVersion;
\r
509 ComCtlVer = 100 * dwVerMajor + dwVerMinor;
\r
513 else if (::GetProcAddress(hComCtl, "InitializeFlatSB"))
\r
514 ComCtlVer = 471; // InitializeFlatSB is unique to version 4.71
\r
517 ::FreeLibrary(hComCtl);
\r
519 // return values and DLL versions
\r
520 // 400 dll ver 4.00 Windows 95/Windows NT 4.0
\r
521 // 470 dll ver 4.70 Internet Explorer 3.x
\r
522 // 471 dll ver 4.71 Internet Explorer 4.0
\r
523 // 472 dll ver 4.72 Internet Explorer 4.01 and Windows 98
\r
524 // 580 dll ver 5.80 Internet Explorer 5
\r
525 // 581 dll ver 5.81 Windows 2000 and Windows ME
\r
526 // 582 dll ver 5.82 Windows XP or Vista without XP themes
\r
527 // 600 dll ver 6.00 Windows XP with XP themes
\r
528 // 610 dll ver 6.10 Windows Vista with XP themes
\r
529 // 616 dll ver 6.16 Windows Vista SP1 or Windows 7 with XP themes
\r
534 inline UINT GetSizeofMenuItemInfo()
\r
536 UINT uSize = sizeof(MENUITEMINFO);
\r
537 // For Win95 and NT, cbSize needs to be 44
\r
538 if (1400 == (GetWinVersion()) || (2400 == GetWinVersion()))
\r
544 inline UINT GetSizeofNonClientMetrics()
\r
546 // This function correctly determines the sizeof NONCLIENTMETRICS
\r
547 UINT uSize = sizeof (NONCLIENTMETRICS);
\r
549 #if (WINVER >= 0x0600)
\r
550 if (GetWinVersion() < 2600 && (uSize > 500)) // Is OS version less than Vista
\r
551 uSize -= sizeof(int); // Adjust size back to correct value
\r
559 // A global function to report the state of the left mouse button
\r
560 inline BOOL IsLeftButtonDown()
\r
563 if (GetSystemMetrics(SM_SWAPBUTTON))
\r
564 // Mouse buttons are swapped
\r
565 state = GetAsyncKeyState(VK_RBUTTON);
\r
567 // Mouse buttons are not swapped
\r
568 state = GetAsyncKeyState(VK_LBUTTON);
\r
570 // returns true if the left mouse button is down
\r
571 return (state & 0x8000);
\r
574 inline BOOL IsAeroThemed()
\r
576 BOOL bIsAeroThemed = FALSE;
\r
578 // Test if Windows version is XP or greater
\r
579 if (GetWinVersion() >= 2501)
\r
581 HMODULE hMod = ::LoadLibrary(_T("uxtheme.dll"));
\r
584 // Declare pointers to IsCompositionActive function
\r
585 FARPROC pIsCompositionActive = ::GetProcAddress(hMod, "IsCompositionActive");
\r
587 if(pIsCompositionActive)
\r
589 if(pIsCompositionActive())
\r
591 bIsAeroThemed = TRUE;
\r
594 ::FreeLibrary(hMod);
\r
598 return bIsAeroThemed;
\r
601 inline BOOL IsXPThemed()
\r
603 BOOL bIsXPThemed = FALSE;
\r
605 // Test if Windows version is XP or greater
\r
606 if (GetWinVersion() >= 2501)
\r
608 HMODULE hMod = ::LoadLibrary(_T("uxtheme.dll"));
\r
611 // Declare pointers to functions
\r
612 FARPROC pIsAppThemed = ::GetProcAddress(hMod, "IsAppThemed");
\r
613 FARPROC pIsThemeActive = ::GetProcAddress(hMod, "IsThemeActive");
\r
615 if(pIsAppThemed && pIsThemeActive)
\r
617 if(pIsAppThemed() && pIsThemeActive())
\r
619 // Test if ComCtl32 dll used is version 6 or later
\r
620 bIsXPThemed = (GetComCtlVersion() >= 600);
\r
623 ::FreeLibrary(hMod);
\r
627 return bIsXPThemed;
\r
630 #endif // #ifndef _WIN32_WCE
\r
632 // Required for WinCE
\r
634 inline LPTSTR lstrcpyn(LPTSTR lpstrDest, LPCTSTR lpstrSrc, int nLength)
\r
636 if(NULL == lpstrDest || NULL == lpstrSrc || nLength <= 0)
\r
638 int nLen = MIN((int)lstrlen(lpstrSrc), nLength - 1);
\r
639 LPTSTR lpstrRet = (LPTSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(TCHAR));
\r
640 lpstrDest[nLen] = _T('\0');
\r
643 #endif // !lstrcpyn
\r
648 #endif // _WIN32XX_WINUTILS_H_
\r