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

Side by Side Diff: third_party/wtl/include/atlwince.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/atluser.h ('k') | third_party/wtl/include/atlwinx.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 __ATLWINCE_H__
10 #define __ATLWINCE_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 atlwince.h requires atlapp.h to be included first
20 #endif
21
22 #ifndef __ATLWIN_H__
23 #error atlwince.h requires atlwin.h to be included first
24 #endif
25
26 #ifndef _WIN32_WCE
27 #error atlwince.h compiles under Windows CE only
28 #elif (_WIN32_WCE < 300)
29 #error atlwince.h requires Windows CE 3.0 or higher.
30 #endif
31
32 #if defined(WIN32_PLATFORM_WFSP) && _MSC_VER < 1400 // EVC compiling SmartPhone code
33 #if (WIN32_PLATFORM_WFSP < 200)
34 #error atlwince.h requires Smartphone 2003 or higher
35 #endif
36 #endif // WIN32_PLATFORM_WFSP
37
38 #if defined(WIN32_PLATFORM_PSPC) && _MSC_VER < 1400 // EVC compiling Pocket PC code
39 #if (WIN32_PLATFORM_PSPC < 310)
40 #error atlwince.h requires Pocket PC 2002 or higher
41 #endif
42 #endif // WIN32_PLATFORM_PSPC
43
44 #if !defined(_AYGSHELL_H_) && !defined(__AYGSHELL_H__)
45 #error atlwince.h requires aygshell.h to be included first
46 #else
47 #if defined(WIN32_PLATFORM_WFSP) && !defined(_TPCSHELL_H_)
48 #error SmartPhone dialog classes require tpcshell.h to be included first
49 #endif
50 #endif
51
52 #if (_MSC_VER >= 1400) // VS2005
53 #include <DeviceResolutionAware.h>
54 #define _WTL_CE_DRA
55 #endif // (_MSC_VER >= 1400)
56
57 #if !defined(_WTL_CE_NO_DIALOGS) && !defined(__ATLFRAME_H__)
58 #error Orientation aware dialog classes require atlframe.h to be include d first
59 #endif
60
61 #if !defined(_WTL_CE_NO_APPWINDOW) && !defined(__ATLFRAME_H__)
62 #error Application window class require atlframe.h to be included first
63 #endif
64
65 #if !defined(_WTL_CE_NO_ZOOMSCROLL) && !defined(__ATLSCRL_H__)
66 #error ZoomScroll implementation requires atlscrl.h to be included first
67 #endif
68
69 #if !defined(_WTL_CE_NO_ZOOMSCROLL)
70 #if !(defined(__ATLTYPES_H__) || (defined(__ATLMISC_H__) && !defined(_WTL_NO_W TYPES)))
71 #error ZoomScroll requires _WTL_NO_WTYPES not to be defined and either a tlmisc.h or atltypes.h to be included first
72 #endif // !(defined(__ATLTYPES_H__) || (defined(__ATLMISC_H__) && !defined(_WT L_NO_WTYPES)))
73 #endif // !defined(_WTL_CE_NO_ZOOMSCROLL)
74
75 #if !defined(WIN32_PLATFORM_WFSP) && !defined(WIN32_PLATFORM_PSPC)
76 #define _WTL_CE_NO_CONTROLS
77 #endif // !defined(WIN32_PLATFORM_WFSP) && !defined(WIN32_PLATFORM_PSPC)
78
79 #ifndef _WTL_CE_NO_CONTROLS
80 #ifndef __ATLCTRLS_H__
81 #error The PPC/SmartPhone controls classes require atlctrls.h to be incl uded first
82 #endif
83
84 #include <htmlctrl.h>
85 #pragma comment(lib, "htmlview.lib")
86
87 #include <voicectl.h>
88 #pragma comment(lib, "voicectl.lib")
89
90 #ifdef WIN32_PLATFORM_PSPC
91 #include <richink.h>
92 #pragma comment(lib, "richink.lib")
93
94 #include <inkx.h>
95 #pragma comment(lib, "inkx.lib")
96
97 #include <doclist.h>
98 #pragma comment(lib, "doclist.lib")
99 #endif
100 #endif
101
102
103 ///////////////////////////////////////////////////////////////////////////////
104 // Classes in this file:
105 //
106 // CStdDialogBase<T, t_shidiFlags, t_bModal> : Standard PPC/SmartPhone dialog ba se class
107 // CStdDialogImplBase - Base implementation of standard dialog
108 // CStdDialogImpl<T, t_shidiFlags, t_bModal> : Standard dialog implementation
109 // CStdIndirectDialogImpl - implementation of standard indirect PPC/SmartPhone d ialog
110 // CStdAxDialogImpl<T, t_shidiFlags, t_bModal> : Standard AxDialog implementatio n
111 // CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags> : Standard simple dialog
112 // CStdDialogResizeImplBase - Base implementation of orientation resizing standa rd dialog
113 // CStdDialogResizeImpl<T, t_shidiFlags, t_bModal> : Orientation resizing standa rd dialog implementation
114 // CStdAxDialogResizeImpl - implementation of orientation resizing standard AxDi alog
115 // CStdSimpleDialogResizeImpl<T, t_wDlgTemplateID, t_shidiFlags> : Standard resi zing simple dialog implementation
116 // CStdOrientedDialogBase - Oriented PPC standard dialog base class
117 // CStdOrientedDialogImplBase - Oriented PPC standard dialog base implementation
118 // CStdOrientedDialogImpl<T, t_shidiFlags, t_bModal> : Oriented PPC standard dia log implementation
119 // CStdAxOrientedDialogImpl - Oriented PPC standard AxDialog implementation
120 // CStdSimpleOrientedDialog<t_wDlgTemplateID, t_wDlgLandscapeID, t_shidiFlags> : Standard simple orientable dialog
121 //
122 // CAppInfoBase : Helper for application state save/restore to registry
123 // CAppInfoT<T> : CAppInfoBase constructed from a CAppWindow<T>
124 // CAppWindowBase<T> : Base class for PPC/SmartPhone well-behaved application wi ndow or dialog
125 // CAppWindow<T> : PPC/SmartPhone well-behaved application window class
126 // CAppDialog<T> : PPC/SmartPhone well-behaved application dialog class
127 // CAppStdDialogImplBase - Base implementation of standard application dialogs
128 // CAppStdDialogImpl<T, t_shidiFlags, t_bModal> : Implementation of standard app lication dialog
129 // CAppStdDialogResizeImpl - implementation of orientation resizing standard app lication dialog
130 // CAppStdAxDialogImpl - Implementation of standard application AxDialog
131 // CAppStdAxDialogResizeImpl - implementation of orientation resizing standard a pplication AxDialog
132 // CAppStdOrientedDialogImpl - implementation of oriented PPC standard applicati on dialog
133 // CAppStdAxOrientedDialogImpl - implementation of oriented PPC standard applica tion AxDialog
134 //
135 // CFullScreenFrame<T, t_bHasSip> : Full screen frame class
136 //
137 // CZoomScrollImpl<T> : WinCE zooming implementation
138 //
139 // CBottomTabViewImpl<T, TBase, TWinTraits> - CBottomTabView
140 // CHtmlCtrlT<TBase> - CHtmlCtrl
141 // CRichInkCtrlT<TBase> - CRichInkCtrl
142 // CInkXCtrlT<TBase> - CInkXCtrl
143 // CVoiceRecorderCtrlT<TBase> - CVoiceRecorderCtrl
144 // CDocListCtrlT<TBase> - CDocListCtrl
145 // CCapEditT<TBase> - CCapEdit
146 // CTTStaticT<TBase> - CTTStatic
147 // CTTButtonT<TBase> - CTTButton
148 //
149 // CSpinCtrlT<TBase> - CSpinCtrl : SmartPhone specific UpDown control
150 // CSpinned<TBase, t_bExpandOnly> : SmartPhone association of control and Spin
151 // CSpinListBox : SmartPhone spinned ListBox control
152 // CExpandListBox : SmartPhone expandable ListBox control
153 // CExpandEdit : SmartPhone expandable Edit control
154 // CExpandCapEdit : SmartPhone expandable CapEdit control
155 //
156 // Global functions:
157 // AtlCreateMenuBar()
158 // AtlCreateEmptyMenuBar()
159 // AtlIsEditFocus()
160 // AtlActivateBackKey()
161
162 namespace WTL
163 {
164
165 ///////////////////////////////////////////////////////////////////////////////
166 // MenuBar creation functions for property sheets and dialogs
167 // Frame windows use CreateSimpleCEMenuBar
168
169 inline HWND AtlCreateMenuBar(SHMENUBARINFO& mbi)
170 {
171 ATLASSERT(::IsWindow(mbi.hwndParent));
172 ATLVERIFY(::SHCreateMenuBar(&mbi) != FALSE);
173 return mbi.hwndMB;
174 };
175
176 inline HWND AtlCreateMenuBar(HWND hWnd, UINT nToolBarId = ATL_IDW_TOOLBAR, DWORD dwFlags = 0, int nBmpId = 0, int cBmpImages = 0, COLORREF clrBk = 0)
177 {
178 SHMENUBARINFO mbi = { sizeof(mbi), hWnd, dwFlags, nToolBarId, ModuleHelp er::GetResourceInstance(), nBmpId, cBmpImages, 0, clrBk };
179 return AtlCreateMenuBar(mbi);
180 }
181
182 inline HWND AtlCreateEmptyMenuBar(HWND hWnd, bool bSip = true)
183 {
184 SHMENUBARINFO embi = { sizeof(SHMENUBARINFO), hWnd, SHCMBF_EMPTYBAR };
185 if (!bSip)
186 embi.dwFlags |= SHCMBF_HIDESIPBUTTON;
187
188 return AtlCreateMenuBar(embi);
189 }
190
191 ///////////////////////////////////////////////////////////////////////////////
192 // Helper functions for SmartPhone back key handling
193
194 inline bool AtlIsEditFocus()
195 {
196 ATL::CWindow wCtrl = GetFocus();
197 if (wCtrl.IsWindow())
198 {
199 TCHAR szClassName[8] = {0};
200 ATLVERIFY(::GetClassName(wCtrl.m_hWnd, szClassName, 8));
201 return !_tcscmp(szClassName, _T("Edit")) || !_tcscmp(szClassName , WC_CAPEDIT);
202 }
203 return false;
204 }
205
206 #if defined WIN32_PLATFORM_WFSP
207 inline void AtlActivateBackKey(HWND hMenuBar)
208 {
209 ATLASSERT(::IsWindow(hMenuBar));
210 ::SendMessage(hMenuBar, SHCMBM_OVERRIDEKEY, VK_TBACK,
211 MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
212 }
213 #endif // WIN32_PLATFORM_WFSP
214
215 // --- Standard PPC/SmartPhone dialogs ---
216
217 #ifndef _WTL_CE_NO_DIALOGS
218
219 ///////////////////////////////////////////////////////////////////////////////
220 // CStdDialogBase - base class for standard PPC/SmartPhone dialogs
221
222 #define WTL_STD_SHIDIF SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULL SCREEN
223 #define WTL_SP_SHIDIF SHIDIF_SIZEDLGFULLSCREEN
224
225 // Title setting macros
226 #define WTL_DLG_TITLEHEIGHT(iHeight) static const int GetTitleHeight(){return iH eight;}
227 #define WTL_DLG_NOTITLE WTL_DLG_TITLEHEIGHT(0)
228
229 ///////////////////////////////////////////////////////////////////////////////
230 // CStdDialogBase - Base class for standard PPC/SmartPhone dialog
231
232 template <class T, UINT t_shidiFlags, bool t_bModal = true>
233 class CStdDialogBase
234 {
235 public:
236 #ifdef WIN32_PLATFORM_PSPC
237 // Pocket PC only Dialog title handling
238 const int nTitleHeight;
239
240 CStdDialogBase() : nTitleHeight(T::GetTitleHeight())
241 { }
242
243 // Overloads
244 BOOL GetClientRect(LPRECT lpRect)
245 {
246 T* pT = static_cast<T*>(this);
247 ATLASSERT(pT->IsWindow());
248 BOOL bRes = ::GetClientRect(pT->m_hWnd, lpRect);
249 lpRect->top += nTitleHeight;
250 return bRes;
251 }
252
253 BOOL SetWindowText(LPCTSTR lpszString)
254 {
255 T* pT = static_cast<T*>(this);
256 ATLASSERT(pT->IsWindow());
257 BOOL bRes = ::SetWindowText(pT->m_hWnd, lpszString);
258 if (nTitleHeight != 0)
259 pT->DoPaintTitle();
260 return bRes;
261 }
262
263 // Overrideables
264 static const int GetTitleHeight()
265 {
266 #ifdef _WTL_CE_DRA
267 return DRA::SCALEY(24);
268 #else // !_WTL_CE_DRA
269 CWindowDC dc(NULL);
270 return dc.GetDeviceCaps(LOGPIXELSY) >> 2; // LOGPIXELSY * 24 / 9 6,
271 #endif // !_WTL_CE_DRA
272 }
273
274 // Title painting
275 bool DoPaintTitle()
276 {
277 T* pT = static_cast<T*>(this);
278 ATLASSERT(pT->IsWindow());
279 TCHAR sTitle[48];
280
281 // Preparation
282 CPaintDC dc(pT->m_hWnd);
283 CFont fontTitle = AtlCreateBoldFont();
284 CFontHandle fontOld = dc.SelectFont(fontTitle);
285 dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHT));
286 int nLen = pT->GetWindowText(sTitle, 48);
287 int nWidth = dc.GetDeviceCaps(HORZRES);
288
289 // Display title text
290 RECT rTitle = { 0, 0, nWidth, nTitleHeight };
291 dc.FillRect(&rTitle, COLOR_3DHIGHLIGHT);
292 #ifdef _WTL_CE_DRA
293 rTitle.left = DRA::SCALEX(8);
294 #else // !_WTL_CE_DRA
295 rTitle.left = nTitleHeight / 3; // 8 == 24 / 3
296 #endif // !_WTL_CE_DRA
297 dc.DrawText(sTitle, nLen, &rTitle, DT_VCENTER | DT_SINGLELINE);
298 dc.SelectFont(fontOld);
299
300 // Draw bottom line, 2 pixels thick if HI_RES_AWARE
301 CPenHandle penOld = dc.SelectStockPen(BLACK_PEN);
302 POINT line[4] = {{0, nTitleHeight}, {nWidth, nTitleHeight}, {0, nTitleHeight - 1}, {nWidth, nTitleHeight - 1}};
303
304 #ifdef _WTL_CE_DRA
305 int nSeg = DRA::SCALEY(1);
306 #else // !_WTL_CE_DRA
307 int nSeg = nTitleHeight / 24;
308 #endif // !_WTL_CE_DRA
309
310 dc.Polyline(line, nSeg <= 2 ? nSeg * 2 : 4);
311 dc.SelectPen(penOld);
312
313 return false;
314 }
315
316 // Title preparation: move the dialog controls down to make room for tit le
317 void DialogTitleInit()
318 {
319 T* pT = static_cast<T*>(this);
320 ATLASSERT(pT->IsWindow());
321
322 ATL::CWindow wCtl = pT->GetWindow(GW_CHILD);
323 while (wCtl.IsWindow())
324 {
325 RECT rCtl = { 0 };
326 wCtl.GetWindowRect(&rCtl);
327 ::MapWindowPoints(NULL, pT->m_hWnd, (LPPOINT)&rCtl, 2);
328 ::OffsetRect(&rCtl, 0, nTitleHeight);
329 wCtl.MoveWindow(&rCtl, FALSE);
330 wCtl = wCtl.GetWindow(GW_HWNDNEXT);
331 }
332 }
333
334 // SIP management
335 void DoSipInfo()
336 {
337 T* pT = static_cast<T*>(this);
338 ATLASSERT(pT->IsWindow());
339
340 SIPINFO si = {sizeof(SIPINFO)};
341 SipGetInfo(&si);
342 if ((si.fdwFlags & SIPF_ON) ^ SIPF_ON)
343 si.rcVisibleDesktop.bottom = si.rcSipRect.bottom;
344 pT->MoveWindow(&si.rcVisibleDesktop, FALSE);
345 }
346
347 // Title painting handler
348 LRESULT OnPaintTitle(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ , BOOL& bHandled)
349 {
350 T* pT = static_cast<T*>(this);
351 return bHandled = nTitleHeight ? pT->DoPaintTitle() : FALSE;
352 }
353
354 // SIP handler
355 LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
356 {
357 T* pT = static_cast<T*>(this);
358 if (wParam == SPI_SETSIPINFO)
359 {
360 pT->DoSipInfo();
361 return TRUE;
362 }
363 return bHandled = FALSE;
364 }
365
366 #elif defined WIN32_PLATFORM_WFSP
367 // SmartPhone VK_TBACK key standard management
368 LRESULT OnHotKey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandl ed*/)
369 {
370 T* pT = static_cast<T*>(this);
371 const UINT uModif = (UINT)LOWORD(lParam);
372 const UINT uVirtKey = (UINT)HIWORD(lParam);
373
374 if(uVirtKey == VK_TBACK)
375 if (AtlIsEditFocus())
376 ::SHSendBackToFocusWindow(uMsg, wParam, lParam);
377 else if (uModif & MOD_KEYUP)
378 pT->StdCloseDialog(IDCANCEL);
379 return 1;
380 }
381
382 // SmartPhone MenuBar and VK_TBACK key initialization
383 void StdSPInit()
384 {
385 T* pT = static_cast<T*>(this);
386 HWND hMenuBar = ::SHFindMenuBar(pT->m_hWnd);
387
388 if (!hMenuBar && (t_shidiFlags & SHIDIF_DONEBUTTON))
389 hMenuBar = CreateMenuBar(ATL_IDM_MENU_DONE);
390
391 if(hMenuBar != NULL)
392 AtlActivateBackKey(hMenuBar);
393 }
394
395 void SetStaticBold()
396 {
397 T* pT = static_cast<T*>(this);
398 ATLASSERT(pT->IsWindow());
399
400 CFontHandle fontBold = AtlCreateBoldFont(pT->GetFont());
401
402 ATL::CWindow wCtl = pT->GetWindow(GW_CHILD);
403
404 while (wCtl.IsWindow())
405 {
406 if ((short int)wCtl.GetDlgCtrlID() == IDC_STATIC)
407 wCtl.SetFont(fontBold);
408 wCtl = wCtl.GetWindow(GW_HWNDNEXT);
409 }
410 }
411 #endif // WIN32_PLATFORM_WFSP
412
413 // Platform dependant initialization
414 void StdPlatformInit()
415 {
416 T* pT = static_cast<T*>(this);
417 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title initialization
418 if (nTitleHeight != 0)
419 pT->DialogTitleInit();
420 #elif defined(WIN32_PLATFORM_WFSP)
421 pT->StdSPInit();
422 SetStaticBold();
423 #endif // WIN32_PLATFORM_WFSP
424 }
425
426 // Menu bar creation
427 HWND CreateMenuBar(UINT uiMB = T::IDD, int nBmpImages = 0)
428 {
429 T* pT = static_cast<T*>(this);
430 return AtlCreateMenuBar(pT->m_hWnd, uiMB, 0, nBmpImages ? uiMB : 0, nBmpImages);
431 }
432
433 // Dialog closing
434 void StdCloseDialog(WORD wID)
435 {
436 T* pT = static_cast<T*>(this);
437 if (t_bModal)
438 ::EndDialog(pT->m_hWnd, wID);
439 else
440 pT->DestroyWindow();
441 }
442
443 // Shell dialog layout initialization
444 void StdShidInit()
445 {
446 T* pT = static_cast<T*>(this);
447 SHINITDLGINFO shidi = { SHIDIM_FLAGS, pT->m_hWnd, t_shidiFlags } ;
448 ::SHInitDialog(&shidi);
449 }
450
451 // IDC_INFOSTATIC background setting
452 LRESULT OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
453 {
454 if (::GetDlgCtrlID((HWND)lParam) == IDC_INFOSTATIC)
455 {
456 ::SetBkMode((HDC)wParam, TRANSPARENT);
457 return (LRESULT)::GetSysColorBrush(COLOR_INFOBK);
458 }
459 return bHandled = FALSE;
460 }
461
462 // Menu dialog ending
463 LRESULT OnMenuClose(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BO OL& /*bHandled*/)
464 {
465 T* pT = static_cast<T*>(this);
466 pT->StdCloseDialog((WORD)(wID - ID_MENU_OK + IDOK));
467 return 0;
468 }
469
470 // Standard dialog ending: may be used with any command
471 LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOO L& /*bHandled*/)
472 {
473 T* pT = static_cast<T*>(this);
474 pT->StdCloseDialog(wID);
475 return 0;
476 }
477 };
478
479
480 ///////////////////////////////////////////////////////////////////////////////
481 // CStdDialogImplBase - Base implementation of standard PPC/SmartPhone dialog
482
483 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true, cla ss TBase = ATL::CDialogImpl< T > >
484 class ATL_NO_VTABLE CStdDialogImplBase :
485 public TBase,
486 public CStdDialogBase<T, t_shidiFlags, t_bModal>
487 {
488 public:
489 #ifdef WIN32_PLATFORM_PSPC
490 BOOL GetClientRect(LPRECT lpRect)
491 {
492 return CStdDialogBase<T, t_shidiFlags, t_bModal>::GetClientRect( lpRect);
493 }
494
495 BOOL SetWindowText(LPCTSTR lpszString)
496 {
497 return CStdDialogBase<T, t_shidiFlags, t_bModal>::SetWindowText( lpszString);
498 }
499 #endif
500
501 BEGIN_MSG_MAP(CStdDialogImplBase)
502 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title and SIP
503 MESSAGE_HANDLER(WM_PAINT, OnPaintTitle)
504 MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
505 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
506 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey)
507 #endif
508 MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
509 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
510 COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, OnCloseCmd)
511 COMMAND_RANGE_HANDLER(ID_MENU_OK, ID_MENU_CANCEL, OnMenuClose)
512 END_MSG_MAP()
513
514 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ , BOOL& bHandled)
515 {
516 #ifdef _DEBUG
517 T* pT = static_cast<T*>(this);
518 ATLASSERT(t_bModal == pT->m_bModal);
519 #endif
520 StdPlatformInit();
521 StdShidInit();
522 return bHandled = FALSE;
523 }
524 };
525
526 ///////////////////////////////////////////////////////////////////////////////
527 // CStdDialogImpl - implementation of standard PPC/SmartPhone dialog
528
529 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true >
530 class ATL_NO_VTABLE CStdDialogImpl : public CStdDialogImplBase< T, t_shidiFlags, t_bModal>
531 {};
532
533 ///////////////////////////////////////////////////////////////////////////////
534 // CStdIndirectDialogImpl - implementation of standard indirect PPC/SmartPhone d ialog
535
536 #if defined __ATLDLGS_H__
537
538 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true>
539 class ATL_NO_VTABLE CStdIndirectDialogImpl :
540 public CIndirectDialogImpl< T, CMemDlgTemplate, CStdDialogImpl<T, t_shid iFlags, t_bModal> >
541 {
542 public:
543 typedef CIndirectDialogImpl< T, CMemDlgTemplate, CStdDialogImpl<T, t_shi diFlags, t_bModal> > _baseClass;
544 typedef CStdDialogImpl<T, t_shidiFlags, t_bModal> _baseStd;
545
546 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow(), LPARAM dwInitPara m = NULL)
547 {
548 ATLASSERT(t_bModal);
549
550 if (!m_Template.IsValid())
551 CreateTemplate();
552
553 if (m_Template.IsTemplateEx())
554 {
555 if (m_Template.GetTemplateExPtr()->style & DS_CENTER)
556 {
557 ATLASSERT(m_Template.GetTemplateExPtr()->style ^ WS_CHILD);
558 GetTemplateExPtr()->style |= WS_POPUP;
559 }
560 }
561 else
562 {
563 if (m_Template.GetTemplatePtr()->style & DS_CENTER)
564 {
565 ATLASSERT(m_Template.GetTemplatePtr()->style ^ W S_CHILD);
566 m_Template.GetTemplatePtr()->style |= WS_POPUP;
567 }
568 }
569
570 return _baseClass::DoModal(hWndParent, dwInitParam);
571 }
572
573 HWND Create(HWND hWndParent, LPARAM dwInitParam = NULL)
574 {
575 ATLASSERT(!t_bModal);
576
577 if (!m_Template.IsValid())
578 CreateTemplate();
579
580 if (m_Template.IsTemplateEx())
581 {
582 if (GetTemplateExPtr()->style & DS_CENTER)
583 {
584 ATLASSERT(GetTemplateExPtr()->style ^ WS_CHILD);
585 GetTemplateExPtr()->style |= WS_POPUP;
586 }
587 }
588 else
589 {
590 if (GetTemplatePtr()->style & DS_CENTER)
591 {
592 ATLASSERT(GetTemplatePtr()->style ^ WS_CHILD);
593 GetTemplatePtr()->style |= WS_POPUP;
594 }
595 }
596
597 return _baseClass::Create(hWndParent, dwInitParam);
598 }
599
600 BEGIN_MSG_MAP(CStdIndirectDialogImpl)
601 CHAIN_MSG_MAP(_baseStd)
602 END_MSG_MAP()
603
604 };
605
606 #endif // defined __ATLDLGS_H__
607
608 #ifndef _ATL_NO_HOSTING
609
610 ///////////////////////////////////////////////////////////////////////////////
611 // CStdAxDialogImpl - implementation of standard PPC/SmartPhone AxDialog
612
613 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true >
614 class ATL_NO_VTABLE CStdAxDialogImpl : public CStdDialogImplBase< T, t_shidiFlag s, t_bModal, ATL::CAxDialogImpl< T > >
615 {};
616 #endif // _ATL_NO_HOSTING
617
618 ///////////////////////////////////////////////////////////////////////////////
619 // CStdSimpleDialog - standard PPC/SmartPhone simple dialog with SHIDIF_xxx flag s
620
621 template <WORD t_wDlgTemplateID, UINT t_shidiFlags = WTL_STD_SHIDIF>
622 class CStdSimpleDialog :
623 public ATL::CSimpleDialog<t_wDlgTemplateID, FALSE>,
624 public CStdDialogBase<CStdSimpleDialog<t_wDlgTemplateID, t_shidi Flags>, t_shidiFlags>
625 {
626 public:
627 typedef CStdDialogBase<CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags>, t_shidiFlags> baseClass;
628
629 #ifdef WIN32_PLATFORM_PSPC
630 BOOL GetClientRect(LPRECT lpRect)
631 {
632 return baseClass::GetClientRect(lpRect);
633 }
634
635 BOOL SetWindowText(LPCTSTR lpszString)
636 {
637 return baseClass::SetWindowText(lpszString);
638 }
639 #endif
640
641 BEGIN_MSG_MAP(CStdSimpleDialog)
642 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title and SIP
643 MESSAGE_HANDLER(WM_PAINT, OnPaintTitle)
644 MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
645 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
646 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey)
647 #endif
648 MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
649 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
650 COMMAND_RANGE_HANDLER(ID_MENU_OK, ID_MENU_CANCEL, OnMenuClose)
651 COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, baseClass::OnCloseCmd)
652 END_MSG_MAP()
653
654 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ , BOOL& bHandled)
655 {
656 StdPlatformInit();
657 StdShidInit();
658 return bHandled = FALSE;
659 }
660 };
661
662 ///////////////////////////////////////////////////////////////////////////////
663 // CStdDialogResizeImplBase - Base implementation of orientation resizing standa rd PPC/SmartPhone dialog
664
665 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true, cla ss TBase = ATL::CDialogImpl<T> >
666 class ATL_NO_VTABLE CStdDialogResizeImplBase :
667 public CStdDialogImplBase< T, t_shidiFlags, t_bModal, TBase>,
668 public CDialogResize<T>
669 {
670 public:
671 // Note: BEGIN_DLGRESIZE_MAP is required in the derived class.
672
673 BEGIN_MSG_MAP(CStdResizeDialogImplBase)
674 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title
675 MESSAGE_HANDLER(WM_PAINT, OnPaintTitle)
676 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
677 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey)
678 #endif
679 MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
680 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
681 COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, OnCloseCmd)
682 COMMAND_RANGE_HANDLER(ID_MENU_OK, ID_MENU_CANCEL, OnMenuClose)
683 CHAIN_MSG_MAP(CDialogResize< T >)
684 END_MSG_MAP()
685
686 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ , BOOL& bHandled)
687 {
688 #ifdef _DEBUG
689 T* pT = static_cast<T*>(this);
690 ATLASSERT(t_bModal == pT->m_bModal);
691 #endif
692 StdPlatformInit();
693 DlgResize_Init(FALSE);
694 StdShidInit();
695 return bHandled = FALSE;
696 }
697 };
698
699 ///////////////////////////////////////////////////////////////////////////////
700 // CStdDialogResizeImpl - implementation of orientation resizing standard PPC/Sm artPhone dialog
701
702 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true >
703 class ATL_NO_VTABLE CStdDialogResizeImpl : public CStdDialogResizeImplBase< T, t _shidiFlags, t_bModal>
704 {};
705
706 #ifndef _ATL_NO_HOSTING
707
708 ///////////////////////////////////////////////////////////////////////////////
709 // CStdAxDialogResizeImpl - implementation of orientation resizing standard PPC/ SmartPhone AxDialog
710
711 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true >
712 class ATL_NO_VTABLE CStdAxDialogResizeImpl : public CStdDialogResizeImplBase< T, t_shidiFlags, t_bModal, ATL::CAxDialogImpl<T> >
713 {};
714 #endif // _ATL_NO_HOSTING
715
716 ///////////////////////////////////////////////////////////////////////////////
717 // CStdSimpleDialogResizeImpl - implementation of standard resizing simple dialo g with SHIDIF_xxx flags
718
719 // Usage:
720 // class CMyDlg : public CStdSimpleDialogResize<CMyDlg,
721 // IDD_MYDLG, SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR>
722 // {
723 // public:
724 // BEGIN_DLGRESIZE_MAP(CMyDlg)
725 // ...
726 // END_DLGRESIZE_MAP()
727 // };
728
729 template <class T, WORD t_wDlgTemplateID, UINT t_shidiFlags = WTL_STD_SHIDIF>
730 class ATL_NO_VTABLE CStdSimpleDialogResizeImpl :
731 public CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags>,
732 public CDialogResize< T >
733 {
734 public:
735 typedef CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags>::baseClass base Class;
736
737 BEGIN_MSG_MAP(CStdSimpleDialogResizeImpl)
738 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title
739 MESSAGE_HANDLER(WM_PAINT, OnPaintTitle)
740 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
741 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey)
742 #endif
743 MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
744 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
745 COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, baseClass::OnCloseCmd)
746 COMMAND_RANGE_HANDLER(ID_MENU_OK, ID_MENU_CANCEL, OnMenuClose)
747 CHAIN_MSG_MAP(CDialogResize< T >)
748 END_MSG_MAP()
749
750 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ , BOOL& bHandled)
751 {
752 StdPlatformInit();
753 DlgResize_Init(FALSE);
754 StdShidInit();
755 return bHandled = FALSE;
756 }
757 };
758
759 #if defined(_WTL_CE_DRA) && defined(WIN32_PLATFORM_PSPC)
760
761 ///////////////////////////////////////////////////////////////////////////////
762 // CStdOrientedDialogBase - Oriented PPC standard dialog base class
763
764 template <class T>
765 class CStdOrientedDialogBase
766 {
767 public:
768 // Operation
769 BOOL SetOrientation(DRA::DisplayMode mode)
770 {
771 T* pT = static_cast<T*>(this);
772 ATLASSERT(pT->IsWindow());
773 ATLASSERT(mode == DRA::GetDisplayMode());
774
775 // Derived dialog must enumerate TWO dialog templates with the s ame control ids and types ie:
776 // enum { IDD = IDD_MYDLG, IDD_LANDSCAPE = IDD_MYDLG_L };
777 UINT iResource = (mode == DRA::Landscape)? T::IDD_LANDSCAPE : T: :IDD;
778
779 BOOL bRes = DRA::RelayoutDialog(ModuleHelper::GetResourceInstanc e(), pT->m_hWnd, MAKEINTRESOURCE(iResource));
780 pT->OnOrientation(mode);
781 return bRes;
782 }
783
784 // Override
785 void OnOrientation(DRA::DisplayMode /*mode*/)
786 {}
787
788 // Message handlers
789 LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
790 {
791 T* pT = static_cast<T*>(this);
792 ATLASSERT(pT->IsWindow());
793 if (wParam == SETTINGCHANGE_RESET)
794 {
795 SetOrientation(DRA::GetDisplayMode());
796 pT->StdPlatformInit();
797 pT->StdShidInit();
798 }
799 else if (wParam == SPI_SETSIPINFO)
800 {
801 pT->DoSipInfo();
802 return TRUE;
803 }
804 return bHandled = FALSE;
805 }
806 };
807
808 ///////////////////////////////////////////////////////////////////////////////
809 // CStdOrientedDialogImplBase - Oriented PPC standard dialog base implementation
810
811 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true, cla ss TBase = ATL::CDialogImpl<T> >
812 class ATL_NO_VTABLE CStdOrientedDialogImplBase :
813 public CStdDialogImplBase< T, t_shidiFlags, t_bModal, TBase>,
814 public CStdOrientedDialogBase<T>
815 {
816 public:
817 BEGIN_MSG_MAP(CStdOrientedDialogImpl)
818 MESSAGE_HANDLER(WM_PAINT, OnPaintTitle)
819 MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
820 MESSAGE_HANDLER(WM_SETTINGCHANGE, CStdOrientedDialogBase<T>::OnS ettingChange)
821 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
822 COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, OnCloseCmd)
823 COMMAND_RANGE_HANDLER(ID_MENU_OK, ID_MENU_CANCEL, OnMenuClose)
824 END_MSG_MAP()
825
826 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/ , BOOL& bHandled)
827 {
828 T* pT = static_cast<T*>(this);
829 #ifdef _DEBUG
830 ATLASSERT(t_bModal == pT->m_bModal);
831 #endif
832 if (DRA::GetDisplayMode() == DRA::Landscape)
833 SetOrientation(DRA::Landscape);
834 pT->StdPlatformInit();
835 pT->StdShidInit();
836 return bHandled = FALSE;
837 }
838 };
839
840 ///////////////////////////////////////////////////////////////////////////////
841 // CStdOrientedDialogImpl - Oriented PPC standard dialog implementation
842
843 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true >
844 class ATL_NO_VTABLE CStdOrientedDialogImpl : public CStdOrientedDialogImplBase< T, t_shidiFlags, t_bModal>
845 {};
846
847 #ifndef _ATL_NO_HOSTING
848 ///////////////////////////////////////////////////////////////////////////////
849 // CStdAxOrientedDialogImpl - Oriented PPC standard AxDialog implementation
850
851 template <class T, UINT t_shidiFlags = WTL_STD_SHIDIF, bool t_bModal = true >
852 class ATL_NO_VTABLE CStdAxOrientedDialogImpl : public CStdOrientedDialogImplBase < T, t_shidiFlags, t_bModal, ATL::CAxDialogImpl<T> >
853 {};
854 #endif // _ATL_NO_HOSTING
855
856 ///////////////////////////////////////////////////////////////////////////////
857 // CStdSimpleOrientedDialog - Standard simple orientable dialog
858
859 template <WORD t_wDlgTemplateID, WORD t_wDlgLandscapeID, UINT t_shidiFlags = WTL _STD_SHIDIF>
860 class CStdSimpleOrientedDialog :
861 public CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags>,
862 public CStdOrientedDialogBase<CStdSimpleOrientedDialog<t_wDlgTem plateID, t_wDlgLandscapeID, t_shidiFlags> >
863 {
864 public:
865 typedef CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags>::baseClass base Class;
866 typedef CStdOrientedDialogBase<CStdSimpleOrientedDialog<t_wDlgTemplateID , t_wDlgLandscapeID, t_shidiFlags> > baseOriented;
867
868 enum {IDD = t_wDlgTemplateID, IDD_LANDSCAPE = t_wDlgLandscapeID};
869
870 BEGIN_MSG_MAP(CStdSimpleDialog)
871 MESSAGE_HANDLER(WM_PAINT, OnPaintTitle)
872 MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
873 MESSAGE_HANDLER(WM_SETTINGCHANGE, baseOriented::OnSettingChange)
874 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
875 COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, baseClass::OnCloseCmd)
876 COMMAND_RANGE_HANDLER(ID_MENU_OK, ID_MENU_CANCEL, OnMenuClose)
877 END_MSG_MAP()
878
879 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* lParam*/, BOOL& bHandled)
880 {
881 if (DRA::GetDisplayMode() == DRA::Landscape)
882 SetOrientation(DRA::Landscape);
883 StdPlatformInit();
884 StdShidInit();
885 return bHandled = FALSE;
886 }
887 };
888
889 #endif // _WTL_CE_DRA
890
891
892 #endif // _WTL_CE_NO_DIALOGS
893
894
895 // --- PPC/SmartPhone application window and helpers ---
896
897 #ifndef _WTL_CE_NO_APPWINDOW
898
899 ///////////////////////////////////////////////////////////////////////////////
900 // CAppInfoBase - Helper for application state save/restore to registry
901
902 class CAppInfoBase
903 {
904 public:
905 ATL::CRegKey m_Key;
906
907 CAppInfoBase(ATL::_U_STRINGorID sAppKey)
908 {
909 m_Key.Create(HKEY_CURRENT_USER, sAppKey.m_lpstr);
910 ATLASSERT(m_Key.m_hKey);
911 }
912
913 template <class V>
914 LONG Save(V& val, ATL::_U_STRINGorID sName)
915 {
916 return ::RegSetValueEx(m_Key, sName.m_lpstr, 0, REG_BINARY, (LPB YTE)&val, sizeof(V));
917 }
918
919 template <class V>
920 LONG Save(int nb, V& val0, ATL::_U_STRINGorID sName)
921 {
922 return ::RegSetValueEx(m_Key, sName.m_lpstr, 0, REG_BINARY, (LPB YTE)&val0, nb * sizeof(V));
923 }
924
925 template <class V>
926 LONG Restore(V& val, ATL::_U_STRINGorID sName)
927 {
928 DWORD valtype;
929 DWORD bufSize = sizeof(V);
930 return ::RegQueryValueEx(m_Key, sName.m_lpstr, 0, &valtype, (LPB YTE)&val, &bufSize);
931 }
932
933 template <class V>
934 LONG Restore(int nb, V& val0, ATL::_U_STRINGorID sName)
935 {
936 DWORD valtype;
937 DWORD bufSize = nb * sizeof(V);
938 return ::RegQueryValueEx(m_Key, sName.m_lpstr, 0, &valtype, (LPB YTE)&val0, &bufSize);
939 }
940
941 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
942 #if (_ATL_VER < 0x0800)
943 LONG Save(_CSTRING_NS::CString& sval, ATL::_U_STRINGorID sName)
944 {
945 return m_Key.SetValue(sval, sName.m_lpstr);
946 }
947
948 LONG Restore(_CSTRING_NS::CString& sval, ATL::_U_STRINGorID sName)
949 {
950 DWORD size = MAX_PATH;
951 LONG res = m_Key.QueryValue(sval.GetBuffer(size), sName.m_lpstr, &size);
952 sval.ReleaseBuffer();
953 return res;
954 }
955 #else // !(_ATL_VER < 0x0800)
956 LONG Save(_CSTRING_NS::CString& sval, ATL::_U_STRINGorID sName)
957 {
958 return m_Key.SetStringValue(sName.m_lpstr, sval);
959 }
960
961 LONG Restore(_CSTRING_NS::CString& sval, ATL::_U_STRINGorID sName)
962 {
963 DWORD size = MAX_PATH;
964 LONG res = m_Key.QueryStringValue(sName.m_lpstr, sval.GetBuffer( size), &size);
965 sval.ReleaseBuffer();
966 return res;
967 }
968 #endif // !(_ATL_VER < 0x0800)
969 #else
970 #pragma message("Warning: CAppInfoBase compiles without CString support. Do no t use CString in Save or Restore.")
971 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
972
973 #if (_ATL_VER < 0x0800)
974 LONG Save(LPCTSTR sval, ATL::_U_STRINGorID sName)
975 {
976 return m_Key.SetValue(sval, sName.m_lpstr);
977 }
978
979 LONG Restore(LPTSTR sval, ATL::_U_STRINGorID sName, DWORD *plength)
980 {
981 return m_Key.QueryValue(sval, sName.m_lpstr, plength);
982 }
983 #else // !(_ATL_VER < 0x0800)
984 LONG Save(LPCTSTR sval, ATL::_U_STRINGorID sName)
985 {
986 return m_Key.SetStringValue(sName.m_lpstr, sval);
987 }
988
989 LONG Restore(LPTSTR sval, ATL::_U_STRINGorID sName, DWORD *plength)
990 {
991 return m_Key.QueryStringValue(sName.m_lpstr, sval, plength);
992 }
993 #endif // !(_ATL_VER < 0x0800)
994
995 LONG Delete(ATL::_U_STRINGorID sName)
996 {
997 return m_Key.DeleteValue(sName.m_lpstr);
998 }
999 };
1000
1001
1002 ///////////////////////////////////////////////////////////////////////////////
1003 // CAppInfoT - CAppInfoBase constructed from a class with T::GetAppKey()
1004
1005 // Macro for declaring AppKey
1006 #define DECLARE_APPKEY(uAppKey) \
1007 static LPCTSTR GetAppKey() \
1008 { \
1009 static LPCTSTR sAppKey = ATL::_U_STRINGorID(uAppKey).m_lpstr; \
1010 return sAppKey; \
1011 }
1012
1013 template <class T>
1014 class CAppInfoT : public CAppInfoBase
1015 {
1016 public:
1017 CAppInfoT() : CAppInfoBase(T::GetAppKey()){}
1018 };
1019
1020
1021 ///////////////////////////////////////////////////////////////////////////////
1022 // CAppWindowBase - Base class for PPC/SmartPhone "well-behaved" application win dow or dialog
1023
1024 // Macros for declaring frame WNDCLASS and AppKey
1025 #define DECLARE_APP_FRAME_CLASS(WndClassName, uCommonResourceID, uAppKey) \
1026 DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \
1027 DECLARE_APPKEY(uAppKey)
1028
1029 #define DECLARE_APP_FRAME_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd , uAppKey) \
1030 DECLARE_FRAME_WND_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd ) \
1031 DECLARE_APPKEY(uAppKey)
1032
1033 template <class T>
1034 class CAppWindowBase
1035 {
1036 public:
1037 typedef class CAppInfoT< T > CAppInfo;
1038
1039 #ifndef WIN32_PLATFORM_WFSP
1040 SHACTIVATEINFO m_sai; // NoOp on SmartPhones
1041 #endif // WIN32_PLATFORM_WFSP
1042
1043 bool m_bHibernate;
1044
1045 CAppWindowBase< T >() : m_bHibernate(false)
1046 {
1047 #ifndef WIN32_PLATFORM_WFSP
1048 SHACTIVATEINFO sai = { sizeof(SHACTIVATEINFO) };
1049 m_sai = sai;
1050 #endif // WIN32_PLATFORM_WFSP
1051 };
1052
1053 // Same as WTL 7.1 AppWizard generated ActivatePreviousInstance + SendMe ssage WM_COPYDATA
1054 static HRESULT ActivatePreviousInstance(HINSTANCE hInstance, LPCTSTR lp strCmdLine, bool bDialog)
1055 {
1056 // requires T does DECLARE_APP_FRAME_CLASS, DECLARE_APP_FRAME_CL ASS_EX or DECLARE_APP_DLG_CLASS
1057 CFrameWndClassInfo& classInfo = T::GetWndClassInfo();
1058
1059 ATLVERIFY(::LoadString(hInstance, classInfo.m_uCommonResourceID, classInfo.m_szAutoName, sizeof(classInfo.m_szAutoName)/sizeof(classInfo.m_szAut oName[0])) != 0);
1060
1061 classInfo.m_wc.lpszClassName = classInfo.m_szAutoName;
1062
1063 const TCHAR* pszClass = classInfo.m_wc.lpszClassName;
1064
1065 if(NULL == pszClass || '\0' == *pszClass)
1066 {
1067 return E_FAIL;
1068 }
1069
1070 const DWORD dRetryInterval = 100;
1071 const int iMaxRetries = 25;
1072
1073 for(int i = 0; i < iMaxRetries; ++i)
1074 {
1075 HANDLE hMutex = CreateMutex(NULL, FALSE, pszClass);
1076
1077 DWORD dw = GetLastError();
1078
1079 if(NULL == hMutex)
1080 {
1081 HRESULT hr;
1082
1083 switch(dw)
1084 {
1085 case ERROR_INVALID_HANDLE:
1086 // A non-mutext object with this name al ready exists.
1087 hr = E_INVALIDARG;
1088 break;
1089 default:
1090 // This should never happen...
1091 hr = E_FAIL;
1092 }
1093
1094 return hr;
1095 }
1096
1097 // If the mutex already exists, then there should be ano ther instance running
1098 if(dw == ERROR_ALREADY_EXISTS)
1099 {
1100 CloseHandle(hMutex);
1101
1102 HWND hwnd = NULL;
1103 if (bDialog)
1104 hwnd = FindWindow(NULL, pszClass);
1105 else
1106 hwnd = FindWindow(pszClass, NULL);
1107
1108 if(hwnd == NULL)
1109 {
1110 Sleep(dRetryInterval);
1111 continue;
1112 }
1113 else
1114 {
1115 // Transmit our params to previous insta nce
1116 if (lpstrCmdLine && *lpstrCmdLine)
1117 {
1118 COPYDATASTRUCT cd = { NULL, size of(TCHAR) * (wcslen(lpstrCmdLine) + 1), (PVOID)lpstrCmdLine };
1119 ::SendMessage(hwnd, WM_COPYDATA, NULL, (LPARAM)&cd);
1120 }
1121 // Set the previous instance as the fore ground window
1122 if(0 != SetForegroundWindow(reinterpret_ cast<HWND>(reinterpret_cast<ULONG>(hwnd) | 0x1)))
1123 return S_FALSE;
1124 }
1125 }
1126 else
1127 {
1128 return S_OK;
1129 }
1130 }
1131 return S_OK;
1132 }
1133
1134 // Operations overriden in derived class
1135 bool AppHibernate(bool /*bHibernate*/)
1136 {
1137 return false;
1138 }
1139
1140 bool AppNewInstance(LPCTSTR /*lpstrCmdLine*/)
1141 {
1142 return false;
1143 }
1144
1145 void AppSave()
1146 {
1147 }
1148
1149 #ifdef WIN32_PLATFORM_WFSP
1150 void AppBackKey()
1151 {
1152 ::SHNavigateBack();
1153 }
1154 #endif
1155
1156 // Message map and handlers
1157 BEGIN_MSG_MAP(CAppWindowBase)
1158 MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
1159 #ifdef WIN32_PLATFORM_WFSP
1160 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey)
1161 #else
1162 MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
1163 #endif // WIN32_PLATFORM_WFSP
1164 MESSAGE_HANDLER(WM_HIBERNATE, OnHibernate)
1165 MESSAGE_HANDLER(WM_COPYDATA, OnNewInstance)
1166 MESSAGE_HANDLER(WM_CLOSE, OnClose)
1167 END_MSG_MAP()
1168
1169 LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bH andled)
1170 {
1171 T* pT = static_cast<T*>(this);
1172 if (m_bHibernate)
1173 m_bHibernate = pT->AppHibernate(false);
1174 #ifndef WIN32_PLATFORM_WFSP
1175 ::SHHandleWMActivate(pT->m_hWnd, wParam, lParam, &m_sai, 0);
1176 #else
1177 wParam;
1178 lParam;
1179 #endif // WIN32_PLATFORM_WFSP
1180 return bHandled = FALSE;
1181 }
1182
1183 #ifdef WIN32_PLATFORM_WFSP
1184 // SmartPhone VK_TBACK key standard management
1185 LRESULT OnHotKey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandl ed*/)
1186 {
1187 T* pT = static_cast<T*>(this);
1188 const UINT uModif = (UINT)LOWORD(lParam);
1189 const UINT uVirtKey = (UINT)HIWORD(lParam);
1190 if(uVirtKey == VK_TBACK)
1191 if (AtlIsEditFocus())
1192 ::SHSendBackToFocusWindow(uMsg, wParam, lParam);
1193 else if (uModif & MOD_KEYUP)
1194 pT->AppBackKey();
1195 return 1;
1196 }
1197
1198 #else // !WIN32_PLATFORM_WFSP
1199 // PPC SIP handling
1200 LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOO L& bHandled)
1201 {
1202 T* pT = static_cast<T*>(this);
1203 bHandled = FALSE;
1204 return ::SHHandleWMSettingChange(pT->m_hWnd, wParam, lParam, &m_ sai);
1205 }
1206 #endif // !WIN32_PLATFORM_WFSP
1207
1208 LRESULT OnHibernate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
1209 {
1210 T* pT = static_cast<T*>(this);
1211 return m_bHibernate = pT->AppHibernate(true);
1212 }
1213
1214 LRESULT OnNewInstance(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, B OOL& /*bHandled*/)
1215 {
1216 T* pT = static_cast<T*>(this);
1217 PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT)lParam;
1218 return pT->AppNewInstance((LPCTSTR)pcds->lpData);
1219 }
1220
1221 LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOO L& bHandled)
1222 {
1223 T* pT = static_cast<T*>(this);
1224 pT->AppSave();
1225 bHandled = FALSE;
1226 return 1;
1227 }
1228 };
1229
1230
1231 ///////////////////////////////////////////////////////////////////////////////
1232 // CAppWindow - PPC/SmartPhone "well-behaved" application window class
1233
1234 template <class T>
1235 class CAppWindow : public CAppWindowBase< T >
1236 {
1237 public:
1238 // Same as WTL 7.1 AppWizard generated Run + lpstrCmdLine in CreateEx
1239 static int AppRun(LPTSTR lpstrCmdLine = NULL, int nCmdShow = SW_SHOWNORM AL)
1240 {
1241 CMessageLoop theLoop;
1242 _Module.AddMessageLoop(&theLoop);
1243
1244 T wndMain;
1245
1246 if(wndMain.CreateEx(NULL, NULL, 0, 0, lpstrCmdLine) == NULL)
1247 {
1248 ATLTRACE2(atlTraceUI, 0, _T("Main window creation failed !\n"));
1249 return 0;
1250 }
1251
1252 wndMain.ShowWindow(nCmdShow);
1253
1254 int nRet = theLoop.Run();
1255
1256 _Module.RemoveMessageLoop();
1257 return nRet;
1258 }
1259
1260 static HRESULT ActivatePreviousInstance(HINSTANCE hInstance, LPCTSTR lp strCmdLine)
1261 {
1262 return CAppWindowBase< T >::ActivatePreviousInstance(hInstance, lpstrCmdLine, false);
1263 }
1264 };
1265
1266
1267 #ifndef _WTL_CE_NO_DIALOGS
1268
1269 ///////////////////////////////////////////////////////////////////////////////
1270 // CAppDialog - PPC/SmartPhone "well-behaved" dialog application class
1271
1272 // Macro for declaring dialog WNDCLASS and AppKey
1273 #define DECLARE_APP_DLG_CLASS(WndClassName, uCommonResourceID, uAppKey) \
1274 static WTL::CFrameWndClassInfo& GetWndClassInfo() \
1275 { \
1276 static WTL::CFrameWndClassInfo wc = \
1277 { \
1278 { 0, (WNDPROC)StartDialogProc, \
1279 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL , WndClassName }, \
1280 NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceI D \
1281 }; \
1282 return wc; \
1283 }; \
1284 DECLARE_APPKEY(uAppKey)
1285
1286 template <class T>
1287 class CAppDialog : public CAppWindowBase< T >
1288 {
1289 public:
1290 static int AppRun(LPTSTR lpstrCmdLine = NULL, int nCmdShow = SW_SHOWNORM AL)
1291 {
1292 CMessageLoop theLoop;
1293 _Module.AddMessageLoop(&theLoop);
1294
1295 T dlgMain;
1296
1297 if(dlgMain.Create(NULL, (LPARAM)lpstrCmdLine) == NULL)
1298 {
1299 ATLTRACE2(atlTraceUI, 0, _T("Main dialog creation failed !\n"));
1300 return 0;
1301 }
1302
1303 dlgMain.ShowWindow(nCmdShow);
1304
1305 int nRet = theLoop.Run();
1306
1307 _Module.RemoveMessageLoop();
1308 return nRet;
1309 }
1310
1311 static HRESULT ActivatePreviousInstance(HINSTANCE hInstance, LPCTSTR lp strCmdLine)
1312 {
1313 return CAppWindowBase< T >::ActivatePreviousInstance(hInstance, lpstrCmdLine, true);
1314 };
1315 };
1316
1317 // PPC/SmartPhone standard application dialogs
1318
1319 #ifdef WIN32_PLATFORM_WFSP
1320 #define WTL_APP_SHIDIF WTL_SP_SHIDIF
1321 #else
1322 #define WTL_APP_SHIDIF WTL_STD_SHIDIF
1323 #endif
1324
1325 ///////////////////////////////////////////////////////////////////////////////
1326 // CAppStdDialogImplBase - Base implementation of standard application dialogs
1327
1328 template <class T, class TImplBase, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_b Modal = false>
1329 class ATL_NO_VTABLE CAppStdDialogImplBase :
1330 public TImplBase,
1331 public CAppDialog< T >
1332 {
1333 public:
1334 WTL_DLG_NOTITLE;
1335
1336 void StdCloseDialog(int nVal)
1337 {
1338 T* pT = static_cast<T*>(this);
1339 if (nVal != IDCANCEL)
1340 pT->AppSave();
1341 if (t_bModal == false)
1342 {
1343 pT->DestroyWindow();
1344 ::PostQuitMessage(nVal);
1345 }
1346 else
1347 ::EndDialog(pT->m_hWnd, nVal);
1348 }
1349
1350 BEGIN_MSG_MAP(CAppStdDialogImplBase)
1351 MESSAGE_HANDLER(WM_CLOSE, OnSystemClose)
1352 CHAIN_MSG_MAP(TImplBase)
1353 CHAIN_MSG_MAP(CAppDialog< T >)
1354 END_MSG_MAP()
1355
1356 LRESULT OnSystemClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam* /, BOOL& /*bHandled*/)
1357 {
1358 T* pT = static_cast<T*>(this);
1359 pT->StdCloseDialog(IDCANCEL);
1360 return 0;
1361 }
1362 };
1363
1364 ///////////////////////////////////////////////////////////////////////////////
1365 // CAppStdDialogImpl - Implementation of standard application dialog
1366
1367 template <class T, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_bModal = false>
1368 class ATL_NO_VTABLE CAppStdDialogImpl :
1369 public CAppStdDialogImplBase<T, CStdDialogImpl<T, t_shidiFlags, t_bModal>, t_shidiFlags, t_bModal>
1370 {};
1371
1372 ///////////////////////////////////////////////////////////////////////////////
1373 // CAppStdDialogResizeImpl - implementation of orientation resizing standard app lication dialog
1374
1375 template <class T, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_bModal = false>
1376 class ATL_NO_VTABLE CAppStdDialogResizeImpl :
1377 public CAppStdDialogImplBase<T, CStdDialogResizeImpl<T, t_shidiF lags, t_bModal>, t_shidiFlags, t_bModal>
1378 {};
1379
1380 #ifndef _ATL_NO_HOSTING
1381 ///////////////////////////////////////////////////////////////////////////////
1382 // CAppStdAxDialogImpl - Implementation of standard application AxDialog
1383
1384 template <class T, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_bModal = false>
1385 class ATL_NO_VTABLE CAppStdAxDialogImpl :
1386 public CAppStdDialogImplBase<T, CStdAxDialogImpl<T, t_shidiFlags , t_bModal>, t_shidiFlags, t_bModal>
1387 {};
1388
1389 ///////////////////////////////////////////////////////////////////////////////
1390 // CAppStdAxDialogResizeImpl - implementation of orientation resizing standard a pplication AxDialog
1391
1392 template <class T, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_bModal = false>
1393 class ATL_NO_VTABLE CAppStdAxDialogResizeImpl :
1394 public CAppStdDialogImplBase<T, CStdAxDialogResizeImpl<T, t_shid iFlags, t_bModal>, t_shidiFlags, t_bModal>
1395 {};
1396 #endif // _ATL_NO_HOSTING
1397
1398 #if defined(_WTL_CE_DRA) && defined(WIN32_PLATFORM_PSPC)
1399 ///////////////////////////////////////////////////////////////////////////////
1400 // CAppStdOrientedDialogImpl - implementation of oriented PPC standard applicati on dialog
1401
1402 template <class T, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_bModal = false>
1403 class ATL_NO_VTABLE CAppStdOrientedDialogImpl :
1404 public CAppStdDialogImplBase<T, CStdOrientedDialogImpl<T, t_shid iFlags, t_bModal>, t_shidiFlags, t_bModal>
1405 {};
1406
1407 #ifndef _ATL_NO_HOSTING
1408 ///////////////////////////////////////////////////////////////////////////////
1409 // CAppStdAxOrientedDialogImpl - implementation of oriented PPC standard applica tion AxDialog
1410
1411 template <class T, UINT t_shidiFlags = WTL_APP_SHIDIF, bool t_bModal = false>
1412 class ATL_NO_VTABLE CAppStdAxOrientedDialogImpl :
1413 public CAppStdDialogImplBase<T, CStdAxOrientedDialogImpl<T, t_sh idiFlags, t_bModal>, t_shidiFlags, t_bModal>
1414 {};
1415 #endif // _ATL_NO_HOSTING
1416
1417 #endif // defined(_WTL_CE_DRA) && defined(WIN32_PLATFORM_PSPC)
1418
1419 #endif // _WTL_CE_NO_DIALOGS
1420
1421 #endif // _WTL_CE_NO_APPWINDOW
1422
1423
1424 // --- Full screen support ---
1425
1426 #ifndef _WTL_CE_NO_FULLSCREEN
1427
1428 ///////////////////////////////////////////////////////////////////////////////
1429 // CFullScreenFrame - full screen frame implementation
1430
1431 template <class T, bool t_bHasSip = true>
1432 class CFullScreenFrame
1433 {
1434 public:
1435 bool m_bFullScreen;
1436
1437 CFullScreenFrame() : m_bFullScreen(false)
1438 { }
1439
1440 // Operation
1441 void SetFullScreen(bool bFull)
1442 {
1443 m_bFullScreen = bFull;
1444 ShowTaskBar(!bFull, false);
1445 ShowMenuBar(!bFull);
1446 }
1447
1448 // Manage TaskBar for modal dialogs and property sheets
1449 template <class D>
1450 int FSDoModal(D& dlg)
1451 {
1452 T* pT = static_cast<T*>(this);
1453 pT; // avoid level 4 warning
1454 ATLASSERT(pT->IsWindow());
1455 if (m_bFullScreen) // Show taskbar if hidden
1456 ShowTaskBar(true, false);
1457 int iRet = dlg.DoModal();
1458 if (m_bFullScreen) // Hide taskbar if restored
1459 ShowTaskBar(false);
1460 return iRet;
1461 }
1462
1463 // Implementation
1464 void ShowMenuBar(bool bShow)
1465 {
1466 T* pT = static_cast<T*>(this);
1467 ATLASSERT(pT->IsWindow());
1468 ATL::CWindow MenuBar = pT->m_hWndCECommandBar;
1469 ATLASSERT(MenuBar.IsWindow());
1470 MenuBar.ShowWindow(bShow ? SW_SHOWNORMAL : SW_HIDE);
1471 pT->SizeToMenuBar();
1472 }
1473
1474 void ShowTaskBar(bool bShow, bool bRepaint = true)
1475 {
1476 T* pT = static_cast<T*>(this);
1477 ATLASSERT(pT->IsWindow());
1478 RECT rect = { 0 };
1479 SystemParametersInfo(SPI_GETWORKAREA, NULL, &rect, FALSE);
1480 if (!bShow)
1481 rect.top = 0;
1482
1483 #ifdef WIN32_PLATFORM_PSPC // Pocket PC code
1484 UINT uShow = t_bHasSip ? SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON : SHFS_SHOWTASKBAR | SHFS_HIDESIPBUTTON;
1485 SHFullScreen(pT->m_hWnd, bShow ? uShow : SHFS_HIDETASKBAR | SHFS _HIDESIPBUTTON);
1486 #elif _WIN32_WCE > 0x500 // Smartphone 2005 code
1487 SHFullScreen(pT->m_hWnd, bShow ? SHFS_SHOWTASKBAR : SHFS_HIDETAS KBAR);
1488 #else // Smartphone 2003
1489 HWND hTaskBar = FindWindow(_T("tray"), NULL);
1490 ATLASSERT(::IsWindow(hTaskBar));
1491 ::ShowWindow(hTaskBar, bShow ? SW_SHOW : SW_HIDE);
1492 #endif // WIN32_PLATFORM_PSPC
1493
1494 pT->MoveWindow(&rect, bRepaint);
1495 }
1496
1497 // Message map and handler
1498 BEGIN_MSG_MAP(CFullScreenFrame)
1499 MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange)
1500 MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
1501 END_MSG_MAP()
1502
1503 LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
1504 {
1505 #ifndef SETTINGCHANGE_RESET // not defined for PPC 2002
1506 #define SETTINGCHANGE_RESET SPI_SETWORKAREA
1507 #endif
1508 if (m_bFullScreen && (wParam & SETTINGCHANGE_RESET))
1509 SetFullScreen(m_bFullScreen);
1510 return bHandled = FALSE;
1511 }
1512
1513 LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & bHandled)
1514 {
1515 if (m_bFullScreen)
1516 {
1517 ShowTaskBar(!wParam);
1518 ShowMenuBar(!wParam);
1519 }
1520 return bHandled = FALSE;
1521 }
1522 };
1523
1524 #endif // _WTL_CE_NO_FULLSCREEN
1525
1526
1527 // --- WinCE zoom support ---
1528
1529 #ifndef _WTL_CE_NO_ZOOMSCROLL
1530
1531 ///////////////////////////////////////////////////////////////////////////////
1532 // CZoomScrollImpl - WinCE zooming implementation on top of CScrollImpl
1533
1534 template <class T>
1535 class CZoomScrollImpl: public CScrollImpl< T >
1536 {
1537 public:
1538 // Data members
1539 _WTYPES_NS::CSize m_sizeTrue;
1540 double m_fzoom;
1541
1542 // Creation
1543 CZoomScrollImpl() : m_sizeTrue(0), m_fzoom(1.)
1544 { }
1545
1546 // Zoom operations and access
1547 void SetZoomScrollSize(_WTYPES_NS::CSize sizeTrue, double fzoom = 1., BO OL bRedraw = TRUE)
1548 {
1549 ATLASSERT(fzoom > 0.);
1550 m_sizeTrue = sizeTrue;
1551 m_fzoom = fzoom;
1552
1553 CScrollImpl< T >::SetScrollSize(sizeTrue / fzoom, bRedraw);
1554 }
1555
1556 void SetZoomScrollSize(int cx, int cy, double fzoom=1., BOOL bRedraw = T RUE)
1557 {
1558 SetZoomScrollSize(_WTYPES_NS::CSize(cx, cy), fzoom, bRedraw);
1559 }
1560
1561 void SetZoom(double fzoom, BOOL bRedraw = TRUE)
1562 {
1563 _WTYPES_NS::CPoint ptCenter = WndtoTrue(m_sizeClient / 2);
1564 _WTYPES_NS::CSize sizePage = GetScrollPage();
1565 _WTYPES_NS::CSize sizeLine = GetScrollLine();
1566
1567 SetZoomScrollSize(GetScrollSize(), fzoom, bRedraw);
1568
1569 SetScrollLine(sizeLine);
1570 SetScrollPage(sizePage);
1571 _WTYPES_NS::CPoint ptOffset = ptCenter - (m_sizeClient / 2) * fz oom;
1572 SetScrollOffset(ptOffset, bRedraw);
1573 }
1574
1575 double GetZoom()
1576 {
1577 return m_fzoom;
1578 }
1579
1580 // CScrollImpl overrides
1581 void SetScrollOffset(int x, int y, BOOL bRedraw = TRUE)
1582 {
1583 CScrollImpl< T >::SetScrollOffset((int)(x / m_fzoom), (int)(y / m_fzoom), bRedraw);
1584 }
1585
1586 void SetScrollOffset(POINT ptOffset, BOOL bRedraw = TRUE)
1587 {
1588 SetScrollOffset(ptOffset.x, ptOffset.y, bRedraw);
1589 }
1590
1591 void GetScrollOffset(POINT& ptOffset)
1592 {
1593 ptOffset.x = (LONG)(m_ptOffset.x * m_fzoom);
1594 ptOffset.y = (LONG)(m_ptOffset.y * m_fzoom);
1595 }
1596
1597 void SetScrollSize(int cx, int cy, BOOL bRedraw = TRUE)
1598 {
1599 SetZoomScrollSize(cx, cy, GetZoom(), bRedraw);
1600 }
1601
1602 void SetScrollSize(SIZE sizeTrue, BOOL bRedraw = TRUE)
1603 {
1604 SetZoomScrollSize(sizeTrue, GetZoom(), bRedraw);
1605 }
1606
1607 void GetScrollSize(SIZE& sizeTrue) const
1608 {
1609 sizeTrue = m_sizeTrue;
1610 }
1611
1612 void SetScrollPage(int cxPage, int cyPage)
1613 {
1614 SetScrollPage(_WTYPES_NS::CSize(cxPage, cyPage));
1615 }
1616
1617 void SetScrollPage(SIZE sizePage)
1618 {
1619 CScrollImpl< T >::SetScrollPage(sizePage / m_fzoom);
1620 }
1621
1622 void GetScrollPage(SIZE& sizePage) const
1623 {
1624 sizePage = m_sizePage * m_fzoom;
1625 }
1626
1627 void SetScrollLine(int cxLine, int cyLine)
1628 {
1629 SetScrollLine(_WTYPES_NS::CSize(cxLine, cyLine));
1630 }
1631
1632 void SetScrollLine(SIZE sizeLine)
1633 {
1634 CScrollImpl< T >::SetScrollLine(sizeLine / m_fzoom);
1635 }
1636
1637 void GetScrollLine(SIZE& sizeLine) const
1638 {
1639 sizeLine = m_sizeLine * m_fzoom;
1640 }
1641
1642 // Data access complements
1643 _WTYPES_NS::CSize GetScrollSize()
1644 {
1645 return m_sizeTrue;
1646 }
1647
1648 _WTYPES_NS::CSize GetScrollPage()
1649 {
1650 return m_sizePage * m_fzoom;
1651 }
1652
1653 _WTYPES_NS::CSize GetScrollLine()
1654 {
1655 return m_sizeLine * m_fzoom;
1656 }
1657
1658 _WTYPES_NS::CPoint GetScrollOffset()
1659 {
1660 return (_WTYPES_NS::CSize)m_ptOffset * m_fzoom;
1661 }
1662
1663 // Helper coordinate functions
1664 _WTYPES_NS::CPoint WndtoTrue(CPoint ptW)
1665 {
1666 return (_WTYPES_NS::CSize)ptW * GetZoom() + GetScrollOffset();
1667 }
1668
1669 void WndtoTrue(LPPOINT aptW, int nPts) // in place coord transformatio n
1670 {
1671 for (int i = 0 ; i < nPts ; i++)
1672 aptW[i] = WndtoTrue(aptW[i]);
1673 }
1674
1675 void WndtoTrue(LPRECT prectW) // in place coord transformation
1676 {
1677 WndtoTrue((LPPOINT)prectW, 2);
1678 }
1679
1680 _WTYPES_NS::CPoint TruetoWnd(CPoint ptT)
1681 {
1682 return (ptT - GetScrollOffset()) / GetZoom();
1683 }
1684
1685 void TruetoWnd(LPPOINT aptT, int nPts) // in place coord transformatio n
1686 {
1687 for (int i = 0 ; i < nPts ; i++)
1688 aptT[i] = TruetoWnd(aptT[i]);
1689 }
1690
1691 void TruetoWnd(LPRECT prectT) // in place coord transformation
1692 {
1693 TruetoWnd((LPPOINT)prectT, 2);
1694 }
1695
1696 // Drawing operations : assume adequate setting of data members
1697 BOOL Draw(HBITMAP hbm, HDC hdestDC, DWORD dwROP = SRCCOPY)
1698 {
1699 CDC memDC = CreateCompatibleDC(hdestDC);
1700 CBitmapHandle bmpOld = memDC.SelectBitmap(hbm);
1701 BOOL bRes = Draw(memDC, hdestDC, dwROP);
1702 memDC.SelectBitmap(bmpOld);
1703 return bRes;
1704 }
1705
1706 BOOL Draw(HDC hsourceDC, HDC hdestDC, DWORD dwROP = SRCCOPY)
1707 {
1708 CDCHandle destDC = hdestDC;
1709 destDC.SetViewportOrg(0,0);
1710 _WTYPES_NS::CPoint ptOffset = GetScrollOffset();
1711 _WTYPES_NS::CSize sizeZClient = m_sizeClient * GetZoom();
1712 return destDC.StretchBlt(0, 0, m_sizeClient.cx, m_sizeClient.cy, hsourceDC, ptOffset.x, ptOffset.y, sizeZClient.cx, sizeZClient.cy, dwROP);
1713 }
1714
1715 #ifdef _IMAGING_H
1716 BOOL Draw(IImage* pIImage, HDC hdestDC)
1717 {
1718 CDCHandle destDC = hdestDC;
1719 destDC.SetViewportOrg(0,0);
1720 return SUCCEEDED(pIImage->Draw(destDC, _WTYPES_NS::CRect(-_WTYPE S_NS::CPoint(m_ptOffset), m_sizeAll), NULL));
1721 }
1722 #endif
1723
1724 // Message map and handlers
1725 BEGIN_MSG_MAP(CZoomScrollImpl< T >)
1726 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
1727 CHAIN_MSG_MAP(CScrollImpl< T >)
1728 END_MSG_MAP()
1729
1730 LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BO OL& bHandled)
1731 {
1732 T* pT = static_cast<T*>(this);
1733 ATLASSERT(::IsWindow(pT->m_hWnd));
1734 if ((GetScrollExtendedStyle() & SCRL_ERASEBACKGROUND))
1735 {
1736 _WTYPES_NS::CRect rect;
1737 pT->GetClientRect(rect);
1738 _WTYPES_NS::CSize sizeClient=rect.Size();
1739
1740 if (m_sizeAll.cx < sizeClient.cx || m_sizeAll.cy < sizeC lient.cy)
1741 {
1742 CDCHandle hdc = (HDC)wParam;
1743 HBRUSH hbr = GetSysColorBrush((int)T::GetWndClas sInfo().m_wc.hbrBackground - 1);
1744
1745 if (m_sizeAll.cx < sizeClient.cx)
1746 {
1747 _WTYPES_NS::CRect rectBG(_WTYPES_NS::CPo int(m_sizeAll.cx, 0), sizeClient);
1748 hdc.FillRect(rectBG, hbr);
1749 }
1750
1751 if (m_sizeAll.cy < sizeClient.cy)
1752 {
1753 _WTYPES_NS::CRect rectBG(_WTYPES_NS::CPo int(0, m_sizeAll.cy), sizeClient);
1754 hdc.FillRect(rectBG, hbr);
1755 }
1756 }
1757 }
1758 else
1759 {
1760 bHandled = FALSE;
1761 }
1762
1763 return 1;
1764 }
1765 };
1766
1767 #endif // _WTL_CE_NO_ZOOMSCROLL
1768
1769 #ifndef _WTL_CE_NO_CONTROLS
1770
1771 // --- PPC bottom TabView control ---
1772
1773 #if defined(__ATLCTRLX_H__) && defined(WIN32_PLATFORM_PSPC)
1774
1775 ///////////////////////////////////////////////////////////////////////////////
1776 // CBottomTabViewImpl
1777
1778 template <class T, class TBase = ATL::CWindow, class TWinTraits = ATL::CControlW inTraits>
1779 class ATL_NO_VTABLE CBottomTabViewImpl : public CTabViewImpl<T, TBase, TWinTrait s>
1780 {
1781 public:
1782 DECLARE_WND_CLASS_EX(NULL, 0, COLOR_APPWORKSPACE)
1783
1784 // Implementation overrideables
1785 bool CreateTabControl()
1786 {
1787 m_tab.Create(m_hWnd, rcDefault, NULL, WS_CHILD | TCS_BOTTOM, 0, m_nTabID);
1788
1789 ATLASSERT(m_tab.m_hWnd != NULL);
1790 if(m_tab.m_hWnd == NULL)
1791 return false;
1792
1793 m_tab.SendMessage(CCM_SETVERSION, COMCTL32_VERSION);
1794 m_tab.SetItemExtra(sizeof(TABVIEWPAGE));
1795
1796 T* pT = static_cast<T*>(this);
1797 m_cyTabHeight = pT->CalcTabHeight();
1798
1799 return true;
1800 }
1801
1802 int CalcTabHeight()
1803 {
1804 int nCount = m_tab.GetItemCount();
1805 TCITEMEXTRA tcix = { 0 };
1806 tcix.tciheader.mask = TCIF_TEXT;
1807 tcix.tciheader.pszText = _T("NS");
1808 int nIndex = m_tab.InsertItem(nCount, tcix);
1809
1810 RECT rect = { 0 };
1811 SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
1812 RECT rcWnd = rect;
1813
1814 m_tab.AdjustRect(FALSE, &rect);
1815 rcWnd.top = rect.bottom;
1816 ::AdjustWindowRectEx(&rcWnd, m_tab.GetStyle(), FALSE, m_tab.GetE xStyle());
1817 m_tab.DeleteItem(nIndex);
1818
1819 return rcWnd.bottom - rcWnd.top;
1820 }
1821
1822 void UpdateLayout()
1823 {
1824 RECT rect;
1825 GetClientRect(&rect);
1826
1827 if(m_tab.IsWindow() && ((m_tab.GetStyle() & WS_VISIBLE) != 0))
1828 m_tab.SetWindowPos(NULL, 0, rect.bottom - m_cyTabHeight, rect.right - rect.left, m_cyTabHeight, SWP_NOZORDER /*| SWP_SHOWWINDOW*/);
1829
1830 if(m_nActivePage != -1)
1831 ::SetWindowPos(GetPageHWND(m_nActivePage), NULL, 0, 0, rect.right - rect.left, rect.bottom - m_cyTabHeight, SWP_NOZORDER);
1832 }
1833
1834 };
1835
1836 class CBottomTabView : public CBottomTabViewImpl<CBottomTabView>
1837 {
1838 public:
1839 DECLARE_WND_CLASS_EX(_T("WTL_BottomTabView"), 0, COLOR_APPWORKSPACE)
1840 };
1841
1842 #endif // defined(__ATLCTRLX_H__) && defined(WIN32_PLATFORM_PSPC)
1843
1844
1845 // --- PPC/SmartPhone controls ---
1846
1847 ////////////////////////////////////////////////////////////////////////////////
1848 // These are wrapper classes for the Pocket PC 2002/2003 and SmartPhone 2003 con trols
1849 // To implement a window based on a control, use following:
1850 // Example: Implementing a window based on a Html control
1851 //
1852 // class CMyHtml : CWindowImpl<CMyHtml, CHtmlCtrl>
1853 // {
1854 // public:
1855 // BEGIN_MSG_MAP(CMyHtml)
1856 // // put your message handler entries here
1857 // END_MSG_MAP()
1858 // };
1859 ///////////////////////////////////////////////////////////////////////////////
1860
1861 ///////////////////////////////////////////////////////////////////////////////
1862 // CHtmlCtrl
1863
1864 template <class TBase>
1865 class CHtmlCtrlT : public TBase
1866 {
1867 public:
1868 // Constructors
1869 CHtmlCtrlT(HWND hWnd = NULL) : TBase(hWnd)
1870 { }
1871
1872 CHtmlCtrlT< TBase >& operator =(HWND hWnd)
1873 {
1874 m_hWnd = hWnd;
1875 return *this;
1876 }
1877
1878 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN ame = NULL,
1879 DWORD dwStyle = 0, DWORD dwExStyle = 0,
1880 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
1881 {
1882 HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_ lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
1883 ATLASSERT(hWnd != NULL); // Did you remember to call InitHTMLC ontrol(hInstance) ??
1884 return hWnd;
1885 }
1886
1887 // Attributes
1888 static LPCTSTR GetWndClassName()
1889 {
1890 return WC_HTML;
1891 }
1892
1893 #if (_WIN32_WCE >= 400)
1894 void AddStyle(LPCWSTR pszStyle)
1895 {
1896 ATLASSERT(::IsWindow(m_hWnd));
1897 ::SendMessage(m_hWnd, DTM_ADDSTYLE, 0, (LPARAM)pszStyle);
1898 }
1899 #endif // (_WIN32_WCE >= 400)
1900
1901 void AddText(BOOL bPlainText, LPCSTR pszText)
1902 {
1903 ATLASSERT(::IsWindow(m_hWnd));
1904 ::SendMessage(m_hWnd, DTM_ADDTEXT, (WPARAM)bPlainText, (LPARAM)p szText);
1905 }
1906
1907 void AddHTML(LPCSTR pszHTML)
1908 {
1909 ATLASSERT(::IsWindow(m_hWnd));
1910 ::SendMessage(m_hWnd, DTM_ADDTEXT, (WPARAM)FALSE, (LPARAM)pszHTM L);
1911 }
1912
1913 void AddText(BOOL bPlainText, LPCWSTR pszText)
1914 {
1915 ATLASSERT(::IsWindow(m_hWnd));
1916 ::SendMessage(m_hWnd, DTM_ADDTEXTW, (WPARAM)bPlainText, (LPARAM) pszText);
1917 }
1918
1919 void AddHTML(LPCWSTR pszHTML)
1920 {
1921 ATLASSERT(::IsWindow(m_hWnd));
1922 ::SendMessage(m_hWnd, DTM_ADDTEXTW, (WPARAM)FALSE, (LPARAM)pszHT ML);
1923 }
1924
1925 void Anchor(LPCSTR pszAnchor)
1926 {
1927 ATLASSERT(::IsWindow(m_hWnd));
1928 ::SendMessage(m_hWnd, DTM_ANCHOR, 0, (LPARAM)pszAnchor);
1929 }
1930
1931 void Anchor(LPCWSTR pszAnchor)
1932 {
1933 ATLASSERT(::IsWindow(m_hWnd));
1934 ::SendMessage(m_hWnd, DTM_ANCHORW, 0, (LPARAM)pszAnchor);
1935 }
1936
1937 #if (_WIN32_WCE >= 420)
1938 void GetBrowserDispatch(IDispatch** ppDispatch)
1939 {
1940 ATLASSERT(::IsWindow(m_hWnd));
1941 ATLASSERT(ppDispatch);
1942 ATLASSERT(*ppDispatch==NULL);
1943 ::SendMessage(m_hWnd, DTM_BROWSERDISPATCH, 0, (LPARAM)ppDispatch );
1944 }
1945 void GetDocumentDispatch(IDispatch** ppDispatch)
1946 {
1947 ATLASSERT(::IsWindow(m_hWnd));
1948 ATLASSERT(ppDispatch);
1949 ATLASSERT(*ppDispatch==NULL);
1950 ::SendMessage(m_hWnd, DTM_DOCUMENTDISPATCH , 0, (LPARAM)ppDispat ch);
1951 }
1952 #endif // (_WIN32_WCE >= 420)
1953
1954 void Clear()
1955 {
1956 ATLASSERT(::IsWindow(m_hWnd));
1957 ::SendMessage(m_hWnd, DTM_CLEAR, 0, 0L);
1958 }
1959
1960 void EnableClearType(BOOL bEnable = TRUE)
1961 {
1962 ATLASSERT(::IsWindow(m_hWnd));
1963 ::SendMessage(m_hWnd, DTM_ENABLECLEARTYPE, 0, (LPARAM)bEnable);
1964 }
1965
1966 void EnableContextMenu(BOOL bEnable = TRUE)
1967 {
1968 ATLASSERT(::IsWindow(m_hWnd));
1969 ::SendMessage(m_hWnd, DTM_ENABLECONTEXTMENU, 0, (LPARAM)bEnable) ;
1970 }
1971
1972 void EnableScripting(BOOL bEnable = TRUE)
1973 {
1974 ATLASSERT(::IsWindow(m_hWnd));
1975 ::SendMessage(m_hWnd, DTM_ENABLESCRIPTING, 0, (LPARAM)bEnable);
1976 }
1977
1978 void EnableShrink(BOOL bEnable = TRUE)
1979 {
1980 ATLASSERT(::IsWindow(m_hWnd));
1981 ::SendMessage(m_hWnd, DTM_ENABLESHRINK, 0, (LPARAM)bEnable);
1982 }
1983
1984 void EndOfSource()
1985 {
1986 ATLASSERT(::IsWindow(m_hWnd));
1987 ::SendMessage(m_hWnd, DTM_ENDOFSOURCE, 0, 0L);
1988 }
1989
1990 void ImageFail(DWORD dwCookie)
1991 {
1992 ATLASSERT(::IsWindow(m_hWnd));
1993 ::SendMessage(m_hWnd, DTM_IMAGEFAIL, 0, (LPARAM)dwCookie);
1994 }
1995
1996 int GetLayoutHeight() const
1997 {
1998 ATLASSERT(::IsWindow(m_hWnd));
1999 return (int)::SendMessage(m_hWnd, DTM_LAYOUTHEIGHT, 0, 0L);
2000 }
2001
2002 int GetLayoutWidth() const
2003 {
2004 ATLASSERT(::IsWindow(m_hWnd));
2005 return (int)::SendMessage(m_hWnd, DTM_LAYOUTWIDTH, 0, 0L);
2006 }
2007
2008 void Navigate(LPCTSTR pstrURL, UINT uFlags = 0)
2009 {
2010 ATLASSERT(::IsWindow(m_hWnd));
2011 ATLASSERT(pstrURL);
2012 ::SendMessage(m_hWnd, DTM_NAVIGATE, (WPARAM)uFlags, (LPARAM)pstr URL);
2013 }
2014
2015 void SelectAll()
2016 {
2017 ATLASSERT(::IsWindow(m_hWnd));
2018 ::SendMessage(m_hWnd, DTM_SELECTALL, 0, 0L);
2019 }
2020
2021 void SetImage(INLINEIMAGEINFO* pImageInfo)
2022 {
2023 ATLASSERT(::IsWindow(m_hWnd));
2024 ATLASSERT(pImageInfo);
2025 ::SendMessage(m_hWnd, DTM_SETIMAGE, 0, (LPARAM)pImageInfo);
2026 }
2027
2028 void ZoomLevel(int iLevel)
2029 {
2030 ATLASSERT(::IsWindow(m_hWnd));
2031 ::SendMessage(m_hWnd, DTM_ZOOMLEVEL, 0, (LPARAM)iLevel);
2032 }
2033
2034 #if (_WIN32_WCE >= 400)
2035 void Stop()
2036 {
2037 ATLASSERT(::IsWindow(m_hWnd));
2038 ::SendMessage(m_hWnd, DTM_STOP, 0, 0L);
2039 }
2040 #endif // (_WIN32_WCE >= 400)
2041
2042 void GetScriptDispatch(IDispatch** ppDispatch)
2043 {
2044 ATLASSERT(::IsWindow(m_hWnd));
2045 ATLASSERT(ppDispatch);
2046 ATLASSERT(*ppDispatch==NULL);
2047 ::SendMessage(m_hWnd, DTM_SCRIPTDISPATCH, 0, (LPARAM)ppDispatch) ;
2048 }
2049 };
2050
2051 typedef CHtmlCtrlT<ATL::CWindow> CHtmlCtrl;
2052
2053
2054 #ifdef WIN32_PLATFORM_PSPC
2055
2056 ///////////////////////////////////////////////////////////////////////////////
2057 // CRichInkCtrl
2058
2059 template <class TBase>
2060 class CRichInkCtrlT : public TBase
2061 {
2062 public:
2063 // Constructors
2064 CRichInkCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2065 { }
2066
2067 CRichInkCtrlT< TBase >& operator =(HWND hWnd)
2068 {
2069 m_hWnd = hWnd;
2070 return *this;
2071 }
2072
2073 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN ame = NULL,
2074 DWORD dwStyle = 0, DWORD dwExStyle = 0,
2075 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
2076 {
2077 HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_ lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2078 ATLASSERT(hWnd != NULL); // Did you remember to call InitRichI nkDLL() ??
2079 return hWnd;
2080 }
2081
2082 // Attributes
2083 static LPCTSTR GetWndClassName()
2084 {
2085 return WC_RICHINK;
2086 }
2087
2088 BOOL CanPaste(UINT uFormat = 0) const
2089 {
2090 ATLASSERT(::IsWindow(m_hWnd));
2091 return (BOOL)::SendMessage(m_hWnd, EM_CANPASTE, (WPARAM)uFormat, 0L);
2092 }
2093
2094 BOOL CanRedo() const
2095 {
2096 ATLASSERT(::IsWindow(m_hWnd));
2097 return (BOOL)::SendMessage(m_hWnd, EM_CANREDO, 0, 0L);
2098 }
2099
2100 BOOL CanUndo() const
2101 {
2102 ATLASSERT(::IsWindow(m_hWnd));
2103 return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L);
2104 }
2105
2106 void ClearAll(BOOL bRepaint = TRUE) const
2107 {
2108 ATLASSERT(::IsWindow(m_hWnd));
2109 ::SendMessage(m_hWnd, EM_CLEARALL, (WPARAM)bRepaint, 0L);
2110 }
2111
2112 BOOL GetModify() const
2113 {
2114 ATLASSERT(::IsWindow(m_hWnd));
2115 return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L);
2116 }
2117
2118 UINT GetPageStyle() const
2119 {
2120 ATLASSERT(::IsWindow(m_hWnd));
2121 return (UINT)::SendMessage(m_hWnd, EM_GETPAGESTYLE, 0, 0L);
2122 }
2123
2124 UINT GetPenMode() const
2125 {
2126 ATLASSERT(::IsWindow(m_hWnd));
2127 return (UINT)::SendMessage(m_hWnd, EM_GETPENMODE, 0, 0L);
2128 }
2129
2130 UINT GetViewStyle() const
2131 {
2132 ATLASSERT(::IsWindow(m_hWnd));
2133 return (UINT)::SendMessage(m_hWnd, EM_GETVIEW, 0, 0L);
2134 }
2135
2136 UINT GetWrapMode() const
2137 {
2138 ATLASSERT(::IsWindow(m_hWnd));
2139 return (UINT)::SendMessage(m_hWnd, EM_GETWRAPMODE, 0, 0L);
2140 }
2141
2142 UINT GetZoomPercent() const
2143 {
2144 ATLASSERT(::IsWindow(m_hWnd));
2145 return (UINT)::SendMessage(m_hWnd, EM_GETZOOMPERCENT, 0, 0L);
2146 }
2147
2148 void InsertLinks(LPWSTR lpString, int cchLength = -1)
2149 {
2150 ATLASSERT(::IsWindow(m_hWnd));
2151 if(cchLength == -1)
2152 cchLength = lstrlen(lpString);
2153 ::SendMessage(m_hWnd, EM_INSERTLINKS, (WPARAM)cchLength, (LPARAM )lpString);
2154 }
2155
2156 void RedoEvent()
2157 {
2158 ATLASSERT(::IsWindow(m_hWnd));
2159 ::SendMessage(m_hWnd, EM_REDOEVENT, 0, 0L);
2160 }
2161
2162 UINT SetInkLayer(UINT uLayer)
2163 {
2164 ATLASSERT(::IsWindow(m_hWnd));
2165 return (UINT)::SendMessage(m_hWnd, EM_SETINKLAYER, (WPARAM)uLaye r, 0L);
2166 }
2167
2168 void SetPageStyle(UINT uStyle)
2169 {
2170 ATLASSERT(::IsWindow(m_hWnd));
2171 ::SendMessage(m_hWnd, EM_SETPAGESTYLE, (WPARAM)uStyle, 0L);
2172 }
2173
2174 void SetPenMode(UINT uMode)
2175 {
2176 ATLASSERT(::IsWindow(m_hWnd));
2177 ::SendMessage(m_hWnd, EM_SETPENMODE, (WPARAM)uMode, 0L);
2178 }
2179
2180 void SetViewStyle(UINT uStyle)
2181 {
2182 ATLASSERT(::IsWindow(m_hWnd));
2183 ::SendMessage(m_hWnd, EM_SETVIEW, (WPARAM)uStyle, 0L);
2184 }
2185
2186 void SetViewAttributes(VIEWATTRIBUTES* pAttribs)
2187 {
2188 ATLASSERT(::IsWindow(m_hWnd));
2189 ATLASSERT(pAttribs);
2190 ::SendMessage(m_hWnd, EM_SETVIEWATTRIBUTES, 0, (LPARAM)pAttribs) ;
2191 }
2192
2193 void SetWrapMode(UINT uMode)
2194 {
2195 ATLASSERT(::IsWindow(m_hWnd));
2196 ::SendMessage(m_hWnd, EM_SETWRAPMODE, (WPARAM)uMode, 0L);
2197 }
2198
2199 void SetZoomPercent(UINT uPercent)
2200 {
2201 ATLASSERT(::IsWindow(m_hWnd));
2202 ::SendMessage(m_hWnd, EM_SETZOOMPERCENT, (WPARAM)uPercent, 0L);
2203 }
2204
2205 LONG StreamIn(UINT uFormat, EDITSTREAM& es)
2206 {
2207 ATLASSERT(::IsWindow(m_hWnd));
2208 return (LONG)::SendMessage(m_hWnd, EM_STREAMIN, (WPARAM)uFormat, (LPARAM)&es);
2209 }
2210
2211 LONG StreamOut(UINT uFormat, EDITSTREAM& es)
2212 {
2213 ATLASSERT(::IsWindow(m_hWnd));
2214 return (LONG)::SendMessage(m_hWnd, EM_STREAMOUT, (WPARAM)uFormat , (LPARAM)&es);
2215 }
2216
2217 void UndoEvent()
2218 {
2219 ATLASSERT(::IsWindow(m_hWnd));
2220 ::SendMessage(m_hWnd, EM_UNDOEVENT, 0, 0L);
2221 }
2222
2223 // Standard EM_xxx messages
2224 DWORD GetSel() const
2225 {
2226 ATLASSERT(::IsWindow(m_hWnd));
2227 return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L);
2228 }
2229
2230 void GetSel(int& nStartChar, int& nEndChar) const
2231 {
2232 ATLASSERT(::IsWindow(m_hWnd));
2233 ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&n EndChar);
2234 }
2235
2236 void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
2237 {
2238 ATLASSERT(::IsWindow(m_hWnd));
2239 ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM)bCanUndo, (LPARAM)l pszNewText);
2240 }
2241
2242 void SetModify(BOOL bModified = TRUE)
2243 {
2244 ATLASSERT(::IsWindow(m_hWnd));
2245 ::SendMessage(m_hWnd, EM_SETMODIFY, (WPARAM)bModified, 0L);
2246 }
2247
2248 int GetTextLength() const
2249 {
2250 ATLASSERT(::IsWindow(m_hWnd));
2251 return (int)::SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0L);
2252 }
2253
2254 // Clipboard operations
2255 void Clear()
2256 {
2257 ATLASSERT(::IsWindow(m_hWnd));
2258 ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
2259 }
2260
2261 void Copy()
2262 {
2263 ATLASSERT(::IsWindow(m_hWnd));
2264 ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
2265 }
2266
2267 void Cut()
2268 {
2269 ATLASSERT(::IsWindow(m_hWnd));
2270 ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
2271 }
2272
2273 void Paste()
2274 {
2275 ATLASSERT(::IsWindow(m_hWnd));
2276 ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
2277 }
2278 };
2279
2280 typedef CRichInkCtrlT<ATL::CWindow> CRichInkCtrl;
2281
2282
2283 ///////////////////////////////////////////////////////////////////////////////
2284 // CInkXCtrl
2285
2286 template <class TBase>
2287 class CInkXCtrlT : public TBase
2288 {
2289 public:
2290 // Constructors
2291 CInkXCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2292 { }
2293
2294 CInkXCtrlT< TBase >& operator =(HWND hWnd)
2295 {
2296 m_hWnd = hWnd;
2297 return *this;
2298 }
2299
2300 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN ame = NULL,
2301 DWORD dwStyle = 0, DWORD dwExStyle = 0,
2302 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
2303 {
2304 HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_ lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2305 ATLASSERT(hWnd != NULL); // Did you remember to call InitInkX( ) ??
2306 return hWnd;
2307 }
2308
2309 // Attributes
2310 static LPCTSTR GetWndClassName()
2311 {
2312 return WC_INKX;
2313 }
2314
2315 static UINT GetHotRecordingMessage()
2316 {
2317 return ::RegisterWindowMessage(szHotRecording);
2318 }
2319
2320 void ClearAll()
2321 {
2322 ATLASSERT(::IsWindow(m_hWnd));
2323 ::SendMessage(m_hWnd, IM_CLEARALL, 0, 0L);
2324 }
2325
2326 int GetData(BYTE* lpBuffer, INT cbBuffer) const
2327 {
2328 ATLASSERT(::IsWindow(m_hWnd));
2329 ATLASSERT(lpBuffer);
2330 return (int)::SendMessage(m_hWnd, IM_GETDATA, (WPARAM)cbBuffer, (LPARAM)lpBuffer);
2331 }
2332
2333 int GetDataLen() const
2334 {
2335 ATLASSERT(::IsWindow(m_hWnd));
2336 return (int)::SendMessage(m_hWnd, IM_GETDATALEN, 0, 0L);
2337 }
2338
2339 CRichInkCtrl GetRichInk() const
2340 {
2341 ATLASSERT(::IsWindow(m_hWnd));
2342 return (HWND)::SendMessage(m_hWnd, IM_GETRICHINK, 0, 0L);
2343 }
2344
2345 BOOL IsRecording() const
2346 {
2347 ATLASSERT(::IsWindow(m_hWnd));
2348 return (BOOL)::SendMessage(m_hWnd, IM_RECORDING, 0, 0L);
2349 }
2350
2351 void ReInit()
2352 {
2353 ATLASSERT(::IsWindow(m_hWnd));
2354 ::SendMessage(m_hWnd, IM_REINIT, 0, 0L);
2355 }
2356
2357 void SetData(const BYTE* lpInkData, INT cbInkData)
2358 {
2359 ATLASSERT(::IsWindow(m_hWnd));
2360 ATLASSERT(lpInkData);
2361 ::SendMessage(m_hWnd, IM_SETDATA, (WPARAM)cbInkData, (LPARAM)lpI nkData);
2362 }
2363
2364 void VoicePlay()
2365 {
2366 ATLASSERT(::IsWindow(m_hWnd));
2367 ::SendMessage(m_hWnd, IM_VOICE_PLAY, 0, 0L);
2368 }
2369
2370 BOOL IsVoicePlaying() const
2371 {
2372 ATLASSERT(::IsWindow(m_hWnd));
2373 return (BOOL)::SendMessage(m_hWnd, IM_VOICE_PLAYING, 0, 0L);
2374 }
2375
2376 BOOL VoiceRecord()
2377 {
2378 ATLASSERT(::IsWindow(m_hWnd));
2379 return (BOOL)::SendMessage(m_hWnd, IM_VOICE_RECORD, 0, 0L);
2380 }
2381
2382 void VoiceStop()
2383 {
2384 ATLASSERT(::IsWindow(m_hWnd));
2385 ::SendMessage(m_hWnd, IM_VOICE_STOP, 0, 0L);
2386 }
2387
2388 void ShowVoiceBar(BOOL bShow = TRUE)
2389 {
2390 ATLASSERT(::IsWindow(m_hWnd));
2391 ::SendMessage(m_hWnd, IM_VOICEBAR, (WPARAM)bShow, 0L);
2392 }
2393 };
2394
2395 typedef CInkXCtrlT<ATL::CWindow> CInkXCtrl;
2396
2397 #endif // WIN32_PLATFORM_PSPC
2398
2399
2400 ///////////////////////////////////////////////////////////////////////////////
2401 // CVoiceRecorderCtrl
2402
2403 template <class TBase>
2404 class CVoiceRecorderCtrlT : public TBase
2405 {
2406 public:
2407 // Constructors
2408 CVoiceRecorderCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2409 { }
2410
2411 CVoiceRecorderCtrlT< TBase >& operator =(HWND hWnd)
2412 {
2413 m_hWnd = hWnd;
2414 return *this;
2415 }
2416
2417 HWND Create(HWND hWndParent, const POINT pt, LPTSTR pstrFileName, UINT n ID, DWORD dwStyle = 0)
2418 {
2419 ATLASSERT(pstrFileName != NULL);
2420 CM_VOICE_RECORDER cmvr = { 0 };
2421 cmvr.cb = sizeof(CM_VOICE_RECORDER);
2422 cmvr.dwStyle = dwStyle;
2423 cmvr.xPos = pt.x;
2424 cmvr.yPos = pt.y;
2425 cmvr.hwndParent = hWndParent;
2426 cmvr.id = nID;
2427 cmvr.lpszRecordFileName = pstrFileName;
2428 m_hWnd = VoiceRecorder_Create(&cmvr);
2429 return m_hWnd;
2430 }
2431
2432 HWND Create(LPCM_VOICE_RECORDER pAttribs)
2433 {
2434 ATLASSERT(pAttribs);
2435 m_hWnd = VoiceRecorder_Create(pAttribs);
2436 return m_hWnd;
2437 }
2438
2439 // Attributes
2440 void Record()
2441 {
2442 ATLASSERT(::IsWindow(m_hWnd));
2443 ::SendMessage(m_hWnd, VRM_RECORD, 0, 0L);
2444 }
2445
2446 void Play()
2447 {
2448 ATLASSERT(::IsWindow(m_hWnd));
2449 ::SendMessage(m_hWnd, VRM_PLAY, 0, 0L);
2450 }
2451
2452 void Stop()
2453 {
2454 ATLASSERT(::IsWindow(m_hWnd));
2455 ::SendMessage(m_hWnd, VRM_STOP, 0, 0L);
2456 }
2457
2458 void Cancel()
2459 {
2460 ATLASSERT(::IsWindow(m_hWnd));
2461 ::SendMessage(m_hWnd, VRM_CANCEL, 0, 0L);
2462 }
2463
2464 void Done()
2465 {
2466 ATLASSERT(::IsWindow(m_hWnd));
2467 ::SendMessage(m_hWnd, VRM_OK, 0, 0L);
2468 }
2469 };
2470
2471 typedef CVoiceRecorderCtrlT<ATL::CWindow> CVoiceRecorderCtrl;
2472
2473
2474 #ifdef WIN32_PLATFORM_PSPC
2475
2476 ///////////////////////////////////////////////////////////////////////////////
2477 // CDocListCtrl
2478
2479 template <class TBase>
2480 class CDocListCtrlT : public TBase
2481 {
2482 public:
2483 // Attributes
2484 DOCLISTCREATE m_dlc;
2485 TCHAR m_szPath[MAX_PATH];
2486
2487 // Constructors
2488 CDocListCtrlT(HWND hWnd = NULL) : TBase(hWnd)
2489 { }
2490
2491 CDocListCtrlT< TBase >& operator =(HWND hWnd)
2492 {
2493 m_hWnd = hWnd;
2494 return *this;
2495 }
2496
2497 HWND Create(HWND hWndParent, WORD wId, LPCTSTR pszFolder = NULL, LPCTSTR pstrFilter = NULL,
2498 WORD wFilterIndex = 0, DWORD dwFlags = DLF_SHOWEXTENSION )
2499 {
2500 ATLASSERT(pstrFilter != NULL); // It seems to need a filter ba dly!!
2501 ::ZeroMemory(&m_dlc, sizeof(DOCLISTCREATE));
2502 ::ZeroMemory(m_szPath, sizeof(m_szPath));
2503 if(pszFolder != NULL)
2504 ::lstrcpyn(m_szPath, pszFolder, MAX_PATH - 1);
2505 m_dlc.dwStructSize = sizeof(DOCLISTCREATE);
2506 m_dlc.hwndParent = hWndParent;
2507 m_dlc.pszFolder = m_szPath;
2508 m_dlc.pstrFilter = pstrFilter;
2509 m_dlc.wFilterIndex = wFilterIndex;
2510 m_dlc.wId = wId;
2511 m_dlc.dwFlags = dwFlags;
2512 m_hWnd = DocList_Create(&m_dlc);
2513 return m_hWnd;
2514 }
2515
2516 HWND Create(DOCLISTCREATE* pDlc)
2517 {
2518 m_dlc = *pDlc;
2519 m_hWnd = DocList_Create(&m_dlc);
2520 return m_hWnd;
2521 }
2522
2523 // Attributes
2524 void DeleteSel()
2525 {
2526 ATLASSERT(::IsWindow(m_hWnd));
2527 ::SendMessage(m_hWnd, DLM_DELETESEL, 0, 0L);
2528 }
2529
2530 void DisableUpdates()
2531 {
2532 ATLASSERT(::IsWindow(m_hWnd));
2533 ::SendMessage(m_hWnd, DLM_DISABLEUPDATES, 0, 0L);
2534 }
2535
2536 void EnableUpdates()
2537 {
2538 ATLASSERT(::IsWindow(m_hWnd));
2539 ::SendMessage(m_hWnd, DLM_ENABLEUPDATES, 0, 0L);
2540 }
2541
2542 int GetFilterIndex() const
2543 {
2544 ATLASSERT(::IsWindow(m_hWnd));
2545 return (int)::SendMessage(m_hWnd, DLM_GETFILTERINDEX, 0, 0L);
2546 }
2547
2548 int GetItemCount() const
2549 {
2550 ATLASSERT(::IsWindow(m_hWnd));
2551 return (int)::SendMessage(m_hWnd, DLM_GETITEMCOUNT, 0, 0L);
2552 }
2553
2554 int GetNextItem(int iIndex, DWORD dwRelation = LVNI_ALL) const
2555 {
2556 ATLASSERT(::IsWindow(m_hWnd));
2557 return (int)::SendMessage(m_hWnd, DLM_GETNEXTITEM, (WPARAM)iInde x, (LPARAM)dwRelation);
2558 }
2559
2560 int GetFirstItem(DWORD dwRelation = LVNI_ALL) const
2561 {
2562 ATLASSERT(::IsWindow(m_hWnd));
2563 return (int)::SendMessage(m_hWnd, DLM_GETNEXTITEM, (WPARAM)-1, ( LPARAM)dwRelation);
2564 }
2565
2566 BOOL GetNextWave(int* pIndex) const
2567 {
2568 ATLASSERT(::IsWindow(m_hWnd));
2569 ATLASSERT(pIndex);
2570 return (BOOL)::SendMessage(m_hWnd, DLM_GETNEXTWAVE, 0, (LPARAM)p Index);
2571 }
2572
2573 BOOL GetPrevWave(int* pIndex) const
2574 {
2575 ATLASSERT(::IsWindow(m_hWnd));
2576 ATLASSERT(pIndex);
2577 return (BOOL)::SendMessage(m_hWnd, DLM_GETPREVWAVE, 0, (LPARAM)p Index);
2578 }
2579
2580 int GetSelCount() const
2581 {
2582 ATLASSERT(::IsWindow(m_hWnd));
2583 return (int)::SendMessage(m_hWnd, DLM_GETSELCOUNT, 0, 0L);
2584 }
2585
2586 BOOL GetSelPathName(LPTSTR pstrPath, int cchMax) const
2587 {
2588 ATLASSERT(::IsWindow(m_hWnd));
2589 ATLASSERT(pstrPath);
2590 return (BOOL)::SendMessage(m_hWnd, DLM_GETSELPATHNAME, (WPARAM)c chMax, (LPARAM)pstrPath);
2591 }
2592
2593 void ReceiveIR(LPCTSTR pstrPath) const
2594 {
2595 ATLASSERT(::IsWindow(m_hWnd));
2596 ATLASSERT(pstrPath);
2597 ::SendMessage(m_hWnd, DLM_RECEIVEIR, 0, (LPARAM)pstrPath);
2598 }
2599
2600 void Refresh()
2601 {
2602 ATLASSERT(::IsWindow(m_hWnd));
2603 ::SendMessage(m_hWnd, DLM_REFRESH, 0, 0L);
2604 }
2605
2606 BOOL RenameMoveSelectedItems()
2607 {
2608 ATLASSERT(::IsWindow(m_hWnd));
2609 return (BOOL)::SendMessage(m_hWnd, DLM_RENAMEMOVE, 0, 0L);
2610 }
2611
2612 int SelectAll()
2613 {
2614 ATLASSERT(::IsWindow(m_hWnd));
2615 return (int)::SendMessage(m_hWnd, DLM_SELECTALL, 0, 0L);
2616 }
2617
2618 HRESULT SelectItem(LPCTSTR pstrPath, BOOL bVisible = TRUE)
2619 {
2620 ATLASSERT(::IsWindow(m_hWnd));
2621 ATLASSERT(pstrPath);
2622 return (HRESULT)::SendMessage(m_hWnd, DLM_SELECTITEM, (WPARAM)bV isible, (LPARAM)pstrPath);
2623 }
2624
2625 void SendEMail(LPCTSTR pstrAttachment)
2626 {
2627 ATLASSERT(::IsWindow(m_hWnd));
2628 ::SendMessage(m_hWnd, DLM_SENDEMAIL, 0, (LPARAM)pstrAttachment);
2629 }
2630
2631 void SendIR(LPCTSTR pstrPath)
2632 {
2633 ATLASSERT(::IsWindow(m_hWnd));
2634 ::SendMessage(m_hWnd, DLM_SENDIR, 0, (LPARAM)pstrPath);
2635 }
2636
2637 HRESULT SetFilterIndex(int iIndex)
2638 {
2639 ATLASSERT(::IsWindow(m_hWnd));
2640 return (HRESULT)::SendMessage(m_hWnd, DLM_SETFILTERINDEX, (WPARA M)iIndex, 0L);
2641 }
2642
2643 void SetFolder(LPCTSTR pstrPath)
2644 {
2645 ATLASSERT(::IsWindow(m_hWnd));
2646 ATLASSERT(pstrPath);
2647 ::SendMessage(m_hWnd, DLM_SETFOLDER, 0, (LPARAM)pstrPath);
2648 }
2649
2650 BOOL SetItemState(int iIndex, const LVITEM* pItem)
2651 {
2652 ATLASSERT(::IsWindow(m_hWnd));
2653 ATLASSERT(pItem);
2654 return (BOOL)::SendMessage(m_hWnd, DLM_SETITEMSTATE, (WPARAM)iIn dex, (LPARAM)pItem);
2655 }
2656
2657 BOOL SetItemState(int iIndex, UINT uState, UINT uMask)
2658 {
2659 ATLASSERT(::IsWindow(m_hWnd));
2660 LV_ITEM lvi = { 0 };
2661 lvi.stateMask = uMask;
2662 lvi.state = uState;
2663 return (BOOL)::SendMessage(m_hWnd, DLM_SETITEMSTATE, (WPARAM)iIn dex, (LPARAM)&lvi);
2664 }
2665
2666 void SetOneItem(int iIndex, LPCVOID pPA)
2667 {
2668 ATLASSERT(::IsWindow(m_hWnd));
2669 ::SendMessage(m_hWnd, DLM_SETONEITEM, (WPARAM)iIndex, (LPARAM)pP A);
2670 }
2671
2672 void SetSelect(int iIndex)
2673 {
2674 ATLASSERT(::IsWindow(m_hWnd));
2675 ::SendMessage(m_hWnd, DLM_SETSELECT, (WPARAM)iIndex, 0L);
2676 }
2677
2678 void SetSelPathName(LPCTSTR pstrPath)
2679 {
2680 ATLASSERT(::IsWindow(m_hWnd));
2681 ATLASSERT(pstrPath);
2682 ::SendMessage(m_hWnd, DLM_SETSELPATHNAME, 0, (LPARAM)pstrPath);
2683 }
2684
2685 BOOL SetSortOrder()
2686 {
2687 ATLASSERT(::IsWindow(m_hWnd));
2688 return (BOOL)::SendMessage(m_hWnd, DLM_SETSORTORDER, 0, 0L);
2689 }
2690
2691 HRESULT Update()
2692 {
2693 ATLASSERT(::IsWindow(m_hWnd));
2694 return (HRESULT)::SendMessage(m_hWnd, DLM_UPDATE, 0, 0L);
2695 }
2696
2697 BOOL ValidateFolder()
2698 {
2699 ATLASSERT(::IsWindow(m_hWnd));
2700 return (BOOL)::SendMessage(m_hWnd, DLM_VALIDATEFOLDER, 0, 0L);
2701 }
2702
2703 // Functions
2704 BOOL GetFirstSelectedWaveFile(int* pIndex, LPTSTR szPath, const size_t c chPath)
2705 {
2706 ATLASSERT(::IsWindow(m_hWnd));
2707 return DocList_GetFirstSelectedWaveFile(m_hWnd, pIndex, szPath, cchPath);
2708 }
2709
2710 BOOL GetNextSelectedWaveFile(int* pIndex, LPTSTR szPath, const size_t cc hPath)
2711 {
2712 ATLASSERT(::IsWindow(m_hWnd));
2713 return DocList_GetNextSelectedWaveFile(m_hWnd, pIndex, szPath, c chPath);
2714 }
2715 };
2716
2717 typedef CDocListCtrlT<ATL::CWindow> CDocListCtrl;
2718
2719 #endif // WIN32_PLATFORM_PSPC
2720
2721
2722 ///////////////////////////////////////////////////////////////////////////////
2723 // CCapEdit
2724
2725 template <class TBase>
2726 class CCapEditT : public TBase
2727 {
2728 public:
2729 // Constructors
2730 CCapEditT(HWND hWnd = NULL) : TBase(hWnd)
2731 { }
2732
2733 CCapEditT< TBase >& operator =(HWND hWnd)
2734 {
2735 m_hWnd = hWnd;
2736 return *this;
2737 }
2738
2739 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN ame = NULL,
2740 DWORD dwStyle = 0, DWORD dwExStyle = 0,
2741 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
2742 {
2743 HWND hWnd = /*TBase*/CWindow::Create(GetWndClassName(), hWndPare nt, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateP aram);
2744 ATLASSERT(hWnd != NULL); // Did you remember to call SHInitExt raControls() ??
2745 return hWnd;
2746 }
2747
2748 // Attributes
2749 static LPCTSTR GetWndClassName()
2750 {
2751 return WC_CAPEDIT;
2752 }
2753 };
2754
2755 typedef CCapEditT<WTL::CEdit> CCapEdit;
2756
2757 ///////////////////////////////////////////////////////////////////////////////
2758 // CTTStatic
2759
2760 #ifndef WIN32_PLATFORM_WFSP // Tooltips not supported on SmartPhone
2761
2762 template <class TBase>
2763 class CTTStaticT : public TBase
2764 {
2765 public:
2766 // Constructors
2767 CTTStaticT(HWND hWnd = NULL) : TBase(hWnd)
2768 { }
2769
2770 CTTStaticT< TBase >& operator =(HWND hWnd)
2771 {
2772 m_hWnd = hWnd;
2773 return *this;
2774 }
2775
2776 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN ame = NULL,
2777 DWORD dwStyle = 0, DWORD dwExStyle = 0,
2778 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
2779 {
2780 HWND hWnd = TBase::Create(hWndParent, rect.m_lpRect, szWindowNam e, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2781 ATLASSERT(hWnd != NULL); // Did you remember to call SHInitExt raControls() ??
2782 return hWnd;
2783 }
2784
2785 // Attributes
2786 static LPCTSTR GetWndClassName()
2787 {
2788 return WC_TSTATIC;
2789 }
2790
2791 // Operations
2792 BOOL SetToolTipText(LPCTSTR pstrTipText)
2793 {
2794 ATLASSERT(::IsWindow(m_hWnd));
2795 ATLASSERT(pstrTipText);
2796 ATLASSERT(lstrlen(pstrTipText)<= 253);
2797 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
2798 LPTSTR pstr = buff.Allocate(lstrlen(pstrTipText) + 3);
2799 if(pstr == NULL)
2800 return FALSE;
2801 ::lstrcpy(pstr, _T("~~"));
2802 ::lstrcat(pstr, pstrTipText);
2803 return SetWindowText(pstr);
2804 }
2805 };
2806
2807 typedef CTTStaticT<WTL::CStatic> CTTStatic;
2808
2809
2810 ///////////////////////////////////////////////////////////////////////////////
2811 // CTTButton
2812
2813 template <class TBase>
2814 class CTTButtonT : public TBase
2815 {
2816 public:
2817 // Constructors
2818 CTTButtonT(HWND hWnd = NULL) : TBase(hWnd)
2819 { }
2820
2821 CTTButtonT< TBase >& operator =(HWND hWnd)
2822 {
2823 m_hWnd = hWnd;
2824 return *this;
2825 }
2826
2827 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowN ame = NULL,
2828 DWORD dwStyle = 0, DWORD dwExStyle = 0,
2829 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
2830 {
2831 HWND hWnd = TBase::Create(hWndParent, rect.m_lpRect, szWindowNam e, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
2832 ATLASSERT(hWnd != NULL); // Did you remember to call SHInitExt raControls() ??
2833 return hWnd;
2834 }
2835
2836 // Attributes
2837 static LPCTSTR GetWndClassName()
2838 {
2839 return WC_TBUTTON;
2840 }
2841
2842 // Operations
2843 BOOL SetToolTipText(LPCTSTR pstrTipText)
2844 {
2845 ATLASSERT(::IsWindow(m_hWnd));
2846 ATLASSERT(pstrTipText);
2847 ATLASSERT(lstrlen(pstrTipText)<= 253);
2848 CTempBuffer<TCHAR, _WTL_STACK_ALLOC_THRESHOLD> buff;
2849 LPTSTR pstr = buff.Allocate(lstrlen(pstrTipText) + 3);
2850 if(pstr == NULL)
2851 return FALSE;
2852 ::lstrcpy(pstr, _T("~~"));
2853 ::lstrcat(pstr, pstrTipText);
2854 return SetWindowText(pstr);
2855 }
2856 };
2857
2858 typedef CTTButtonT<WTL::CButton> CTTButton;
2859
2860 #endif // !WIN32_PLATFORM_WFSP
2861
2862
2863 // --- SmartPhone specific controls ---
2864
2865 #ifdef WIN32_PLATFORM_WFSP
2866
2867 ///////////////////////////////////////////////////////////////////////////////
2868 // CSpinCtrlT - CSpinCtrl : SmartPhone adapted UpDown control
2869
2870 template <class TBase>
2871 class CSpinCtrlT : public CUpDownCtrlT< TBase >
2872 {
2873 public:
2874 // Constructors
2875 CSpinCtrlT(HWND hWnd = NULL) : CUpDownCtrlT< TBase >(hWnd)
2876 { }
2877
2878 CSpinCtrlT< TBase >& operator =(HWND hWnd)
2879 {
2880 m_hWnd = hWnd;
2881 return *this;
2882 }
2883
2884 HWND Create(HWND hWndParent, HWND hBuddy, DWORD dwStyle, int nID, LPCTST R szExpandedName = NULL)
2885 {
2886 ATLASSERT(::IsWindow(hWndParent));
2887 CUpDownCtrlT< TBase >::Create(hWndParent, NULL, szExpandedName, dwStyle, 0, nID, NULL);
2888 ATLASSERT(m_hWnd != NULL); // Did you remember to call AtlInit CommonControls(ICC_UPDOWN_CLASS)?
2889 if (hBuddy != NULL)
2890 {
2891 ATLASSERT(::IsWindow(hBuddy));
2892 SetBuddy(hBuddy);
2893 }
2894 return m_hWnd;
2895 }
2896 };
2897
2898 typedef CSpinCtrlT<ATL::CWindow> CSpinCtrl;
2899
2900
2901 ///////////////////////////////////////////////////////////////////////////////
2902 // CSpinned - SmartPhone association of control and Spin
2903
2904 template <class TBase, bool t_bExpandOnly>
2905 class CSpinned : public TBase
2906 {
2907 public:
2908 CSpinCtrl m_SpinCtrl;
2909 DWORD m_dwSpinnedStyle;
2910
2911 // Constructors
2912 CSpinned(HWND hWnd = NULL) : TBase(hWnd)
2913 {
2914 m_dwSpinnedStyle = WS_VISIBLE | UDS_ALIGNRIGHT | UDS_EXPANDABLE;
2915
2916 if (t_bExpandOnly == true)
2917 m_dwSpinnedStyle |= UDS_NOSCROLL;
2918 else
2919 m_dwSpinnedStyle |= UDS_HORZ | UDS_ARROWKEYS | UDS_SETBU DDYINT | UDS_WRAP;
2920
2921 if (hWnd != NULL)
2922 AttachOrCreateSpinCtrl();
2923 }
2924
2925 CSpinned<TBase, t_bExpandOnly>& operator =(HWND hWnd)
2926 {
2927 Attach(hWnd);
2928 return *this;
2929 }
2930
2931 void Attach(HWND hWnd)
2932 {
2933 ATLASSERT(!IsWindow());
2934 TBase* pT = static_cast<TBase*>(this);
2935 pT->m_hWnd = hWnd;
2936 if (hWnd != NULL)
2937 AttachOrCreateSpinCtrl();
2938 }
2939
2940 HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szExpande dName = NULL,
2941 DWORD dwStyle = 0, DWORD dwExStyle = 0,
2942 ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = N ULL)
2943 {
2944
2945 TBase* pT = static_cast<TBase*>(this);
2946 TBase::Create(hWndParent, rect, NULL, dwStyle, dwExStyle, MenuOr ID, lpCreateParam);
2947 ATLASSERT(pT->m_hWnd != NULL);
2948
2949 m_SpinCtrl.Create(hWndParent, pT->m_hWnd, m_dwSpinnedStyle, ATL_ IDW_SPIN_ID + (int)MenuOrID.m_hMenu, szExpandedName);
2950
2951 ATLASSERT(m_SpinCtrl.m_hWnd != NULL); // Did you remember to c all AtlInitCommonControls(ICC_UPDOWN_CLASS)?
2952
2953 return pT->m_hWnd;
2954 }
2955
2956 // Attributes
2957 CSpinCtrl& GetSpinCtrl()
2958 {
2959 return m_SpinCtrl;
2960 }
2961
2962 // Implementation
2963 // Attach our existing SpinCtrl or create one
2964 bool AttachOrCreateSpinCtrl()
2965 {
2966 TBase* pT = static_cast<TBase*>(this);
2967
2968 HWND hSpin = ::GetDlgItem(pT->GetParent(), ATL_IDW_SPIN_ID + pT- >GetDlgCtrlID());
2969
2970 if (hSpin != NULL)
2971 {
2972 m_SpinCtrl.Attach(hSpin);
2973 #ifdef DEBUG
2974 TCHAR sClassName[16];
2975 ::GetClassName(hSpin, sClassName, 16);
2976 ATLASSERT(!_tcscmp(sClassName, UPDOWN_CLASS));
2977 ATLASSERT(m_SpinCtrl.GetBuddy().m_hWnd == pT->m_hWnd);
2978 #endif // DEBUG
2979 }
2980 else
2981 {
2982 m_SpinCtrl.Create(pT->GetParent(), pT->m_hWnd, m_dwSpinn edStyle, ATL_IDW_SPIN_ID + pT->GetDlgCtrlID());
2983 }
2984
2985 return m_SpinCtrl.m_hWnd != NULL;
2986 }
2987 };
2988
2989
2990 ///////////////////////////////////////////////////////////////////////////////
2991 // CSpinListBox - SmartPhone spinned ListBox control
2992 // CExpandListBox - SmartPhone expandable ListBox control
2993 // CExpandEdit - SmartPhone expandable Edit control
2994 // CExpandCapEdit - SmartPhone expandable CapEdit control
2995
2996 typedef CSpinned<CListBox, false> CSpinListBox;
2997 typedef CSpinned<CListBox, true> CExpandListBox;
2998 typedef CSpinned<CEdit, true> CExpandEdit;
2999 typedef CSpinned<CCapEdit, true> CExpandCapEdit;
3000
3001 #endif // WIN32_PLATFORM_WFSP
3002
3003 #endif // _WTL_CE_NO_CONTROLS
3004
3005 }; // namespace WTL
3006
3007 #endif // __ATLWINCE_H__
OLDNEW
« no previous file with comments | « third_party/wtl/include/atluser.h ('k') | third_party/wtl/include/atlwinx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698