Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: third_party/wtl/include/atluser.h

Issue 703753005: More Windows build fixes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove generated files Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/wtl/include/atltheme.h ('k') | third_party/wtl/include/atlwince.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Windows Template Library - WTL version 8.0
2 // Copyright (C) Microsoft Corporation. All rights reserved.
3 //
4 // This file is a part of the Windows Template Library.
5 // The use and distribution terms for this software are covered by the
6 // Microsoft Permissive License (Ms-PL) which can be found in the file
7 // Ms-PL.txt at the root of this distribution.
8
9 #ifndef __ATLUSER_H__
10 #define __ATLUSER_H__
11
12 #pragma once
13
14 #ifndef __cplusplus
15 #error ATL requires C++ compilation (use a .cpp suffix)
16 #endif
17
18 #ifndef __ATLAPP_H__
19 #error atluser.h requires atlapp.h to be included first
20 #endif
21
22
23 ///////////////////////////////////////////////////////////////////////////////
24 // Classes in this file:
25 //
26 // CMenuItemInfo
27 // CMenuT<t_bManaged>
28 // CAcceleratorT<t_bManaged>
29 // CIconT<t_bManaged>
30 // CCursorT<t_bManaged>
31 // CResource
32 //
33 // Global functions:
34 // AtlMessageBox()
35
36
37 namespace WTL
38 {
39
40 ///////////////////////////////////////////////////////////////////////////////
41 // AtlMessageBox - accepts both memory and resource based strings
42
43 inline int AtlMessageBox(HWND hWndOwner, ATL::_U_STRINGorID message, ATL::_U_STR INGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION)
44 {
45 ATLASSERT(hWndOwner == NULL || ::IsWindow(hWndOwner));
46
47 LPTSTR lpstrMessage = NULL;
48 if(IS_INTRESOURCE(message.m_lpstr))
49 {
50 for(int nLen = 256; ; nLen *= 2)
51 {
52 ATLTRY(lpstrMessage = new TCHAR[nLen]);
53 if(lpstrMessage == NULL)
54 {
55 ATLASSERT(FALSE);
56 return 0;
57 }
58 int nRes = ::LoadString(ModuleHelper::GetResourceInstanc e(), LOWORD(message.m_lpstr), lpstrMessage, nLen);
59 if(nRes < nLen - 1)
60 break;
61 delete [] lpstrMessage;
62 lpstrMessage = NULL;
63 }
64
65 message.m_lpstr = lpstrMessage;
66 }
67
68 LPTSTR lpstrTitle = NULL;
69 if(IS_INTRESOURCE(title.m_lpstr) && LOWORD(title.m_lpstr) != 0)
70 {
71 for(int nLen = 256; ; nLen *= 2)
72 {
73 ATLTRY(lpstrTitle = new TCHAR[nLen]);
74 if(lpstrTitle == NULL)
75 {
76 ATLASSERT(FALSE);
77 return 0;
78 }
79 int nRes = ::LoadString(ModuleHelper::GetResourceInstanc e(), LOWORD(title.m_lpstr), lpstrTitle, nLen);
80 if(nRes < nLen - 1)
81 break;
82 delete [] lpstrTitle;
83 lpstrTitle = NULL;
84 }
85
86 title.m_lpstr = lpstrTitle;
87 }
88
89 int nRet = ::MessageBox(hWndOwner, message.m_lpstr, title.m_lpstr, uType );
90
91 delete [] lpstrMessage;
92 delete [] lpstrTitle;
93
94 return nRet;
95 }
96
97
98 ///////////////////////////////////////////////////////////////////////////////
99 // CMenu
100
101 #if (WINVER >= 0x0500)
102 #ifndef MII_SIZEOF_STRUCT
103 #define MII_SIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structnam e*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member) )
104 #endif
105 #define MENUITEMINFO_SIZE_VERSION_400A MII_SIZEOF_STRUCT(MENUITEMINFOA, cch)
106 #define MENUITEMINFO_SIZE_VERSION_400W MII_SIZEOF_STRUCT(MENUITEMINFOW, cch)
107 #ifdef UNICODE
108 #define MENUITEMINFO_SIZE_VERSION_400 MENUITEMINFO_SIZE_VERSION_400W
109 #else
110 #define MENUITEMINFO_SIZE_VERSION_400 MENUITEMINFO_SIZE_VERSION_400A
111 #endif // !UNICODE
112 #endif // (WINVER >= 0x0500)
113
114 class CMenuItemInfo : public MENUITEMINFO
115 {
116 public:
117 CMenuItemInfo()
118 {
119 memset(this, 0, sizeof(MENUITEMINFO));
120 cbSize = sizeof(MENUITEMINFO);
121 #if (WINVER >= 0x0500)
122 // adjust struct size if running on older version of Windows
123 if(AtlIsOldWindows())
124 {
125 ATLASSERT(cbSize > MENUITEMINFO_SIZE_VERSION_400); // must be
126 cbSize = MENUITEMINFO_SIZE_VERSION_400;
127 }
128 #endif // (WINVER >= 0x0500)
129 }
130 };
131
132
133 // forward declarations
134 template <bool t_bManaged> class CMenuT;
135 typedef CMenuT<false> CMenuHandle;
136 typedef CMenuT<true> CMenu;
137
138
139 template <bool t_bManaged>
140 class CMenuT
141 {
142 public:
143 // Data members
144 HMENU m_hMenu;
145
146 // Constructor/destructor/operators
147 CMenuT(HMENU hMenu = NULL) : m_hMenu(hMenu)
148 { }
149
150 ~CMenuT()
151 {
152 if(t_bManaged && m_hMenu != NULL)
153 DestroyMenu();
154 }
155
156 CMenuT<t_bManaged>& operator =(HMENU hMenu)
157 {
158 Attach(hMenu);
159 return *this;
160 }
161
162 void Attach(HMENU hMenuNew)
163 {
164 ATLASSERT(::IsMenu(hMenuNew));
165 if(t_bManaged && m_hMenu != NULL && m_hMenu != hMenuNew)
166 ::DestroyMenu(m_hMenu);
167 m_hMenu = hMenuNew;
168 }
169
170 HMENU Detach()
171 {
172 HMENU hMenu = m_hMenu;
173 m_hMenu = NULL;
174 return hMenu;
175 }
176
177 operator HMENU() const { return m_hMenu; }
178
179 bool IsNull() const { return (m_hMenu == NULL); }
180
181 BOOL IsMenu() const
182 {
183 return ::IsMenu(m_hMenu);
184 }
185
186 // Create/destroy methods
187 BOOL CreateMenu()
188 {
189 ATLASSERT(m_hMenu == NULL);
190 m_hMenu = ::CreateMenu();
191 return (m_hMenu != NULL) ? TRUE : FALSE;
192 }
193
194 BOOL CreatePopupMenu()
195 {
196 ATLASSERT(m_hMenu == NULL);
197 m_hMenu = ::CreatePopupMenu();
198 return (m_hMenu != NULL) ? TRUE : FALSE;
199 }
200
201 BOOL LoadMenu(ATL::_U_STRINGorID menu)
202 {
203 ATLASSERT(m_hMenu == NULL);
204 m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), menu.m _lpstr);
205 return (m_hMenu != NULL) ? TRUE : FALSE;
206 }
207
208 #ifndef _WIN32_WCE
209 BOOL LoadMenuIndirect(const void* lpMenuTemplate)
210 {
211 ATLASSERT(m_hMenu == NULL);
212 m_hMenu = ::LoadMenuIndirect(lpMenuTemplate);
213 return (m_hMenu != NULL) ? TRUE : FALSE;
214 }
215 #endif // !_WIN32_WCE
216
217 BOOL DestroyMenu()
218 {
219 if (m_hMenu == NULL)
220 return FALSE;
221 BOOL bRet = ::DestroyMenu(m_hMenu);
222 if(bRet)
223 m_hMenu = NULL;
224 return bRet;
225 }
226
227 // Menu Operations
228 BOOL DeleteMenu(UINT nPosition, UINT nFlags)
229 {
230 ATLASSERT(::IsMenu(m_hMenu));
231 return ::DeleteMenu(m_hMenu, nPosition, nFlags);
232 }
233
234 BOOL TrackPopupMenu(UINT nFlags, int x, int y, HWND hWnd, LPCRECT lpRect = NULL)
235 {
236 ATLASSERT(::IsMenu(m_hMenu));
237 #ifndef _WIN32_WCE
238 #if (WINVER >= 0x0500)
239 x = _FixTrackMenuPopupX(x, y);
240 #endif // !(WINVER >= 0x0500)
241 return ::TrackPopupMenu(m_hMenu, nFlags, x, y, 0, hWnd, lpRect);
242 #else // CE specific
243 lpRect;
244 return ::TrackPopupMenuEx(m_hMenu, nFlags, x, y, hWnd, NULL);
245 #endif // _WIN32_WCE
246 }
247
248 BOOL TrackPopupMenuEx(UINT uFlags, int x, int y, HWND hWnd, LPTPMPARAMS lptpm = NULL)
249 {
250 ATLASSERT(::IsMenu(m_hMenu));
251 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
252 x = _FixTrackMenuPopupX(x, y);
253 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
254 return ::TrackPopupMenuEx(m_hMenu, uFlags, x, y, hWnd, lptpm);
255 }
256
257 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
258 // helper that fixes popup menu X position when it's off-screen
259 static int _FixTrackMenuPopupX(int x, int y)
260 {
261 POINT pt = { x, y };
262 HMONITOR hMonitor = ::MonitorFromPoint(pt, MONITOR_DEFAULTTONULL );
263 if(hMonitor == NULL)
264 {
265 HMONITOR hMonitorNear = ::MonitorFromPoint(pt, MONITOR_D EFAULTTONEAREST);
266 if(hMonitorNear != NULL)
267 {
268 MONITORINFO mi = { 0 };
269 mi.cbSize = sizeof(MONITORINFO);
270 if(::GetMonitorInfo(hMonitorNear, &mi) != FALSE)
271 {
272 if(x < mi.rcWork.left)
273 x = mi.rcWork.left;
274 else if(x > mi.rcWork.right)
275 x = mi.rcWork.right;
276 }
277 }
278 }
279
280 return x;
281 }
282
283 BOOL GetMenuInfo(LPMENUINFO lpMenuInfo) const
284 {
285 ATLASSERT(::IsMenu(m_hMenu));
286 return ::GetMenuInfo(m_hMenu, lpMenuInfo);
287 }
288
289 BOOL SetMenuInfo(LPCMENUINFO lpMenuInfo)
290 {
291 ATLASSERT(::IsMenu(m_hMenu));
292 return ::SetMenuInfo(m_hMenu, lpMenuInfo);
293 }
294 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
295
296 // Menu Item Operations
297 BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem = 0, LPCTSTR lpszNewIte m = NULL)
298 {
299 ATLASSERT(::IsMenu(m_hMenu));
300 return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, lpszNewItem);
301 }
302
303 BOOL AppendMenu(UINT nFlags, HMENU hSubMenu, LPCTSTR lpszNewItem)
304 {
305 ATLASSERT(::IsMenu(m_hMenu));
306 ATLASSERT(::IsMenu(hSubMenu));
307 return ::AppendMenu(m_hMenu, nFlags | MF_POPUP, (UINT_PTR)hSubMe nu, lpszNewItem);
308 }
309
310 #ifndef _WIN32_WCE
311 BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, HBITMAP hBmp)
312 {
313 ATLASSERT(::IsMenu(m_hMenu));
314 return ::AppendMenu(m_hMenu, nFlags | MF_BITMAP, nIDNewItem, (LP CTSTR)hBmp);
315 }
316
317 BOOL AppendMenu(UINT nFlags, HMENU hSubMenu, HBITMAP hBmp)
318 {
319 ATLASSERT(::IsMenu(m_hMenu));
320 ATLASSERT(::IsMenu(hSubMenu));
321 return ::AppendMenu(m_hMenu, nFlags | (MF_BITMAP | MF_POPUP), (U INT_PTR)hSubMenu, (LPCTSTR)hBmp);
322 }
323 #endif // !_WIN32_WCE
324
325 UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck)
326 {
327 ATLASSERT(::IsMenu(m_hMenu));
328 return (UINT)::CheckMenuItem(m_hMenu, nIDCheckItem, nCheck);
329 }
330
331 UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable)
332 {
333 ATLASSERT(::IsMenu(m_hMenu));
334 return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable);
335 }
336
337 #ifndef _WIN32_WCE
338 BOOL HiliteMenuItem(HWND hWnd, UINT uIDHiliteItem, UINT uHilite)
339 {
340 ATLASSERT(::IsMenu(m_hMenu));
341 return ::HiliteMenuItem(hWnd, m_hMenu, uIDHiliteItem, uHilite);
342 }
343
344 int GetMenuItemCount() const
345 {
346 ATLASSERT(::IsMenu(m_hMenu));
347 return ::GetMenuItemCount(m_hMenu);
348 }
349
350 UINT GetMenuItemID(int nPos) const
351 {
352 ATLASSERT(::IsMenu(m_hMenu));
353 return ::GetMenuItemID(m_hMenu, nPos);
354 }
355
356 UINT GetMenuState(UINT nID, UINT nFlags) const
357 {
358 ATLASSERT(::IsMenu(m_hMenu));
359 return ::GetMenuState(m_hMenu, nID, nFlags);
360 }
361
362 int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFl ags) const
363 {
364 ATLASSERT(::IsMenu(m_hMenu));
365 return ::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nF lags);
366 }
367
368 int GetMenuStringLen(UINT nIDItem, UINT nFlags) const
369 {
370 ATLASSERT(::IsMenu(m_hMenu));
371 return ::GetMenuString(m_hMenu, nIDItem, NULL, 0, nFlags);
372 }
373
374 #ifndef _ATL_NO_COM
375 BOOL GetMenuString(UINT nIDItem, BSTR& bstrText, UINT nFlags) const
376 {
377 USES_CONVERSION;
378 ATLASSERT(::IsMenu(m_hMenu));
379 ATLASSERT(bstrText == NULL);
380
381 int nLen = GetMenuStringLen(nIDItem, nFlags);
382 if(nLen == 0)
383 {
384 bstrText = ::SysAllocString(OLESTR(""));
385 return (bstrText != NULL) ? TRUE : FALSE;
386 }
387
388 nLen++; // increment to include terminating NULL char
389 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
390 LPTSTR lpszText = buff.Allocate(nLen);
391 if(lpszText == NULL)
392 return FALSE;
393
394 if(!GetMenuString(nIDItem, lpszText, nLen, nFlags))
395 return FALSE;
396
397 bstrText = ::SysAllocString(T2OLE(lpszText));
398 return (bstrText != NULL) ? TRUE : FALSE;
399 }
400 #endif // !_ATL_NO_COM
401 #endif // !_WIN32_WCE
402
403 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
404 int GetMenuString(UINT nIDItem, _CSTRING_NS::CString& strText, UINT nFla gs) const
405 {
406 ATLASSERT(::IsMenu(m_hMenu));
407
408 int nLen = GetMenuStringLen(nIDItem, nFlags);
409 if(nLen == 0)
410 return 0;
411
412 nLen++; // increment to include terminating NULL char
413 LPTSTR lpstr = strText.GetBufferSetLength(nLen);
414 if(lpstr == NULL)
415 return 0;
416 int nRet = GetMenuString(nIDItem, lpstr, nLen, nFlags);
417 strText.ReleaseBuffer();
418 return nRet;
419 }
420 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
421
422 CMenuHandle GetSubMenu(int nPos) const
423 {
424 ATLASSERT(::IsMenu(m_hMenu));
425 return CMenuHandle(::GetSubMenu(m_hMenu, nPos));
426 }
427
428 BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem = 0, LP CTSTR lpszNewItem = NULL)
429 {
430 ATLASSERT(::IsMenu(m_hMenu));
431 return ::InsertMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpsz NewItem);
432 }
433
434 BOOL InsertMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, LPCTSTR lps zNewItem)
435 {
436 ATLASSERT(::IsMenu(m_hMenu));
437 ATLASSERT(::IsMenu(hSubMenu));
438 return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_POPUP, (UINT _PTR)hSubMenu, lpszNewItem);
439 }
440
441 #ifndef _WIN32_WCE
442 BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMA P hBmp)
443 {
444 ATLASSERT(::IsMenu(m_hMenu));
445 return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDN ewItem, (LPCTSTR)hBmp);
446 }
447
448 BOOL InsertMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, HBITMAP hBm p)
449 {
450 ATLASSERT(::IsMenu(m_hMenu));
451 ATLASSERT(::IsMenu(hSubMenu));
452 return ::InsertMenu(m_hMenu, nPosition, nFlags | (MF_BITMAP | MF _POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp);
453 }
454
455 BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem = 0, LP CTSTR lpszNewItem = NULL)
456 {
457 ATLASSERT(::IsMenu(m_hMenu));
458 return ::ModifyMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpsz NewItem);
459 }
460
461 BOOL ModifyMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, LPCTSTR lps zNewItem)
462 {
463 ATLASSERT(::IsMenu(m_hMenu));
464 ATLASSERT(::IsMenu(hSubMenu));
465 return ::ModifyMenu(m_hMenu, nPosition, nFlags | MF_POPUP, (UINT _PTR)hSubMenu, lpszNewItem);
466 }
467
468 BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, HBITMA P hBmp)
469 {
470 ATLASSERT(::IsMenu(m_hMenu));
471 return ::ModifyMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDN ewItem, (LPCTSTR)hBmp);
472 }
473
474 BOOL ModifyMenu(UINT nPosition, UINT nFlags, HMENU hSubMenu, HBITMAP hBm p)
475 {
476 ATLASSERT(::IsMenu(m_hMenu));
477 ATLASSERT(::IsMenu(hSubMenu));
478 return ::ModifyMenu(m_hMenu, nPosition, nFlags | (MF_BITMAP | MF _POPUP), (UINT_PTR)hSubMenu, (LPCTSTR)hBmp);
479 }
480 #endif // !_WIN32_WCE
481
482 BOOL RemoveMenu(UINT nPosition, UINT nFlags)
483 {
484 ATLASSERT(::IsMenu(m_hMenu));
485 return ::RemoveMenu(m_hMenu, nPosition, nFlags);
486 }
487
488 #ifndef _WIN32_WCE
489 BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, HBITMAP hBmpUncheck ed, HBITMAP hBmpChecked)
490 {
491 ATLASSERT(::IsMenu(m_hMenu));
492 return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags, hBmpUnch ecked, hBmpChecked);
493 }
494 #endif // !_WIN32_WCE
495
496 BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags)
497 {
498 ATLASSERT(::IsMenu(m_hMenu));
499 return ::CheckMenuRadioItem(m_hMenu, nIDFirst, nIDLast, nIDItem, nFlags);
500 }
501
502 BOOL GetMenuItemInfo(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii) const
503 {
504 ATLASSERT(::IsMenu(m_hMenu));
505 return (BOOL)::GetMenuItemInfo(m_hMenu, uItem, bByPosition, lpmi i);
506 }
507
508 BOOL SetMenuItemInfo(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii)
509 {
510 ATLASSERT(::IsMenu(m_hMenu));
511 return (BOOL)::SetMenuItemInfo(m_hMenu, uItem, bByPosition, lpmi i);
512 }
513
514 #ifndef _WIN32_WCE
515 BOOL InsertMenuItem(UINT uItem, BOOL bByPosition, LPMENUITEMINFO lpmii)
516 {
517 ATLASSERT(::IsMenu(m_hMenu));
518 return (BOOL)::InsertMenuItem(m_hMenu, uItem, bByPosition, lpmii );
519 }
520
521 UINT GetMenuDefaultItem(BOOL bByPosition = FALSE, UINT uFlags = 0U) cons t
522 {
523 ATLASSERT(::IsMenu(m_hMenu));
524 return ::GetMenuDefaultItem(m_hMenu, (UINT)bByPosition, uFlags);
525 }
526
527 BOOL SetMenuDefaultItem(UINT uItem = (UINT)-1, BOOL bByPosition = FALSE )
528 {
529 ATLASSERT(::IsMenu(m_hMenu));
530 return ::SetMenuDefaultItem(m_hMenu, uItem, (UINT)bByPosition);
531 }
532
533 BOOL GetMenuItemRect(HWND hWnd, UINT uItem, LPRECT lprcItem) const
534 {
535 ATLASSERT(::IsMenu(m_hMenu));
536 return ::GetMenuItemRect(hWnd, m_hMenu, uItem, lprcItem);
537 }
538
539 int MenuItemFromPoint(HWND hWnd, POINT point) const
540 {
541 ATLASSERT(::IsMenu(m_hMenu));
542 return ::MenuItemFromPoint(hWnd, m_hMenu, point);
543 }
544
545 // Context Help Functions
546 BOOL SetMenuContextHelpId(DWORD dwContextHelpId)
547 {
548 ATLASSERT(::IsMenu(m_hMenu));
549 return ::SetMenuContextHelpId(m_hMenu, dwContextHelpId);
550 }
551
552 DWORD GetMenuContextHelpId() const
553 {
554 ATLASSERT(::IsMenu(m_hMenu));
555 return ::GetMenuContextHelpId(m_hMenu);
556 }
557 #endif // !_WIN32_WCE
558 };
559
560
561 ///////////////////////////////////////////////////////////////////////////////
562 // CAccelerator
563
564 template <bool t_bManaged>
565 class CAcceleratorT
566 {
567 public:
568 HACCEL m_hAccel;
569
570 // Constructor/destructor/operators
571 CAcceleratorT(HACCEL hAccel = NULL) : m_hAccel(hAccel)
572 { }
573
574 ~CAcceleratorT()
575 {
576 if(t_bManaged && m_hAccel != NULL)
577 ::DestroyAcceleratorTable(m_hAccel);
578 }
579
580 CAcceleratorT<t_bManaged>& operator =(HACCEL hAccel)
581 {
582 Attach(hAccel);
583 return *this;
584 }
585
586 void Attach(HACCEL hAccel)
587 {
588 if(t_bManaged && m_hAccel != NULL)
589 ::DestroyAcceleratorTable(m_hAccel);
590 m_hAccel = hAccel;
591 }
592
593 HACCEL Detach()
594 {
595 HACCEL hAccel = m_hAccel;
596 m_hAccel = NULL;
597 return hAccel;
598 }
599
600 operator HACCEL() const { return m_hAccel; }
601
602 bool IsNull() const { return m_hAccel == NULL; }
603
604 // Create/destroy methods
605 HACCEL LoadAccelerators(ATL::_U_STRINGorID accel)
606 {
607 ATLASSERT(m_hAccel == NULL);
608 m_hAccel = ::LoadAccelerators(ModuleHelper::GetResourceInstance( ), accel.m_lpstr);
609 return m_hAccel;
610 }
611
612 HACCEL CreateAcceleratorTable(LPACCEL pAccel, int cEntries)
613 {
614 ATLASSERT(m_hAccel == NULL);
615 ATLASSERT(pAccel != NULL);
616 m_hAccel = ::CreateAcceleratorTable(pAccel, cEntries);
617 return m_hAccel;
618 }
619
620 void DestroyObject()
621 {
622 if(m_hAccel != NULL)
623 {
624 ::DestroyAcceleratorTable(m_hAccel);
625 m_hAccel = NULL;
626 }
627 }
628
629 // Operations
630 #ifndef _WIN32_WCE
631 int CopyAcceleratorTable(LPACCEL lpAccelDst, int cEntries)
632 {
633 ATLASSERT(m_hAccel != NULL);
634 ATLASSERT(lpAccelDst != NULL);
635 return ::CopyAcceleratorTable(m_hAccel, lpAccelDst, cEntries);
636 }
637
638 int GetEntriesCount() const
639 {
640 ATLASSERT(m_hAccel != NULL);
641 return ::CopyAcceleratorTable(m_hAccel, NULL, 0);
642 }
643 #endif // !_WIN32_WCE
644
645 BOOL TranslateAccelerator(HWND hWnd, LPMSG pMsg)
646 {
647 ATLASSERT(m_hAccel != NULL);
648 ATLASSERT(::IsWindow(hWnd));
649 ATLASSERT(pMsg != NULL);
650 return ::TranslateAccelerator(hWnd, m_hAccel, pMsg);
651 }
652 };
653
654 typedef CAcceleratorT<false> CAcceleratorHandle;
655 typedef CAcceleratorT<true> CAccelerator;
656
657
658 ///////////////////////////////////////////////////////////////////////////////
659 // CIcon
660
661 template <bool t_bManaged>
662 class CIconT
663 {
664 public:
665 HICON m_hIcon;
666
667 // Constructor/destructor/operators
668 CIconT(HICON hIcon = NULL) : m_hIcon(hIcon)
669 { }
670
671 ~CIconT()
672 {
673 if(t_bManaged && m_hIcon != NULL)
674 ::DestroyIcon(m_hIcon);
675 }
676
677 CIconT<t_bManaged>& operator =(HICON hIcon)
678 {
679 Attach(hIcon);
680 return *this;
681 }
682
683 void Attach(HICON hIcon)
684 {
685 if(t_bManaged && m_hIcon != NULL)
686 ::DestroyIcon(m_hIcon);
687 m_hIcon = hIcon;
688 }
689
690 HICON Detach()
691 {
692 HICON hIcon = m_hIcon;
693 m_hIcon = NULL;
694 return hIcon;
695 }
696
697 operator HICON() const { return m_hIcon; }
698
699 bool IsNull() const { return m_hIcon == NULL; }
700
701 // Create/destroy methods
702 HICON LoadIcon(ATL::_U_STRINGorID icon)
703 {
704 ATLASSERT(m_hIcon == NULL);
705 m_hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), icon.m _lpstr);
706 return m_hIcon;
707 }
708
709 HICON LoadIcon(ATL::_U_STRINGorID icon, int cxDesired, int cyDesired, UI NT fuLoad = 0)
710 {
711 ATLASSERT(m_hIcon == NULL);
712 m_hIcon = (HICON) ::LoadImage(ModuleHelper::GetResourceInstance( ), icon.m_lpstr, IMAGE_ICON, cxDesired, cyDesired, fuLoad);
713 return m_hIcon;
714 }
715
716 #ifndef _WIN32_WCE
717 HICON LoadOEMIcon(LPCTSTR lpstrIconName)
718 {
719 ATLASSERT(m_hIcon == NULL);
720 ATLASSERT(IsOEMIcon(lpstrIconName));
721 m_hIcon = ::LoadIcon(NULL, lpstrIconName);
722 return m_hIcon;
723 }
724
725 HICON CreateIcon(int nWidth, int nHeight, BYTE cPlanes, BYTE cBitsPixel, CONST BYTE* lpbANDbits, CONST BYTE *lpbXORbits)
726 {
727 ATLASSERT(m_hIcon == NULL);
728 ATLASSERT(lpbANDbits != NULL);
729 ATLASSERT(lpbXORbits != NULL);
730 m_hIcon = ::CreateIcon(ModuleHelper::GetResourceInstance(), nWid th, nHeight, cPlanes, cBitsPixel, lpbANDbits, lpbXORbits);
731 return m_hIcon;
732 }
733
734 HICON CreateIconFromResource(PBYTE pBits, DWORD dwResSize, DWORD dwVersi on = 0x00030000)
735 {
736 ATLASSERT(m_hIcon == NULL);
737 ATLASSERT(pBits != NULL);
738 m_hIcon = ::CreateIconFromResource(pBits, dwResSize, TRUE, dwVer sion);
739 return m_hIcon;
740 }
741
742 HICON CreateIconFromResourceEx(PBYTE pbBits, DWORD cbBits, DWORD dwVersi on = 0x00030000, int cxDesired = 0, int cyDesired = 0, UINT uFlags = LR_DEFAULTC OLOR)
743 {
744 ATLASSERT(m_hIcon == NULL);
745 ATLASSERT(pbBits != NULL);
746 ATLASSERT(cbBits > 0);
747 m_hIcon = ::CreateIconFromResourceEx(pbBits, cbBits, TRUE, dwVer sion, cxDesired, cyDesired, uFlags);
748 return m_hIcon;
749 }
750 #endif // !_WIN32_WCE
751
752 HICON CreateIconIndirect(PICONINFO pIconInfo)
753 {
754 ATLASSERT(m_hIcon == NULL);
755 ATLASSERT(pIconInfo != NULL);
756 m_hIcon = ::CreateIconIndirect(pIconInfo);
757 return m_hIcon;
758 }
759
760 #ifndef _WIN32_WCE
761 HICON ExtractIcon(LPCTSTR lpszExeFileName, UINT nIconIndex)
762 {
763 ATLASSERT(m_hIcon == NULL);
764 ATLASSERT(lpszExeFileName != NULL);
765 m_hIcon = ::ExtractIcon(ModuleHelper::GetModuleInstance(), lpszE xeFileName, nIconIndex);
766 return m_hIcon;
767 }
768
769 HICON ExtractAssociatedIcon(HINSTANCE hInst, LPTSTR lpIconPath, LPWORD l piIcon)
770 {
771 ATLASSERT(m_hIcon == NULL);
772 ATLASSERT(lpIconPath != NULL);
773 ATLASSERT(lpiIcon != NULL);
774 m_hIcon = ::ExtractAssociatedIcon(hInst, lpIconPath, lpiIcon);
775 return m_hIcon;
776 }
777 #endif // !_WIN32_WCE
778
779 BOOL DestroyIcon()
780 {
781 ATLASSERT(m_hIcon != NULL);
782 BOOL bRet = ::DestroyIcon(m_hIcon);
783 if(bRet != FALSE)
784 m_hIcon = NULL;
785 return bRet;
786 }
787
788 // Operations
789 #ifndef _WIN32_WCE
790 HICON CopyIcon()
791 {
792 ATLASSERT(m_hIcon != NULL);
793 return ::CopyIcon(m_hIcon);
794 }
795
796 HICON DuplicateIcon()
797 {
798 ATLASSERT(m_hIcon != NULL);
799 return ::DuplicateIcon(NULL, m_hIcon);
800 }
801 #endif // !_WIN32_WCE
802
803 BOOL DrawIcon(HDC hDC, int x, int y)
804 {
805 ATLASSERT(m_hIcon != NULL);
806 #ifndef _WIN32_WCE
807 return ::DrawIcon(hDC, x, y, m_hIcon);
808 #else // CE specific
809 return ::DrawIconEx(hDC, x, y, m_hIcon, 0, 0, 0, NULL, DI_NORMAL );
810 #endif // _WIN32_WCE
811 }
812
813 BOOL DrawIcon(HDC hDC, POINT pt)
814 {
815 ATLASSERT(m_hIcon != NULL);
816 #ifndef _WIN32_WCE
817 return ::DrawIcon(hDC, pt.x, pt.y, m_hIcon);
818 #else // CE specific
819 return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, 0, 0, 0, NULL, DI_ NORMAL);
820 #endif // _WIN32_WCE
821 }
822
823 BOOL DrawIconEx(HDC hDC, int x, int y, int cxWidth, int cyWidth, UINT uS tepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
824 {
825 ATLASSERT(m_hIcon != NULL);
826 return ::DrawIconEx(hDC, x, y, m_hIcon, cxWidth, cyWidth, uStepI fAniCur, hbrFlickerFreeDraw, uFlags);
827 }
828
829 BOOL DrawIconEx(HDC hDC, POINT pt, SIZE size, UINT uStepIfAniCur = 0, HB RUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
830 {
831 ATLASSERT(m_hIcon != NULL);
832 return ::DrawIconEx(hDC, pt.x, pt.y, m_hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
833 }
834
835 #ifndef _WIN32_WCE
836 BOOL GetIconInfo(PICONINFO pIconInfo) const
837 {
838 ATLASSERT(m_hIcon != NULL);
839 ATLASSERT(pIconInfo != NULL);
840 return ::GetIconInfo(m_hIcon, pIconInfo);
841 }
842
843 #if (_WIN32_WINNT >= 0x0600)
844 BOOL GetIconInfoEx(PICONINFOEX pIconInfo) const
845 {
846 ATLASSERT(m_hIcon != NULL);
847 ATLASSERT(pIconInfo != NULL);
848 return ::GetIconInfoEx(m_hIcon, pIconInfo);
849 }
850 #endif // (_WIN32_WINNT >= 0x0600)
851
852 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)
853 HRESULT LoadIconMetric(ATL::_U_STRINGorID icon, int lims)
854 {
855 ATLASSERT(m_hIcon == NULL);
856 USES_CONVERSION;
857 return ::LoadIconMetric(ModuleHelper::GetResourceInstance(), T2C W(icon.m_lpstr), lims, &m_hIcon);
858 }
859
860 HRESULT LoadIconWithScaleDown(ATL::_U_STRINGorID icon, int cx, int cy)
861 {
862 ATLASSERT(m_hIcon == NULL);
863 USES_CONVERSION;
864 return ::LoadIconWithScaleDown(ModuleHelper::GetResourceInstance (), T2CW(icon.m_lpstr), cx, cy, &m_hIcon);
865 }
866
867 HRESULT LoadOEMIconMetric(LPCTSTR lpstrIconName, int lims)
868 {
869 ATLASSERT(m_hIcon == NULL);
870 ATLASSERT(IsOEMIcon(lpstrIconName));
871 return ::LoadIconMetric(NULL, (LPCWSTR)lpstrIconName, lims, &m_h Icon);
872 }
873
874 HRESULT LoadOEMIconWithScaleDown(LPCTSTR lpstrIconName, int cx, int cy)
875 {
876 ATLASSERT(m_hIcon == NULL);
877 ATLASSERT(IsOEMIcon(lpstrIconName));
878 USES_CONVERSION;
879 return ::LoadIconWithScaleDown(NULL, (LPCWSTR)lpstrIconName, cx, cy, &m_hIcon);
880 }
881 #endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)
882 #endif // !_WIN32_WCE
883
884 // Helper
885 #ifndef _WIN32_WCE
886 static bool IsOEMIcon(LPCTSTR lpstrIconName)
887 {
888 #if (WINVER >= 0x0600)
889 return (lpstrIconName == IDI_APPLICATION || lpstrIconName == IDI _ASTERISK || lpstrIconName == IDI_EXCLAMATION ||
890 lpstrIconName == IDI_HAND || lpstrIconName == IDI_QUES TION || lpstrIconName == IDI_WINLOGO ||
891 lpstrIconName == IDI_SHIELD);
892 #else // !(WINVER >= 0x0600)
893 return (lpstrIconName == IDI_APPLICATION || lpstrIconName == IDI _ASTERISK || lpstrIconName == IDI_EXCLAMATION ||
894 lpstrIconName == IDI_HAND || lpstrIconName == IDI_QUES TION || lpstrIconName == IDI_WINLOGO);
895 #endif // !(WINVER >= 0x0600)
896 }
897 #endif // !_WIN32_WCE
898 };
899
900 typedef CIconT<false> CIconHandle;
901 typedef CIconT<true> CIcon;
902
903
904 ///////////////////////////////////////////////////////////////////////////////
905 // CCursor
906
907 // protect template member from a winuser.h macro
908 #ifdef CopyCursor
909 #undef CopyCursor
910 #endif
911
912 template <bool t_bManaged>
913 class CCursorT
914 {
915 public:
916 HCURSOR m_hCursor;
917
918 // Constructor/destructor/operators
919 CCursorT(HCURSOR hCursor = NULL) : m_hCursor(hCursor)
920 { }
921
922 ~CCursorT()
923 {
924 if(t_bManaged && m_hCursor != NULL)
925 DestroyCursor();
926 }
927
928 CCursorT<t_bManaged>& operator =(HCURSOR hCursor)
929 {
930 Attach(hCursor);
931 return *this;
932 }
933
934 void Attach(HCURSOR hCursor)
935 {
936 if(t_bManaged && m_hCursor != NULL)
937 DestroyCursor();
938 m_hCursor = hCursor;
939 }
940
941 HCURSOR Detach()
942 {
943 HCURSOR hCursor = m_hCursor;
944 m_hCursor = NULL;
945 return hCursor;
946 }
947
948 operator HCURSOR() const { return m_hCursor; }
949
950 bool IsNull() const { return m_hCursor == NULL; }
951
952 // Create/destroy methods
953 HCURSOR LoadCursor(ATL::_U_STRINGorID cursor)
954 {
955 ATLASSERT(m_hCursor == NULL);
956 m_hCursor = ::LoadCursor(ModuleHelper::GetResourceInstance(), cu rsor.m_lpstr);
957 return m_hCursor;
958 }
959
960 HCURSOR LoadSysCursor(LPCTSTR lpstrCursorName)
961 {
962 ATLASSERT(m_hCursor == NULL);
963 #if (WINVER >= 0x0500)
964 ATLASSERT(lpstrCursorName == IDC_ARROW || lpstrCursorName == IDC _IBEAM || lpstrCursorName == IDC_WAIT ||
965 lpstrCursorName == IDC_CROSS || lpstrCursorName == IDC_U PARROW || lpstrCursorName == IDC_SIZE ||
966 lpstrCursorName == IDC_ICON || lpstrCursorName == IDC_SI ZENWSE || lpstrCursorName == IDC_SIZENESW ||
967 lpstrCursorName == IDC_SIZEWE || lpstrCursorName == IDC_ SIZENS || lpstrCursorName == IDC_SIZEALL ||
968 lpstrCursorName == IDC_NO || lpstrCursorName == IDC_APPS TARTING || lpstrCursorName == IDC_HELP ||
969 lpstrCursorName == IDC_HAND);
970 #else // !(WINVER >= 0x0500)
971 ATLASSERT(lpstrCursorName == IDC_ARROW || lpstrCursorName == IDC _IBEAM || lpstrCursorName == IDC_WAIT ||
972 lpstrCursorName == IDC_CROSS || lpstrCursorName == IDC_U PARROW || lpstrCursorName == IDC_SIZE ||
973 lpstrCursorName == IDC_ICON || lpstrCursorName == IDC_SI ZENWSE || lpstrCursorName == IDC_SIZENESW ||
974 lpstrCursorName == IDC_SIZEWE || lpstrCursorName == IDC_ SIZENS || lpstrCursorName == IDC_SIZEALL ||
975 lpstrCursorName == IDC_NO || lpstrCursorName == IDC_APPS TARTING || lpstrCursorName == IDC_HELP);
976 #endif // !(WINVER >= 0x0500)
977 m_hCursor = ::LoadCursor(NULL, lpstrCursorName);
978 return m_hCursor;
979 }
980
981 // deprecated
982 HCURSOR LoadOEMCursor(LPCTSTR lpstrCursorName)
983 {
984 return LoadSysCursor(lpstrCursorName);
985 }
986
987 HCURSOR LoadCursor(ATL::_U_STRINGorID cursor, int cxDesired, int cyDesir ed, UINT fuLoad = 0)
988 {
989 ATLASSERT(m_hCursor == NULL);
990 m_hCursor = (HCURSOR) ::LoadImage(ModuleHelper::GetResourceInsta nce(), cursor.m_lpstr, IMAGE_CURSOR, cxDesired, cyDesired, fuLoad);
991 return m_hCursor;
992 }
993
994 #ifndef _WIN32_WCE
995 HCURSOR LoadCursorFromFile(LPCTSTR pstrFilename)
996 {
997 ATLASSERT(m_hCursor == NULL);
998 ATLASSERT(pstrFilename != NULL);
999 m_hCursor = ::LoadCursorFromFile(pstrFilename);
1000 return m_hCursor;
1001 }
1002 #endif // !_WIN32_WCE
1003
1004 #if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_P SPC) || defined(WIN32_PLATFORM_WFSP)))
1005 HCURSOR CreateCursor(int xHotSpot, int yHotSpot, int nWidth, int nHeight , CONST VOID *pvANDPlane, CONST VOID *pvXORPlane)
1006 {
1007 ATLASSERT(m_hCursor == NULL);
1008 m_hCursor = ::CreateCursor(ModuleHelper::GetResourceInstance(), xHotSpot, yHotSpot, nWidth, nHeight, pvANDPlane, pvXORPlane);
1009 return m_hCursor;
1010 }
1011 #endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLAT FORM_PSPC) || defined(WIN32_PLATFORM_WFSP)))
1012
1013 #ifndef _WIN32_WCE
1014 HCURSOR CreateCursorFromResource(PBYTE pBits, DWORD dwResSize, DWORD dwV ersion = 0x00030000)
1015 {
1016 ATLASSERT(m_hCursor == NULL);
1017 ATLASSERT(pBits != NULL);
1018 m_hCursor = (HCURSOR)::CreateIconFromResource(pBits, dwResSize, FALSE, dwVersion);
1019 return m_hCursor;
1020 }
1021
1022 HCURSOR CreateCursorFromResourceEx(PBYTE pbBits, DWORD cbBits, DWORD dwV ersion = 0x00030000, int cxDesired = 0, int cyDesired = 0, UINT uFlags = LR_DEFA ULTCOLOR)
1023 {
1024 ATLASSERT(m_hCursor == NULL);
1025 ATLASSERT(pbBits != NULL);
1026 ATLASSERT(cbBits > 0);
1027 m_hCursor = (HCURSOR)::CreateIconFromResourceEx(pbBits, cbBits, FALSE, dwVersion, cxDesired, cyDesired, uFlags);
1028 return m_hCursor;
1029 }
1030 #endif // !_WIN32_WCE
1031
1032 BOOL DestroyCursor()
1033 {
1034 ATLASSERT(m_hCursor != NULL);
1035 #if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLATFORM_P SPC) || defined(WIN32_PLATFORM_WFSP)))
1036 BOOL bRet = ::DestroyCursor(m_hCursor);
1037 if(bRet != FALSE)
1038 m_hCursor = NULL;
1039 return bRet;
1040 #else // !(!defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PLA TFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))))
1041 ATLTRACE2(atlTraceUI, 0, _T("Warning: This version of Windows CE does not have ::DestroyCursor()\n"));
1042 return FALSE;
1043 #endif // !(!defined(_WIN32_WCE) || ((_WIN32_WCE >= 0x400) && !(defined(WIN32_PL ATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP))))
1044 }
1045
1046 // Operations
1047 #ifndef _WIN32_WCE
1048 HCURSOR CopyCursor()
1049 {
1050 ATLASSERT(m_hCursor != NULL);
1051 return (HCURSOR)::CopyIcon((HICON)m_hCursor);
1052 }
1053 #endif // !_WIN32_WCE
1054
1055 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
1056 BOOL GetCursorInfo(LPCURSORINFO pCursorInfo)
1057 {
1058 ATLASSERT(m_hCursor != NULL);
1059 ATLASSERT(pCursorInfo != NULL);
1060 return ::GetCursorInfo(pCursorInfo);
1061 }
1062 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
1063 };
1064
1065 typedef CCursorT<false> CCursorHandle;
1066 typedef CCursorT<true> CCursor;
1067
1068
1069 ///////////////////////////////////////////////////////////////////////////////
1070 // CResource - Wraps a generic Windows resource.
1071 // Use it with custom resource types other than the
1072 // standard RT_CURSOR, RT_BITMAP, etc.
1073
1074 class CResource
1075 {
1076 public:
1077 HGLOBAL m_hGlobal;
1078 HRSRC m_hResource;
1079
1080 // Constructor/destructor
1081 CResource() : m_hGlobal(NULL), m_hResource(NULL)
1082 { }
1083
1084 ~CResource()
1085 {
1086 Release();
1087 }
1088
1089 // Load methods
1090 bool Load(ATL::_U_STRINGorID Type, ATL::_U_STRINGorID ID)
1091 {
1092 ATLASSERT(m_hResource == NULL);
1093 ATLASSERT(m_hGlobal == NULL);
1094
1095 m_hResource = ::FindResource(ModuleHelper::GetResourceInstance() , ID.m_lpstr, Type.m_lpstr);
1096 if(m_hResource == NULL)
1097 return false;
1098
1099 m_hGlobal = ::LoadResource(ModuleHelper::GetResourceInstance(), m_hResource);
1100 if(m_hGlobal == NULL)
1101 {
1102 m_hResource = NULL;
1103 return false;
1104 }
1105
1106 return true;
1107 }
1108
1109 #ifndef _WIN32_WCE
1110 bool LoadEx(ATL::_U_STRINGorID Type, ATL::_U_STRINGorID ID, WORD wLangua ge)
1111 {
1112 ATLASSERT(m_hResource == NULL);
1113 ATLASSERT(m_hGlobal == NULL);
1114
1115 m_hResource = ::FindResourceEx(ModuleHelper::GetResourceInstance (), ID.m_lpstr, Type.m_lpstr, wLanguage);
1116 if(m_hResource == NULL)
1117 return false;
1118
1119 m_hGlobal = ::LoadResource(ModuleHelper::GetResourceInstance(), m_hResource);
1120 if(m_hGlobal == NULL)
1121 {
1122 m_hResource = NULL;
1123 return false;
1124 }
1125
1126 return true;
1127 }
1128 #endif // !_WIN32_WCE
1129
1130 // Misc. operations
1131 DWORD GetSize() const
1132 {
1133 ATLASSERT(m_hResource != NULL);
1134 return ::SizeofResource(ModuleHelper::GetResourceInstance(), m_h Resource);
1135 }
1136
1137 LPVOID Lock()
1138 {
1139 ATLASSERT(m_hResource != NULL);
1140 ATLASSERT(m_hGlobal != NULL);
1141 LPVOID pVoid = ::LockResource(m_hGlobal);
1142 ATLASSERT(pVoid != NULL);
1143 return pVoid;
1144 }
1145
1146 void Release()
1147 {
1148 if(m_hGlobal != NULL)
1149 {
1150 FreeResource(m_hGlobal);
1151 m_hGlobal = NULL;
1152 m_hResource = NULL;
1153 }
1154 }
1155 };
1156
1157 }; // namespace WTL
1158
1159 #endif // __ATLUSER_H__
OLDNEW
« no previous file with comments | « third_party/wtl/include/atltheme.h ('k') | third_party/wtl/include/atlwince.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698