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