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