1 // Windows Template Library - WTL version 8.0
2 // Copyright (C) Microsoft Corporation. All rights reserved.
4 // This file is a part of the Windows Template Library.
5 // The use and distribution terms for this software are covered by the
6 // Microsoft Permissive License (Ms-PL) which can be found in the file
7 // Ms-PL.txt at the root of this distribution.
10 #define __ATLWINCE_H__
15 #error ATL requires C++ compilation (use a .cpp suffix)
19 #error atlwince.h requires atlapp.h to be included first
23 #error atlwince.h requires atlwin.h to be included first
27 #error atlwince.h compiles under Windows CE only
28 #elif (_WIN32_WCE < 300)
29 #error atlwince.h requires Windows CE 3.0 or higher.
32 #if defined(WIN32_PLATFORM_WFSP) && _MSC_VER < 1400 // EVC compiling SmartPhone code
33 #if (WIN32_PLATFORM_WFSP < 200)
34 #error atlwince.h requires Smartphone 2003 or higher
36 #endif // WIN32_PLATFORM_WFSP
38 #if defined(WIN32_PLATFORM_PSPC) && _MSC_VER < 1400 // EVC compiling Pocket PC code
39 #if (WIN32_PLATFORM_PSPC < 310)
40 #error atlwince.h requires Pocket PC 2002 or higher
42 #endif // WIN32_PLATFORM_PSPC
44 #if !defined(_AYGSHELL_H_) && !defined(__AYGSHELL_H__)
45 #error atlwince.h requires aygshell.h to be included first
47 #if defined(WIN32_PLATFORM_WFSP) && !defined(_TPCSHELL_H_)
48 #error SmartPhone dialog classes require tpcshell.h to be included first
52 #if (_MSC_VER >= 1400) // VS2005
53 #include <DeviceResolutionAware.h>
55 #endif // (_MSC_VER >= 1400)
57 #if !defined(_WTL_CE_NO_DIALOGS) && !defined(__ATLFRAME_H__)
58 #error Orientation aware dialog classes require atlframe.h to be included first
61 #if !defined(_WTL_CE_NO_APPWINDOW) && !defined(__ATLFRAME_H__)
62 #error Application window class require atlframe.h to be included first
65 #if !defined(_WTL_CE_NO_ZOOMSCROLL) && !defined(__ATLSCRL_H__)
66 #error ZoomScroll implementation requires atlscrl.h to be included first
69 #if !defined(_WTL_CE_NO_ZOOMSCROLL)
70 #if !(defined(__ATLTYPES_H__) || (defined(__ATLMISC_H__) && !defined(_WTL_NO_WTYPES)))
71 #error ZoomScroll requires _WTL_NO_WTYPES not to be defined and either atlmisc.h or atltypes.h to be included first
72 #endif // !(defined(__ATLTYPES_H__) || (defined(__ATLMISC_H__) && !defined(_WTL_NO_WTYPES)))
73 #endif // !defined(_WTL_CE_NO_ZOOMSCROLL)
75 #if !defined(WIN32_PLATFORM_WFSP) && !defined(WIN32_PLATFORM_PSPC)
76 #define _WTL_CE_NO_CONTROLS
77 #endif // !defined(WIN32_PLATFORM_WFSP) && !defined(WIN32_PLATFORM_PSPC)
79 #ifndef _WTL_CE_NO_CONTROLS
80 #ifndef __ATLCTRLS_H__
81 #error The PPC/SmartPhone controls classes require atlctrls.h to be included first
85 #pragma comment(lib, "htmlview.lib")
88 #pragma comment(lib, "voicectl.lib")
90 #ifdef WIN32_PLATFORM_PSPC
92 #pragma comment(lib, "richink.lib")
95 #pragma comment(lib, "inkx.lib")
98 #pragma comment(lib, "doclist.lib")
103 ///////////////////////////////////////////////////////////////////////////////
104 // Classes in this file:
106 // CStdDialogBase<T, t_shidiFlags, t_bModal> : Standard PPC/SmartPhone dialog base class
107 // CStdDialogImplBase - Base implementation of standard dialog
108 // CStdDialogImpl<T, t_shidiFlags, t_bModal> : Standard dialog implementation
109 // CStdIndirectDialogImpl - implementation of standard indirect PPC/SmartPhone dialog
110 // CStdAxDialogImpl<T, t_shidiFlags, t_bModal> : Standard AxDialog implementation
111 // CStdSimpleDialog<t_wDlgTemplateID, t_shidiFlags> : Standard simple dialog
112 // CStdDialogResizeImplBase - Base implementation of orientation resizing standard dialog
113 // CStdDialogResizeImpl<T, t_shidiFlags, t_bModal> : Orientation resizing standard dialog implementation
114 // CStdAxDialogResizeImpl - implementation of orientation resizing standard AxDialog
115 // CStdSimpleDialogResizeImpl<T, t_wDlgTemplateID, t_shidiFlags> : Standard resizing simple dialog implementation
116 // CStdOrientedDialogBase - Oriented PPC standard dialog base class
117 // CStdOrientedDialogImplBase - Oriented PPC standard dialog base implementation
118 // CStdOrientedDialogImpl<T, t_shidiFlags, t_bModal> : Oriented PPC standard dialog implementation
119 // CStdAxOrientedDialogImpl - Oriented PPC standard AxDialog implementation
120 // CStdSimpleOrientedDialog<t_wDlgTemplateID, t_wDlgLandscapeID, t_shidiFlags> : Standard simple orientable dialog
122 // CAppInfoBase : Helper for application state save/restore to registry
123 // CAppInfoT<T> : CAppInfoBase constructed from a CAppWindow<T>
124 // CAppWindowBase<T> : Base class for PPC/SmartPhone well-behaved application window or dialog
125 // CAppWindow<T> : PPC/SmartPhone well-behaved application window class
126 // CAppDialog<T> : PPC/SmartPhone well-behaved application dialog class
127 // CAppStdDialogImplBase - Base implementation of standard application dialogs
128 // CAppStdDialogImpl<T, t_shidiFlags, t_bModal> : Implementation of standard application dialog
129 // CAppStdDialogResizeImpl - implementation of orientation resizing standard application dialog
130 // CAppStdAxDialogImpl - Implementation of standard application AxDialog
131 // CAppStdAxDialogResizeImpl - implementation of orientation resizing standard application AxDialog
132 // CAppStdOrientedDialogImpl - implementation of oriented PPC standard application dialog
133 // CAppStdAxOrientedDialogImpl - implementation of oriented PPC standard application AxDialog
135 // CFullScreenFrame<T, t_bHasSip> : Full screen frame class
137 // CZoomScrollImpl<T> : WinCE zooming implementation
139 // CBottomTabViewImpl<T, TBase, TWinTraits> - CBottomTabView
140 // CHtmlCtrlT<TBase> - CHtmlCtrl
141 // CRichInkCtrlT<TBase> - CRichInkCtrl
142 // CInkXCtrlT<TBase> - CInkXCtrl
143 // CVoiceRecorderCtrlT<TBase> - CVoiceRecorderCtrl
144 // CDocListCtrlT<TBase> - CDocListCtrl
145 // CCapEditT<TBase> - CCapEdit
146 // CTTStaticT<TBase> - CTTStatic
147 // CTTButtonT<TBase> - CTTButton
149 // CSpinCtrlT<TBase> - CSpinCtrl : SmartPhone specific UpDown control
150 // CSpinned<TBase, t_bExpandOnly> : SmartPhone association of control and Spin
151 // CSpinListBox : SmartPhone spinned ListBox control
152 // CExpandListBox : SmartPhone expandable ListBox control
153 // CExpandEdit : SmartPhone expandable Edit control
154 // CExpandCapEdit : SmartPhone expandable CapEdit control
157 // AtlCreateMenuBar()
158 // AtlCreateEmptyMenuBar()
160 // AtlActivateBackKey()
165 ///////////////////////////////////////////////////////////////////////////////
166 // MenuBar creation functions for property sheets and dialogs
167 // Frame windows use CreateSimpleCEMenuBar
169 inline HWND
AtlCreateMenuBar(SHMENUBARINFO
& mbi
)
171 ATLASSERT(::IsWindow(mbi
.hwndParent
));
172 ATLVERIFY(::SHCreateMenuBar(&mbi
) != FALSE
);
176 inline HWND
AtlCreateMenuBar(HWND hWnd
, UINT nToolBarId
= ATL_IDW_TOOLBAR
, DWORD dwFlags
= 0, int nBmpId
= 0, int cBmpImages
= 0, COLORREF clrBk
= 0)
178 SHMENUBARINFO mbi
= { sizeof(mbi
), hWnd
, dwFlags
, nToolBarId
, ModuleHelper::GetResourceInstance(), nBmpId
, cBmpImages
, 0, clrBk
};
179 return AtlCreateMenuBar(mbi
);
182 inline HWND
AtlCreateEmptyMenuBar(HWND hWnd
, bool bSip
= true)
184 SHMENUBARINFO embi
= { sizeof(SHMENUBARINFO
), hWnd
, SHCMBF_EMPTYBAR
};
186 embi
.dwFlags
|= SHCMBF_HIDESIPBUTTON
;
188 return AtlCreateMenuBar(embi
);
191 ///////////////////////////////////////////////////////////////////////////////
192 // Helper functions for SmartPhone back key handling
194 inline bool AtlIsEditFocus()
196 ATL::CWindow wCtrl
= GetFocus();
197 if (wCtrl
.IsWindow())
199 TCHAR szClassName
[8] = {0};
200 ATLVERIFY(::GetClassName(wCtrl
.m_hWnd
, szClassName
, 8));
201 return !_tcscmp(szClassName
, _T("Edit")) || !_tcscmp(szClassName
, WC_CAPEDIT
);
206 #if defined WIN32_PLATFORM_WFSP
207 inline void AtlActivateBackKey(HWND hMenuBar
)
209 ATLASSERT(::IsWindow(hMenuBar
));
210 ::SendMessage(hMenuBar
, SHCMBM_OVERRIDEKEY
, VK_TBACK
,
211 MAKELPARAM(SHMBOF_NODEFAULT
| SHMBOF_NOTIFY
, SHMBOF_NODEFAULT
| SHMBOF_NOTIFY
));
213 #endif // WIN32_PLATFORM_WFSP
215 // --- Standard PPC/SmartPhone dialogs ---
217 #ifndef _WTL_CE_NO_DIALOGS
219 ///////////////////////////////////////////////////////////////////////////////
220 // CStdDialogBase - base class for standard PPC/SmartPhone dialogs
222 #define WTL_STD_SHIDIF SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN
223 #define WTL_SP_SHIDIF SHIDIF_SIZEDLGFULLSCREEN
225 // Title setting macros
226 #define WTL_DLG_TITLEHEIGHT(iHeight) static const int GetTitleHeight(){return iHeight;}
227 #define WTL_DLG_NOTITLE WTL_DLG_TITLEHEIGHT(0)
229 ///////////////////////////////////////////////////////////////////////////////
230 // CStdDialogBase - Base class for standard PPC/SmartPhone dialog
232 template <class T
, UINT t_shidiFlags
, bool t_bModal
= true>
236 #ifdef WIN32_PLATFORM_PSPC
237 // Pocket PC only Dialog title handling
238 const int nTitleHeight
;
240 CStdDialogBase() : nTitleHeight(T::GetTitleHeight())
244 BOOL
GetClientRect(LPRECT lpRect
)
246 T
* pT
= static_cast<T
*>(this);
247 ATLASSERT(pT
->IsWindow());
248 BOOL bRes
= ::GetClientRect(pT
->m_hWnd
, lpRect
);
249 lpRect
->top
+= nTitleHeight
;
253 BOOL
SetWindowText(LPCTSTR lpszString
)
255 T
* pT
= static_cast<T
*>(this);
256 ATLASSERT(pT
->IsWindow());
257 BOOL bRes
= ::SetWindowText(pT
->m_hWnd
, lpszString
);
258 if (nTitleHeight
!= 0)
264 static const int GetTitleHeight()
267 return DRA::SCALEY(24);
268 #else // !_WTL_CE_DRA
270 return dc
.GetDeviceCaps(LOGPIXELSY
) >> 2; // LOGPIXELSY * 24 / 96,
271 #endif // !_WTL_CE_DRA
277 T
* pT
= static_cast<T
*>(this);
278 ATLASSERT(pT
->IsWindow());
282 CPaintDC
dc(pT
->m_hWnd
);
283 CFont fontTitle
= AtlCreateBoldFont();
284 CFontHandle fontOld
= dc
.SelectFont(fontTitle
);
285 dc
.SetTextColor(GetSysColor(COLOR_HIGHLIGHT
));
286 int nLen
= pT
->GetWindowText(sTitle
, 48);
287 int nWidth
= dc
.GetDeviceCaps(HORZRES
);
289 // Display title text
290 RECT rTitle
= { 0, 0, nWidth
, nTitleHeight
};
291 dc
.FillRect(&rTitle
, COLOR_3DHIGHLIGHT
);
293 rTitle
.left
= DRA::SCALEX(8);
294 #else // !_WTL_CE_DRA
295 rTitle
.left
= nTitleHeight
/ 3; // 8 == 24 / 3
296 #endif // !_WTL_CE_DRA
297 dc
.DrawText(sTitle
, nLen
, &rTitle
, DT_VCENTER
| DT_SINGLELINE
);
298 dc
.SelectFont(fontOld
);
300 // Draw bottom line, 2 pixels thick if HI_RES_AWARE
301 CPenHandle penOld
= dc
.SelectStockPen(BLACK_PEN
);
302 POINT line
[4] = {{0, nTitleHeight
}, {nWidth
, nTitleHeight
}, {0, nTitleHeight
- 1}, {nWidth
, nTitleHeight
- 1}};
305 int nSeg
= DRA::SCALEY(1);
306 #else // !_WTL_CE_DRA
307 int nSeg
= nTitleHeight
/ 24;
308 #endif // !_WTL_CE_DRA
310 dc
.Polyline(line
, nSeg
<= 2 ? nSeg
* 2 : 4);
311 dc
.SelectPen(penOld
);
316 // Title preparation: move the dialog controls down to make room for title
317 void DialogTitleInit()
319 T
* pT
= static_cast<T
*>(this);
320 ATLASSERT(pT
->IsWindow());
322 ATL::CWindow wCtl
= pT
->GetWindow(GW_CHILD
);
323 while (wCtl
.IsWindow())
326 wCtl
.GetWindowRect(&rCtl
);
327 ::MapWindowPoints(NULL
, pT
->m_hWnd
, (LPPOINT
)&rCtl
, 2);
328 ::OffsetRect(&rCtl
, 0, nTitleHeight
);
329 wCtl
.MoveWindow(&rCtl
, FALSE
);
330 wCtl
= wCtl
.GetWindow(GW_HWNDNEXT
);
337 T
* pT
= static_cast<T
*>(this);
338 ATLASSERT(pT
->IsWindow());
340 SIPINFO si
= {sizeof(SIPINFO
)};
342 if ((si
.fdwFlags
& SIPF_ON
) ^ SIPF_ON
)
343 si
.rcVisibleDesktop
.bottom
= si
.rcSipRect
.bottom
;
344 pT
->MoveWindow(&si
.rcVisibleDesktop
, FALSE
);
347 // Title painting handler
348 LRESULT
OnPaintTitle(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
350 T
* pT
= static_cast<T
*>(this);
351 return bHandled
= nTitleHeight
? pT
->DoPaintTitle() : FALSE
;
355 LRESULT
OnSettingChange(UINT
/*uMsg*/, WPARAM wParam
, LPARAM
/*lParam*/, BOOL
& bHandled
)
357 T
* pT
= static_cast<T
*>(this);
358 if (wParam
== SPI_SETSIPINFO
)
363 return bHandled
= FALSE
;
366 #elif defined WIN32_PLATFORM_WFSP
367 // SmartPhone VK_TBACK key standard management
368 LRESULT
OnHotKey(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& /*bHandled*/)
370 T
* pT
= static_cast<T
*>(this);
371 const UINT uModif
= (UINT
)LOWORD(lParam
);
372 const UINT uVirtKey
= (UINT
)HIWORD(lParam
);
374 if(uVirtKey
== VK_TBACK
)
375 if (AtlIsEditFocus())
376 ::SHSendBackToFocusWindow(uMsg
, wParam
, lParam
);
377 else if (uModif
& MOD_KEYUP
)
378 pT
->StdCloseDialog(IDCANCEL
);
382 // SmartPhone MenuBar and VK_TBACK key initialization
385 T
* pT
= static_cast<T
*>(this);
386 HWND hMenuBar
= ::SHFindMenuBar(pT
->m_hWnd
);
388 if (!hMenuBar
&& (t_shidiFlags
& SHIDIF_DONEBUTTON
))
389 hMenuBar
= CreateMenuBar(ATL_IDM_MENU_DONE
);
392 AtlActivateBackKey(hMenuBar
);
397 T
* pT
= static_cast<T
*>(this);
398 ATLASSERT(pT
->IsWindow());
400 CFontHandle fontBold
= AtlCreateBoldFont(pT
->GetFont());
402 ATL::CWindow wCtl
= pT
->GetWindow(GW_CHILD
);
404 while (wCtl
.IsWindow())
406 if ((short int)wCtl
.GetDlgCtrlID() == IDC_STATIC
)
407 wCtl
.SetFont(fontBold
);
408 wCtl
= wCtl
.GetWindow(GW_HWNDNEXT
);
411 #endif // WIN32_PLATFORM_WFSP
413 // Platform dependant initialization
414 void StdPlatformInit()
416 T
* pT
= static_cast<T
*>(this);
417 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title initialization
418 if (nTitleHeight
!= 0)
419 pT
->DialogTitleInit();
420 #elif defined(WIN32_PLATFORM_WFSP)
423 #endif // WIN32_PLATFORM_WFSP
427 HWND
CreateMenuBar(UINT uiMB
= T::IDD
, int nBmpImages
= 0)
429 T
* pT
= static_cast<T
*>(this);
430 return AtlCreateMenuBar(pT
->m_hWnd
, uiMB
, 0, nBmpImages
? uiMB
: 0, nBmpImages
);
434 void StdCloseDialog(WORD wID
)
436 T
* pT
= static_cast<T
*>(this);
438 ::EndDialog(pT
->m_hWnd
, wID
);
443 // Shell dialog layout initialization
446 T
* pT
= static_cast<T
*>(this);
447 SHINITDLGINFO shidi
= { SHIDIM_FLAGS
, pT
->m_hWnd
, t_shidiFlags
};
448 ::SHInitDialog(&shidi
);
451 // IDC_INFOSTATIC background setting
452 LRESULT
OnColorStatic(UINT
/*uMsg*/, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
454 if (::GetDlgCtrlID((HWND
)lParam
) == IDC_INFOSTATIC
)
456 ::SetBkMode((HDC
)wParam
, TRANSPARENT
);
457 return (LRESULT
)::GetSysColorBrush(COLOR_INFOBK
);
459 return bHandled
= FALSE
;
462 // Menu dialog ending
463 LRESULT
OnMenuClose(WORD
/*wNotifyCode*/, WORD wID
, HWND
/*hWndCtl*/, BOOL
& /*bHandled*/)
465 T
* pT
= static_cast<T
*>(this);
466 pT
->StdCloseDialog((WORD
)(wID
- ID_MENU_OK
+ IDOK
));
470 // Standard dialog ending: may be used with any command
471 LRESULT
OnCloseCmd(WORD
/*wNotifyCode*/, WORD wID
, HWND
/*hWndCtl*/, BOOL
& /*bHandled*/)
473 T
* pT
= static_cast<T
*>(this);
474 pT
->StdCloseDialog(wID
);
480 ///////////////////////////////////////////////////////////////////////////////
481 // CStdDialogImplBase - Base implementation of standard PPC/SmartPhone dialog
483 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true, class TBase
= ATL::CDialogImpl
< T
> >
484 class ATL_NO_VTABLE CStdDialogImplBase
:
486 public CStdDialogBase
<T
, t_shidiFlags
, t_bModal
>
489 #ifdef WIN32_PLATFORM_PSPC
490 BOOL
GetClientRect(LPRECT lpRect
)
492 return CStdDialogBase
<T
, t_shidiFlags
, t_bModal
>::GetClientRect(lpRect
);
495 BOOL
SetWindowText(LPCTSTR lpszString
)
497 return CStdDialogBase
<T
, t_shidiFlags
, t_bModal
>::SetWindowText(lpszString
);
501 BEGIN_MSG_MAP(CStdDialogImplBase
)
502 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title and SIP
503 MESSAGE_HANDLER(WM_PAINT
, OnPaintTitle
)
504 MESSAGE_HANDLER(WM_SETTINGCHANGE
, OnSettingChange
)
505 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
506 MESSAGE_HANDLER(WM_HOTKEY
, OnHotKey
)
508 MESSAGE_HANDLER(WM_CTLCOLORSTATIC
, OnColorStatic
)
509 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
510 COMMAND_RANGE_HANDLER(IDOK
, IDCANCEL
, OnCloseCmd
)
511 COMMAND_RANGE_HANDLER(ID_MENU_OK
, ID_MENU_CANCEL
, OnMenuClose
)
514 LRESULT
OnInitDialog(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
517 T
* pT
= static_cast<T
*>(this);
518 ATLASSERT(t_bModal
== pT
->m_bModal
);
522 return bHandled
= FALSE
;
526 ///////////////////////////////////////////////////////////////////////////////
527 // CStdDialogImpl - implementation of standard PPC/SmartPhone dialog
529 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true >
530 class ATL_NO_VTABLE CStdDialogImpl
: public CStdDialogImplBase
< T
, t_shidiFlags
, t_bModal
>
533 ///////////////////////////////////////////////////////////////////////////////
534 // CStdIndirectDialogImpl - implementation of standard indirect PPC/SmartPhone dialog
536 #if defined __ATLDLGS_H__
538 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true>
539 class ATL_NO_VTABLE CStdIndirectDialogImpl
:
540 public CIndirectDialogImpl
< T
, CMemDlgTemplate
, CStdDialogImpl
<T
, t_shidiFlags
, t_bModal
> >
543 typedef CIndirectDialogImpl
< T
, CMemDlgTemplate
, CStdDialogImpl
<T
, t_shidiFlags
, t_bModal
> > _baseClass
;
544 typedef CStdDialogImpl
<T
, t_shidiFlags
, t_bModal
> _baseStd
;
546 INT_PTR
DoModal(HWND hWndParent
= ::GetActiveWindow(), LPARAM dwInitParam
= NULL
)
550 if (!m_Template
.IsValid())
553 if (m_Template
.IsTemplateEx())
555 if (m_Template
.GetTemplateExPtr()->style
& DS_CENTER
)
557 ATLASSERT(m_Template
.GetTemplateExPtr()->style
^ WS_CHILD
);
558 GetTemplateExPtr()->style
|= WS_POPUP
;
563 if (m_Template
.GetTemplatePtr()->style
& DS_CENTER
)
565 ATLASSERT(m_Template
.GetTemplatePtr()->style
^ WS_CHILD
);
566 m_Template
.GetTemplatePtr()->style
|= WS_POPUP
;
570 return _baseClass::DoModal(hWndParent
, dwInitParam
);
573 HWND
Create(HWND hWndParent
, LPARAM dwInitParam
= NULL
)
575 ATLASSERT(!t_bModal
);
577 if (!m_Template
.IsValid())
580 if (m_Template
.IsTemplateEx())
582 if (GetTemplateExPtr()->style
& DS_CENTER
)
584 ATLASSERT(GetTemplateExPtr()->style
^ WS_CHILD
);
585 GetTemplateExPtr()->style
|= WS_POPUP
;
590 if (GetTemplatePtr()->style
& DS_CENTER
)
592 ATLASSERT(GetTemplatePtr()->style
^ WS_CHILD
);
593 GetTemplatePtr()->style
|= WS_POPUP
;
597 return _baseClass::Create(hWndParent
, dwInitParam
);
600 BEGIN_MSG_MAP(CStdIndirectDialogImpl
)
601 CHAIN_MSG_MAP(_baseStd
)
606 #endif // defined __ATLDLGS_H__
608 #ifndef _ATL_NO_HOSTING
610 ///////////////////////////////////////////////////////////////////////////////
611 // CStdAxDialogImpl - implementation of standard PPC/SmartPhone AxDialog
613 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true >
614 class ATL_NO_VTABLE CStdAxDialogImpl
: public CStdDialogImplBase
< T
, t_shidiFlags
, t_bModal
, ATL::CAxDialogImpl
< T
> >
616 #endif // _ATL_NO_HOSTING
618 ///////////////////////////////////////////////////////////////////////////////
619 // CStdSimpleDialog - standard PPC/SmartPhone simple dialog with SHIDIF_xxx flags
621 template <WORD t_wDlgTemplateID
, UINT t_shidiFlags
= WTL_STD_SHIDIF
>
622 class CStdSimpleDialog
:
623 public ATL::CSimpleDialog
<t_wDlgTemplateID
, FALSE
>,
624 public CStdDialogBase
<CStdSimpleDialog
<t_wDlgTemplateID
, t_shidiFlags
>, t_shidiFlags
>
627 typedef CStdDialogBase
<CStdSimpleDialog
<t_wDlgTemplateID
, t_shidiFlags
>, t_shidiFlags
> baseClass
;
629 #ifdef WIN32_PLATFORM_PSPC
630 BOOL
GetClientRect(LPRECT lpRect
)
632 return baseClass::GetClientRect(lpRect
);
635 BOOL
SetWindowText(LPCTSTR lpszString
)
637 return baseClass::SetWindowText(lpszString
);
641 BEGIN_MSG_MAP(CStdSimpleDialog
)
642 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title and SIP
643 MESSAGE_HANDLER(WM_PAINT
, OnPaintTitle
)
644 MESSAGE_HANDLER(WM_SETTINGCHANGE
, OnSettingChange
)
645 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
646 MESSAGE_HANDLER(WM_HOTKEY
, OnHotKey
)
648 MESSAGE_HANDLER(WM_CTLCOLORSTATIC
, OnColorStatic
)
649 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
650 COMMAND_RANGE_HANDLER(ID_MENU_OK
, ID_MENU_CANCEL
, OnMenuClose
)
651 COMMAND_RANGE_HANDLER(IDOK
, IDCANCEL
, baseClass::OnCloseCmd
)
654 LRESULT
OnInitDialog(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
658 return bHandled
= FALSE
;
662 ///////////////////////////////////////////////////////////////////////////////
663 // CStdDialogResizeImplBase - Base implementation of orientation resizing standard PPC/SmartPhone dialog
665 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true, class TBase
= ATL::CDialogImpl
<T
> >
666 class ATL_NO_VTABLE CStdDialogResizeImplBase
:
667 public CStdDialogImplBase
< T
, t_shidiFlags
, t_bModal
, TBase
>,
668 public CDialogResize
<T
>
671 // Note: BEGIN_DLGRESIZE_MAP is required in the derived class.
673 BEGIN_MSG_MAP(CStdResizeDialogImplBase
)
674 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title
675 MESSAGE_HANDLER(WM_PAINT
, OnPaintTitle
)
676 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
677 MESSAGE_HANDLER(WM_HOTKEY
, OnHotKey
)
679 MESSAGE_HANDLER(WM_CTLCOLORSTATIC
, OnColorStatic
)
680 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
681 COMMAND_RANGE_HANDLER(IDOK
, IDCANCEL
, OnCloseCmd
)
682 COMMAND_RANGE_HANDLER(ID_MENU_OK
, ID_MENU_CANCEL
, OnMenuClose
)
683 CHAIN_MSG_MAP(CDialogResize
< T
>)
686 LRESULT
OnInitDialog(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
689 T
* pT
= static_cast<T
*>(this);
690 ATLASSERT(t_bModal
== pT
->m_bModal
);
693 DlgResize_Init(FALSE
);
695 return bHandled
= FALSE
;
699 ///////////////////////////////////////////////////////////////////////////////
700 // CStdDialogResizeImpl - implementation of orientation resizing standard PPC/SmartPhone dialog
702 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true >
703 class ATL_NO_VTABLE CStdDialogResizeImpl
: public CStdDialogResizeImplBase
< T
, t_shidiFlags
, t_bModal
>
706 #ifndef _ATL_NO_HOSTING
708 ///////////////////////////////////////////////////////////////////////////////
709 // CStdAxDialogResizeImpl - implementation of orientation resizing standard PPC/SmartPhone AxDialog
711 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true >
712 class ATL_NO_VTABLE CStdAxDialogResizeImpl
: public CStdDialogResizeImplBase
< T
, t_shidiFlags
, t_bModal
, ATL::CAxDialogImpl
<T
> >
714 #endif // _ATL_NO_HOSTING
716 ///////////////////////////////////////////////////////////////////////////////
717 // CStdSimpleDialogResizeImpl - implementation of standard resizing simple dialog with SHIDIF_xxx flags
720 // class CMyDlg : public CStdSimpleDialogResize<CMyDlg,
721 // IDD_MYDLG, SHIDIF_DONEBUTTON | SHIDIF_FULLSCREENNOMENUBAR>
724 // BEGIN_DLGRESIZE_MAP(CMyDlg)
726 // END_DLGRESIZE_MAP()
729 template <class T
, WORD t_wDlgTemplateID
, UINT t_shidiFlags
= WTL_STD_SHIDIF
>
730 class ATL_NO_VTABLE CStdSimpleDialogResizeImpl
:
731 public CStdSimpleDialog
<t_wDlgTemplateID
, t_shidiFlags
>,
732 public CDialogResize
< T
>
735 typedef CStdSimpleDialog
<t_wDlgTemplateID
, t_shidiFlags
>::baseClass baseClass
;
737 BEGIN_MSG_MAP(CStdSimpleDialogResizeImpl
)
738 #ifdef WIN32_PLATFORM_PSPC // Pocket PC title
739 MESSAGE_HANDLER(WM_PAINT
, OnPaintTitle
)
740 #elif defined(WIN32_PLATFORM_WFSP) // SmartPhone VK_TBACK key
741 MESSAGE_HANDLER(WM_HOTKEY
, OnHotKey
)
743 MESSAGE_HANDLER(WM_CTLCOLORSTATIC
, OnColorStatic
)
744 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
745 COMMAND_RANGE_HANDLER(IDOK
, IDCANCEL
, baseClass::OnCloseCmd
)
746 COMMAND_RANGE_HANDLER(ID_MENU_OK
, ID_MENU_CANCEL
, OnMenuClose
)
747 CHAIN_MSG_MAP(CDialogResize
< T
>)
750 LRESULT
OnInitDialog(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
753 DlgResize_Init(FALSE
);
755 return bHandled
= FALSE
;
759 #if defined(_WTL_CE_DRA) && defined(WIN32_PLATFORM_PSPC)
761 ///////////////////////////////////////////////////////////////////////////////
762 // CStdOrientedDialogBase - Oriented PPC standard dialog base class
765 class CStdOrientedDialogBase
769 BOOL
SetOrientation(DRA::DisplayMode mode
)
771 T
* pT
= static_cast<T
*>(this);
772 ATLASSERT(pT
->IsWindow());
773 ATLASSERT(mode
== DRA::GetDisplayMode());
775 // Derived dialog must enumerate TWO dialog templates with the same control ids and types ie:
776 // enum { IDD = IDD_MYDLG, IDD_LANDSCAPE = IDD_MYDLG_L };
777 UINT iResource
= (mode
== DRA::Landscape
)? T::IDD_LANDSCAPE
: T::IDD
;
779 BOOL bRes
= DRA::RelayoutDialog(ModuleHelper::GetResourceInstance(), pT
->m_hWnd
, MAKEINTRESOURCE(iResource
));
780 pT
->OnOrientation(mode
);
785 void OnOrientation(DRA::DisplayMode
/*mode*/)
789 LRESULT
OnSettingChange(UINT
/*uMsg*/, WPARAM wParam
, LPARAM
/*lParam*/, BOOL
& bHandled
)
791 T
* pT
= static_cast<T
*>(this);
792 ATLASSERT(pT
->IsWindow());
793 if (wParam
== SETTINGCHANGE_RESET
)
795 SetOrientation(DRA::GetDisplayMode());
796 pT
->StdPlatformInit();
799 else if (wParam
== SPI_SETSIPINFO
)
804 return bHandled
= FALSE
;
808 ///////////////////////////////////////////////////////////////////////////////
809 // CStdOrientedDialogImplBase - Oriented PPC standard dialog base implementation
811 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true, class TBase
= ATL::CDialogImpl
<T
> >
812 class ATL_NO_VTABLE CStdOrientedDialogImplBase
:
813 public CStdDialogImplBase
< T
, t_shidiFlags
, t_bModal
, TBase
>,
814 public CStdOrientedDialogBase
<T
>
817 BEGIN_MSG_MAP(CStdOrientedDialogImpl
)
818 MESSAGE_HANDLER(WM_PAINT
, OnPaintTitle
)
819 MESSAGE_HANDLER(WM_CTLCOLORSTATIC
, OnColorStatic
)
820 MESSAGE_HANDLER(WM_SETTINGCHANGE
, CStdOrientedDialogBase
<T
>::OnSettingChange
)
821 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
822 COMMAND_RANGE_HANDLER(IDOK
, IDCANCEL
, OnCloseCmd
)
823 COMMAND_RANGE_HANDLER(ID_MENU_OK
, ID_MENU_CANCEL
, OnMenuClose
)
826 LRESULT
OnInitDialog(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
828 T
* pT
= static_cast<T
*>(this);
830 ATLASSERT(t_bModal
== pT
->m_bModal
);
832 if (DRA::GetDisplayMode() == DRA::Landscape
)
833 SetOrientation(DRA::Landscape
);
834 pT
->StdPlatformInit();
836 return bHandled
= FALSE
;
840 ///////////////////////////////////////////////////////////////////////////////
841 // CStdOrientedDialogImpl - Oriented PPC standard dialog implementation
843 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true >
844 class ATL_NO_VTABLE CStdOrientedDialogImpl
: public CStdOrientedDialogImplBase
< T
, t_shidiFlags
, t_bModal
>
847 #ifndef _ATL_NO_HOSTING
848 ///////////////////////////////////////////////////////////////////////////////
849 // CStdAxOrientedDialogImpl - Oriented PPC standard AxDialog implementation
851 template <class T
, UINT t_shidiFlags
= WTL_STD_SHIDIF
, bool t_bModal
= true >
852 class ATL_NO_VTABLE CStdAxOrientedDialogImpl
: public CStdOrientedDialogImplBase
< T
, t_shidiFlags
, t_bModal
, ATL::CAxDialogImpl
<T
> >
854 #endif // _ATL_NO_HOSTING
856 ///////////////////////////////////////////////////////////////////////////////
857 // CStdSimpleOrientedDialog - Standard simple orientable dialog
859 template <WORD t_wDlgTemplateID
, WORD t_wDlgLandscapeID
, UINT t_shidiFlags
= WTL_STD_SHIDIF
>
860 class CStdSimpleOrientedDialog
:
861 public CStdSimpleDialog
<t_wDlgTemplateID
, t_shidiFlags
>,
862 public CStdOrientedDialogBase
<CStdSimpleOrientedDialog
<t_wDlgTemplateID
, t_wDlgLandscapeID
, t_shidiFlags
> >
865 typedef CStdSimpleDialog
<t_wDlgTemplateID
, t_shidiFlags
>::baseClass baseClass
;
866 typedef CStdOrientedDialogBase
<CStdSimpleOrientedDialog
<t_wDlgTemplateID
, t_wDlgLandscapeID
, t_shidiFlags
> > baseOriented
;
868 enum {IDD
= t_wDlgTemplateID
, IDD_LANDSCAPE
= t_wDlgLandscapeID
};
870 BEGIN_MSG_MAP(CStdSimpleDialog
)
871 MESSAGE_HANDLER(WM_PAINT
, OnPaintTitle
)
872 MESSAGE_HANDLER(WM_CTLCOLORSTATIC
, OnColorStatic
)
873 MESSAGE_HANDLER(WM_SETTINGCHANGE
, baseOriented::OnSettingChange
)
874 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
875 COMMAND_RANGE_HANDLER(IDOK
, IDCANCEL
, baseClass::OnCloseCmd
)
876 COMMAND_RANGE_HANDLER(ID_MENU_OK
, ID_MENU_CANCEL
, OnMenuClose
)
879 LRESULT
OnInitDialog(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
881 if (DRA::GetDisplayMode() == DRA::Landscape
)
882 SetOrientation(DRA::Landscape
);
885 return bHandled
= FALSE
;
889 #endif // _WTL_CE_DRA
892 #endif // _WTL_CE_NO_DIALOGS
895 // --- PPC/SmartPhone application window and helpers ---
897 #ifndef _WTL_CE_NO_APPWINDOW
899 ///////////////////////////////////////////////////////////////////////////////
900 // CAppInfoBase - Helper for application state save/restore to registry
907 CAppInfoBase(ATL::_U_STRINGorID sAppKey
)
909 m_Key
.Create(HKEY_CURRENT_USER
, sAppKey
.m_lpstr
);
910 ATLASSERT(m_Key
.m_hKey
);
914 LONG
Save(V
& val
, ATL::_U_STRINGorID sName
)
916 return ::RegSetValueEx(m_Key
, sName
.m_lpstr
, 0, REG_BINARY
, (LPBYTE
)&val
, sizeof(V
));
920 LONG
Save(int nb
, V
& val0
, ATL::_U_STRINGorID sName
)
922 return ::RegSetValueEx(m_Key
, sName
.m_lpstr
, 0, REG_BINARY
, (LPBYTE
)&val0
, nb
* sizeof(V
));
926 LONG
Restore(V
& val
, ATL::_U_STRINGorID sName
)
929 DWORD bufSize
= sizeof(V
);
930 return ::RegQueryValueEx(m_Key
, sName
.m_lpstr
, 0, &valtype
, (LPBYTE
)&val
, &bufSize
);
934 LONG
Restore(int nb
, V
& val0
, ATL::_U_STRINGorID sName
)
937 DWORD bufSize
= nb
* sizeof(V
);
938 return ::RegQueryValueEx(m_Key
, sName
.m_lpstr
, 0, &valtype
, (LPBYTE
)&val0
, &bufSize
);
941 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
942 #if (_ATL_VER < 0x0800)
943 LONG
Save(_CSTRING_NS::CString
& sval
, ATL::_U_STRINGorID sName
)
945 return m_Key
.SetValue(sval
, sName
.m_lpstr
);
948 LONG
Restore(_CSTRING_NS::CString
& sval
, ATL::_U_STRINGorID sName
)
950 DWORD size
= MAX_PATH
;
951 LONG res
= m_Key
.QueryValue(sval
.GetBuffer(size
), sName
.m_lpstr
, &size
);
952 sval
.ReleaseBuffer();
955 #else // !(_ATL_VER < 0x0800)
956 LONG
Save(_CSTRING_NS::CString
& sval
, ATL::_U_STRINGorID sName
)
958 return m_Key
.SetStringValue(sName
.m_lpstr
, sval
);
961 LONG
Restore(_CSTRING_NS::CString
& sval
, ATL::_U_STRINGorID sName
)
963 DWORD size
= MAX_PATH
;
964 LONG res
= m_Key
.QueryStringValue(sName
.m_lpstr
, sval
.GetBuffer(size
), &size
);
965 sval
.ReleaseBuffer();
968 #endif // !(_ATL_VER < 0x0800)
970 #pragma message("Warning: CAppInfoBase compiles without CString support. Do not use CString in Save or Restore.")
971 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
973 #if (_ATL_VER < 0x0800)
974 LONG
Save(LPCTSTR sval
, ATL::_U_STRINGorID sName
)
976 return m_Key
.SetValue(sval
, sName
.m_lpstr
);
979 LONG
Restore(LPTSTR sval
, ATL::_U_STRINGorID sName
, DWORD
*plength
)
981 return m_Key
.QueryValue(sval
, sName
.m_lpstr
, plength
);
983 #else // !(_ATL_VER < 0x0800)
984 LONG
Save(LPCTSTR sval
, ATL::_U_STRINGorID sName
)
986 return m_Key
.SetStringValue(sName
.m_lpstr
, sval
);
989 LONG
Restore(LPTSTR sval
, ATL::_U_STRINGorID sName
, DWORD
*plength
)
991 return m_Key
.QueryStringValue(sName
.m_lpstr
, sval
, plength
);
993 #endif // !(_ATL_VER < 0x0800)
995 LONG
Delete(ATL::_U_STRINGorID sName
)
997 return m_Key
.DeleteValue(sName
.m_lpstr
);
1002 ///////////////////////////////////////////////////////////////////////////////
1003 // CAppInfoT - CAppInfoBase constructed from a class with T::GetAppKey()
1005 // Macro for declaring AppKey
1006 #define DECLARE_APPKEY(uAppKey) \
1007 static LPCTSTR GetAppKey() \
1009 static LPCTSTR sAppKey = ATL::_U_STRINGorID(uAppKey).m_lpstr; \
1014 class CAppInfoT
: public CAppInfoBase
1017 CAppInfoT() : CAppInfoBase(T::GetAppKey()){}
1021 ///////////////////////////////////////////////////////////////////////////////
1022 // CAppWindowBase - Base class for PPC/SmartPhone "well-behaved" application window or dialog
1024 // Macros for declaring frame WNDCLASS and AppKey
1025 #define DECLARE_APP_FRAME_CLASS(WndClassName, uCommonResourceID, uAppKey) \
1026 DECLARE_FRAME_WND_CLASS(WndClassName, uCommonResourceID) \
1027 DECLARE_APPKEY(uAppKey)
1029 #define DECLARE_APP_FRAME_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd, uAppKey) \
1030 DECLARE_FRAME_WND_CLASS_EX(WndClassName, uCommonResourceID, style, bkgnd) \
1031 DECLARE_APPKEY(uAppKey)
1034 class CAppWindowBase
1037 typedef class CAppInfoT
< T
> CAppInfo
;
1039 #ifndef WIN32_PLATFORM_WFSP
1040 SHACTIVATEINFO m_sai
; // NoOp on SmartPhones
1041 #endif // WIN32_PLATFORM_WFSP
1045 CAppWindowBase
< T
>() : m_bHibernate(false)
1047 #ifndef WIN32_PLATFORM_WFSP
1048 SHACTIVATEINFO sai
= { sizeof(SHACTIVATEINFO
) };
1050 #endif // WIN32_PLATFORM_WFSP
1053 // Same as WTL 7.1 AppWizard generated ActivatePreviousInstance + SendMessage WM_COPYDATA
1054 static HRESULT
ActivatePreviousInstance(HINSTANCE hInstance
, LPCTSTR lpstrCmdLine
, bool bDialog
)
1056 // requires T does DECLARE_APP_FRAME_CLASS, DECLARE_APP_FRAME_CLASS_EX or DECLARE_APP_DLG_CLASS
1057 CFrameWndClassInfo
& classInfo
= T::GetWndClassInfo();
1059 ATLVERIFY(::LoadString(hInstance
, classInfo
.m_uCommonResourceID
, classInfo
.m_szAutoName
, sizeof(classInfo
.m_szAutoName
)/sizeof(classInfo
.m_szAutoName
[0])) != 0);
1061 classInfo
.m_wc
.lpszClassName
= classInfo
.m_szAutoName
;
1063 const TCHAR
* pszClass
= classInfo
.m_wc
.lpszClassName
;
1065 if(NULL
== pszClass
|| '\0' == *pszClass
)
1070 const DWORD dRetryInterval
= 100;
1071 const int iMaxRetries
= 25;
1073 for(int i
= 0; i
< iMaxRetries
; ++i
)
1075 HANDLE hMutex
= CreateMutex(NULL
, FALSE
, pszClass
);
1077 DWORD dw
= GetLastError();
1085 case ERROR_INVALID_HANDLE
:
1086 // A non-mutext object with this name already exists.
1090 // This should never happen...
1097 // If the mutex already exists, then there should be another instance running
1098 if(dw
== ERROR_ALREADY_EXISTS
)
1100 CloseHandle(hMutex
);
1104 hwnd
= FindWindow(NULL
, pszClass
);
1106 hwnd
= FindWindow(pszClass
, NULL
);
1110 Sleep(dRetryInterval
);
1115 // Transmit our params to previous instance
1116 if (lpstrCmdLine
&& *lpstrCmdLine
)
1118 COPYDATASTRUCT cd
= { NULL
, sizeof(TCHAR
) * (wcslen(lpstrCmdLine
) + 1), (PVOID
)lpstrCmdLine
};
1119 ::SendMessage(hwnd
, WM_COPYDATA
, NULL
, (LPARAM
)&cd
);
1121 // Set the previous instance as the foreground window
1122 if(0 != SetForegroundWindow(reinterpret_cast<HWND
>(reinterpret_cast<ULONG
>(hwnd
) | 0x1)))
1134 // Operations overriden in derived class
1135 bool AppHibernate(bool /*bHibernate*/)
1140 bool AppNewInstance(LPCTSTR
/*lpstrCmdLine*/)
1149 #ifdef WIN32_PLATFORM_WFSP
1156 // Message map and handlers
1157 BEGIN_MSG_MAP(CAppWindowBase
)
1158 MESSAGE_HANDLER(WM_ACTIVATE
, OnActivate
)
1159 #ifdef WIN32_PLATFORM_WFSP
1160 MESSAGE_HANDLER(WM_HOTKEY
, OnHotKey
)
1162 MESSAGE_HANDLER(WM_SETTINGCHANGE
, OnSettingChange
)
1163 #endif // WIN32_PLATFORM_WFSP
1164 MESSAGE_HANDLER(WM_HIBERNATE
, OnHibernate
)
1165 MESSAGE_HANDLER(WM_COPYDATA
, OnNewInstance
)
1166 MESSAGE_HANDLER(WM_CLOSE
, OnClose
)
1169 LRESULT
OnActivate(UINT
/*uMsg*/, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
1171 T
* pT
= static_cast<T
*>(this);
1173 m_bHibernate
= pT
->AppHibernate(false);
1174 #ifndef WIN32_PLATFORM_WFSP
1175 ::SHHandleWMActivate(pT
->m_hWnd
, wParam
, lParam
, &m_sai
, 0);
1179 #endif // WIN32_PLATFORM_WFSP
1180 return bHandled
= FALSE
;
1183 #ifdef WIN32_PLATFORM_WFSP
1184 // SmartPhone VK_TBACK key standard management
1185 LRESULT
OnHotKey(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& /*bHandled*/)
1187 T
* pT
= static_cast<T
*>(this);
1188 const UINT uModif
= (UINT
)LOWORD(lParam
);
1189 const UINT uVirtKey
= (UINT
)HIWORD(lParam
);
1190 if(uVirtKey
== VK_TBACK
)
1191 if (AtlIsEditFocus())
1192 ::SHSendBackToFocusWindow(uMsg
, wParam
, lParam
);
1193 else if (uModif
& MOD_KEYUP
)
1198 #else // !WIN32_PLATFORM_WFSP
1200 LRESULT
OnSettingChange(UINT
/*uMsg*/, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
1202 T
* pT
= static_cast<T
*>(this);
1204 return ::SHHandleWMSettingChange(pT
->m_hWnd
, wParam
, lParam
, &m_sai
);
1206 #endif // !WIN32_PLATFORM_WFSP
1208 LRESULT
OnHibernate(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& /*bHandled*/)
1210 T
* pT
= static_cast<T
*>(this);
1211 return m_bHibernate
= pT
->AppHibernate(true);
1214 LRESULT
OnNewInstance(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM lParam
, BOOL
& /*bHandled*/)
1216 T
* pT
= static_cast<T
*>(this);
1217 PCOPYDATASTRUCT pcds
= (PCOPYDATASTRUCT
)lParam
;
1218 return pT
->AppNewInstance((LPCTSTR
)pcds
->lpData
);
1221 LRESULT
OnClose(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& bHandled
)
1223 T
* pT
= static_cast<T
*>(this);
1231 ///////////////////////////////////////////////////////////////////////////////
1232 // CAppWindow - PPC/SmartPhone "well-behaved" application window class
1235 class CAppWindow
: public CAppWindowBase
< T
>
1238 // Same as WTL 7.1 AppWizard generated Run + lpstrCmdLine in CreateEx
1239 static int AppRun(LPTSTR lpstrCmdLine
= NULL
, int nCmdShow
= SW_SHOWNORMAL
)
1241 CMessageLoop theLoop
;
1242 _Module
.AddMessageLoop(&theLoop
);
1246 if(wndMain
.CreateEx(NULL
, NULL
, 0, 0, lpstrCmdLine
) == NULL
)
1248 ATLTRACE2(atlTraceUI
, 0, _T("Main window creation failed!\n"));
1252 wndMain
.ShowWindow(nCmdShow
);
1254 int nRet
= theLoop
.Run();
1256 _Module
.RemoveMessageLoop();
1260 static HRESULT
ActivatePreviousInstance(HINSTANCE hInstance
, LPCTSTR lpstrCmdLine
)
1262 return CAppWindowBase
< T
>::ActivatePreviousInstance(hInstance
, lpstrCmdLine
, false);
1267 #ifndef _WTL_CE_NO_DIALOGS
1269 ///////////////////////////////////////////////////////////////////////////////
1270 // CAppDialog - PPC/SmartPhone "well-behaved" dialog application class
1272 // Macro for declaring dialog WNDCLASS and AppKey
1273 #define DECLARE_APP_DLG_CLASS(WndClassName, uCommonResourceID, uAppKey) \
1274 static WTL::CFrameWndClassInfo& GetWndClassInfo() \
1276 static WTL::CFrameWndClassInfo wc = \
1278 { 0, (WNDPROC)StartDialogProc, \
1279 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, WndClassName }, \
1280 NULL, NULL, IDC_ARROW, TRUE, 0, _T(""), uCommonResourceID \
1284 DECLARE_APPKEY(uAppKey)
1287 class CAppDialog
: public CAppWindowBase
< T
>
1290 static int AppRun(LPTSTR lpstrCmdLine
= NULL
, int nCmdShow
= SW_SHOWNORMAL
)
1292 CMessageLoop theLoop
;
1293 _Module
.AddMessageLoop(&theLoop
);
1297 if(dlgMain
.Create(NULL
, (LPARAM
)lpstrCmdLine
) == NULL
)
1299 ATLTRACE2(atlTraceUI
, 0, _T("Main dialog creation failed!\n"));
1303 dlgMain
.ShowWindow(nCmdShow
);
1305 int nRet
= theLoop
.Run();
1307 _Module
.RemoveMessageLoop();
1311 static HRESULT
ActivatePreviousInstance(HINSTANCE hInstance
, LPCTSTR lpstrCmdLine
)
1313 return CAppWindowBase
< T
>::ActivatePreviousInstance(hInstance
, lpstrCmdLine
, true);
1317 // PPC/SmartPhone standard application dialogs
1319 #ifdef WIN32_PLATFORM_WFSP
1320 #define WTL_APP_SHIDIF WTL_SP_SHIDIF
1322 #define WTL_APP_SHIDIF WTL_STD_SHIDIF
1325 ///////////////////////////////////////////////////////////////////////////////
1326 // CAppStdDialogImplBase - Base implementation of standard application dialogs
1328 template <class T
, class TImplBase
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1329 class ATL_NO_VTABLE CAppStdDialogImplBase
:
1331 public CAppDialog
< T
>
1336 void StdCloseDialog(int nVal
)
1338 T
* pT
= static_cast<T
*>(this);
1339 if (nVal
!= IDCANCEL
)
1341 if (t_bModal
== false)
1343 pT
->DestroyWindow();
1344 ::PostQuitMessage(nVal
);
1347 ::EndDialog(pT
->m_hWnd
, nVal
);
1350 BEGIN_MSG_MAP(CAppStdDialogImplBase
)
1351 MESSAGE_HANDLER(WM_CLOSE
, OnSystemClose
)
1352 CHAIN_MSG_MAP(TImplBase
)
1353 CHAIN_MSG_MAP(CAppDialog
< T
>)
1356 LRESULT
OnSystemClose(UINT
/*uMsg*/, WPARAM
/*wParam*/, LPARAM
/*lParam*/, BOOL
& /*bHandled*/)
1358 T
* pT
= static_cast<T
*>(this);
1359 pT
->StdCloseDialog(IDCANCEL
);
1364 ///////////////////////////////////////////////////////////////////////////////
1365 // CAppStdDialogImpl - Implementation of standard application dialog
1367 template <class T
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1368 class ATL_NO_VTABLE CAppStdDialogImpl
:
1369 public CAppStdDialogImplBase
<T
, CStdDialogImpl
<T
, t_shidiFlags
, t_bModal
>, t_shidiFlags
, t_bModal
>
1372 ///////////////////////////////////////////////////////////////////////////////
1373 // CAppStdDialogResizeImpl - implementation of orientation resizing standard application dialog
1375 template <class T
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1376 class ATL_NO_VTABLE CAppStdDialogResizeImpl
:
1377 public CAppStdDialogImplBase
<T
, CStdDialogResizeImpl
<T
, t_shidiFlags
, t_bModal
>, t_shidiFlags
, t_bModal
>
1380 #ifndef _ATL_NO_HOSTING
1381 ///////////////////////////////////////////////////////////////////////////////
1382 // CAppStdAxDialogImpl - Implementation of standard application AxDialog
1384 template <class T
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1385 class ATL_NO_VTABLE CAppStdAxDialogImpl
:
1386 public CAppStdDialogImplBase
<T
, CStdAxDialogImpl
<T
, t_shidiFlags
, t_bModal
>, t_shidiFlags
, t_bModal
>
1389 ///////////////////////////////////////////////////////////////////////////////
1390 // CAppStdAxDialogResizeImpl - implementation of orientation resizing standard application AxDialog
1392 template <class T
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1393 class ATL_NO_VTABLE CAppStdAxDialogResizeImpl
:
1394 public CAppStdDialogImplBase
<T
, CStdAxDialogResizeImpl
<T
, t_shidiFlags
, t_bModal
>, t_shidiFlags
, t_bModal
>
1396 #endif // _ATL_NO_HOSTING
1398 #if defined(_WTL_CE_DRA) && defined(WIN32_PLATFORM_PSPC)
1399 ///////////////////////////////////////////////////////////////////////////////
1400 // CAppStdOrientedDialogImpl - implementation of oriented PPC standard application dialog
1402 template <class T
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1403 class ATL_NO_VTABLE CAppStdOrientedDialogImpl
:
1404 public CAppStdDialogImplBase
<T
, CStdOrientedDialogImpl
<T
, t_shidiFlags
, t_bModal
>, t_shidiFlags
, t_bModal
>
1407 #ifndef _ATL_NO_HOSTING
1408 ///////////////////////////////////////////////////////////////////////////////
1409 // CAppStdAxOrientedDialogImpl - implementation of oriented PPC standard application AxDialog
1411 template <class T
, UINT t_shidiFlags
= WTL_APP_SHIDIF
, bool t_bModal
= false>
1412 class ATL_NO_VTABLE CAppStdAxOrientedDialogImpl
:
1413 public CAppStdDialogImplBase
<T
, CStdAxOrientedDialogImpl
<T
, t_shidiFlags
, t_bModal
>, t_shidiFlags
, t_bModal
>
1415 #endif // _ATL_NO_HOSTING
1417 #endif // defined(_WTL_CE_DRA) && defined(WIN32_PLATFORM_PSPC)
1419 #endif // _WTL_CE_NO_DIALOGS
1421 #endif // _WTL_CE_NO_APPWINDOW
1424 // --- Full screen support ---
1426 #ifndef _WTL_CE_NO_FULLSCREEN
1428 ///////////////////////////////////////////////////////////////////////////////
1429 // CFullScreenFrame - full screen frame implementation
1431 template <class T
, bool t_bHasSip
= true>
1432 class CFullScreenFrame
1437 CFullScreenFrame() : m_bFullScreen(false)
1441 void SetFullScreen(bool bFull
)
1443 m_bFullScreen
= bFull
;
1444 ShowTaskBar(!bFull
, false);
1445 ShowMenuBar(!bFull
);
1448 // Manage TaskBar for modal dialogs and property sheets
1450 int FSDoModal(D
& dlg
)
1452 T
* pT
= static_cast<T
*>(this);
1453 pT
; // avoid level 4 warning
1454 ATLASSERT(pT
->IsWindow());
1455 if (m_bFullScreen
) // Show taskbar if hidden
1456 ShowTaskBar(true, false);
1457 int iRet
= dlg
.DoModal();
1458 if (m_bFullScreen
) // Hide taskbar if restored
1464 void ShowMenuBar(bool bShow
)
1466 T
* pT
= static_cast<T
*>(this);
1467 ATLASSERT(pT
->IsWindow());
1468 ATL::CWindow MenuBar
= pT
->m_hWndCECommandBar
;
1469 ATLASSERT(MenuBar
.IsWindow());
1470 MenuBar
.ShowWindow(bShow
? SW_SHOWNORMAL
: SW_HIDE
);
1471 pT
->SizeToMenuBar();
1474 void ShowTaskBar(bool bShow
, bool bRepaint
= true)
1476 T
* pT
= static_cast<T
*>(this);
1477 ATLASSERT(pT
->IsWindow());
1479 SystemParametersInfo(SPI_GETWORKAREA
, NULL
, &rect
, FALSE
);
1483 #ifdef WIN32_PLATFORM_PSPC // Pocket PC code
1484 UINT uShow
= t_bHasSip
? SHFS_SHOWTASKBAR
| SHFS_SHOWSIPBUTTON
: SHFS_SHOWTASKBAR
| SHFS_HIDESIPBUTTON
;
1485 SHFullScreen(pT
->m_hWnd
, bShow
? uShow
: SHFS_HIDETASKBAR
| SHFS_HIDESIPBUTTON
);
1486 #elif _WIN32_WCE > 0x500 // Smartphone 2005 code
1487 SHFullScreen(pT
->m_hWnd
, bShow
? SHFS_SHOWTASKBAR
: SHFS_HIDETASKBAR
);
1488 #else // Smartphone 2003
1489 HWND hTaskBar
= FindWindow(_T("tray"), NULL
);
1490 ATLASSERT(::IsWindow(hTaskBar
));
1491 ::ShowWindow(hTaskBar
, bShow
? SW_SHOW
: SW_HIDE
);
1492 #endif // WIN32_PLATFORM_PSPC
1494 pT
->MoveWindow(&rect
, bRepaint
);
1497 // Message map and handler
1498 BEGIN_MSG_MAP(CFullScreenFrame
)
1499 MESSAGE_HANDLER(WM_SETTINGCHANGE
, OnSettingChange
)
1500 MESSAGE_HANDLER(WM_ACTIVATE
, OnActivate
)
1503 LRESULT
OnSettingChange(UINT
/*uMsg*/, WPARAM wParam
, LPARAM
/*lParam*/, BOOL
& bHandled
)
1505 #ifndef SETTINGCHANGE_RESET // not defined for PPC 2002
1506 #define SETTINGCHANGE_RESET SPI_SETWORKAREA
1508 if (m_bFullScreen
&& (wParam
& SETTINGCHANGE_RESET
))
1509 SetFullScreen(m_bFullScreen
);
1510 return bHandled
= FALSE
;
1513 LRESULT
OnActivate(UINT
/*uMsg*/, WPARAM wParam
, LPARAM
/*lParam*/, BOOL
& bHandled
)
1517 ShowTaskBar(!wParam
);
1518 ShowMenuBar(!wParam
);
1520 return bHandled
= FALSE
;
1524 #endif // _WTL_CE_NO_FULLSCREEN
1527 // --- WinCE zoom support ---
1529 #ifndef _WTL_CE_NO_ZOOMSCROLL
1531 ///////////////////////////////////////////////////////////////////////////////
1532 // CZoomScrollImpl - WinCE zooming implementation on top of CScrollImpl
1535 class CZoomScrollImpl
: public CScrollImpl
< T
>
1539 _WTYPES_NS::CSize m_sizeTrue
;
1543 CZoomScrollImpl() : m_sizeTrue(0), m_fzoom(1.)
1546 // Zoom operations and access
1547 void SetZoomScrollSize(_WTYPES_NS::CSize sizeTrue
, double fzoom
= 1., BOOL bRedraw
= TRUE
)
1549 ATLASSERT(fzoom
> 0.);
1550 m_sizeTrue
= sizeTrue
;
1553 CScrollImpl
< T
>::SetScrollSize(sizeTrue
/ fzoom
, bRedraw
);
1556 void SetZoomScrollSize(int cx
, int cy
, double fzoom
=1., BOOL bRedraw
= TRUE
)
1558 SetZoomScrollSize(_WTYPES_NS::CSize(cx
, cy
), fzoom
, bRedraw
);
1561 void SetZoom(double fzoom
, BOOL bRedraw
= TRUE
)
1563 _WTYPES_NS::CPoint ptCenter
= WndtoTrue(m_sizeClient
/ 2);
1564 _WTYPES_NS::CSize sizePage
= GetScrollPage();
1565 _WTYPES_NS::CSize sizeLine
= GetScrollLine();
1567 SetZoomScrollSize(GetScrollSize(), fzoom
, bRedraw
);
1569 SetScrollLine(sizeLine
);
1570 SetScrollPage(sizePage
);
1571 _WTYPES_NS::CPoint ptOffset
= ptCenter
- (m_sizeClient
/ 2) * fzoom
;
1572 SetScrollOffset(ptOffset
, bRedraw
);
1580 // CScrollImpl overrides
1581 void SetScrollOffset(int x
, int y
, BOOL bRedraw
= TRUE
)
1583 CScrollImpl
< T
>::SetScrollOffset((int)(x
/ m_fzoom
), (int)(y
/ m_fzoom
), bRedraw
);
1586 void SetScrollOffset(POINT ptOffset
, BOOL bRedraw
= TRUE
)
1588 SetScrollOffset(ptOffset
.x
, ptOffset
.y
, bRedraw
);
1591 void GetScrollOffset(POINT
& ptOffset
)
1593 ptOffset
.x
= (LONG
)(m_ptOffset
.x
* m_fzoom
);
1594 ptOffset
.y
= (LONG
)(m_ptOffset
.y
* m_fzoom
);
1597 void SetScrollSize(int cx
, int cy
, BOOL bRedraw
= TRUE
)
1599 SetZoomScrollSize(cx
, cy
, GetZoom(), bRedraw
);
1602 void SetScrollSize(SIZE sizeTrue
, BOOL bRedraw
= TRUE
)
1604 SetZoomScrollSize(sizeTrue
, GetZoom(), bRedraw
);
1607 void GetScrollSize(SIZE
& sizeTrue
) const
1609 sizeTrue
= m_sizeTrue
;
1612 void SetScrollPage(int cxPage
, int cyPage
)
1614 SetScrollPage(_WTYPES_NS::CSize(cxPage
, cyPage
));
1617 void SetScrollPage(SIZE sizePage
)
1619 CScrollImpl
< T
>::SetScrollPage(sizePage
/ m_fzoom
);
1622 void GetScrollPage(SIZE
& sizePage
) const
1624 sizePage
= m_sizePage
* m_fzoom
;
1627 void SetScrollLine(int cxLine
, int cyLine
)
1629 SetScrollLine(_WTYPES_NS::CSize(cxLine
, cyLine
));
1632 void SetScrollLine(SIZE sizeLine
)
1634 CScrollImpl
< T
>::SetScrollLine(sizeLine
/ m_fzoom
);
1637 void GetScrollLine(SIZE
& sizeLine
) const
1639 sizeLine
= m_sizeLine
* m_fzoom
;
1642 // Data access complements
1643 _WTYPES_NS::CSize
GetScrollSize()
1648 _WTYPES_NS::CSize
GetScrollPage()
1650 return m_sizePage
* m_fzoom
;
1653 _WTYPES_NS::CSize
GetScrollLine()
1655 return m_sizeLine
* m_fzoom
;
1658 _WTYPES_NS::CPoint
GetScrollOffset()
1660 return (_WTYPES_NS::CSize
)m_ptOffset
* m_fzoom
;
1663 // Helper coordinate functions
1664 _WTYPES_NS::CPoint
WndtoTrue(CPoint ptW
)
1666 return (_WTYPES_NS::CSize
)ptW
* GetZoom() + GetScrollOffset();
1669 void WndtoTrue(LPPOINT aptW
, int nPts
) // in place coord transformation
1671 for (int i
= 0 ; i
< nPts
; i
++)
1672 aptW
[i
] = WndtoTrue(aptW
[i
]);
1675 void WndtoTrue(LPRECT prectW
) // in place coord transformation
1677 WndtoTrue((LPPOINT
)prectW
, 2);
1680 _WTYPES_NS::CPoint
TruetoWnd(CPoint ptT
)
1682 return (ptT
- GetScrollOffset()) / GetZoom();
1685 void TruetoWnd(LPPOINT aptT
, int nPts
) // in place coord transformation
1687 for (int i
= 0 ; i
< nPts
; i
++)
1688 aptT
[i
] = TruetoWnd(aptT
[i
]);
1691 void TruetoWnd(LPRECT prectT
) // in place coord transformation
1693 TruetoWnd((LPPOINT
)prectT
, 2);
1696 // Drawing operations : assume adequate setting of data members
1697 BOOL
Draw(HBITMAP hbm
, HDC hdestDC
, DWORD dwROP
= SRCCOPY
)
1699 CDC memDC
= CreateCompatibleDC(hdestDC
);
1700 CBitmapHandle bmpOld
= memDC
.SelectBitmap(hbm
);
1701 BOOL bRes
= Draw(memDC
, hdestDC
, dwROP
);
1702 memDC
.SelectBitmap(bmpOld
);
1706 BOOL
Draw(HDC hsourceDC
, HDC hdestDC
, DWORD dwROP
= SRCCOPY
)
1708 CDCHandle destDC
= hdestDC
;
1709 destDC
.SetViewportOrg(0,0);
1710 _WTYPES_NS::CPoint ptOffset
= GetScrollOffset();
1711 _WTYPES_NS::CSize sizeZClient
= m_sizeClient
* GetZoom();
1712 return destDC
.StretchBlt(0, 0, m_sizeClient
.cx
, m_sizeClient
.cy
, hsourceDC
, ptOffset
.x
, ptOffset
.y
, sizeZClient
.cx
, sizeZClient
.cy
, dwROP
);
1716 BOOL
Draw(IImage
* pIImage
, HDC hdestDC
)
1718 CDCHandle destDC
= hdestDC
;
1719 destDC
.SetViewportOrg(0,0);
1720 return SUCCEEDED(pIImage
->Draw(destDC
, _WTYPES_NS::CRect(-_WTYPES_NS::CPoint(m_ptOffset
), m_sizeAll
), NULL
));
1724 // Message map and handlers
1725 BEGIN_MSG_MAP(CZoomScrollImpl
< T
>)
1726 MESSAGE_HANDLER(WM_ERASEBKGND
, OnEraseBkgnd
)
1727 CHAIN_MSG_MAP(CScrollImpl
< T
>)
1730 LRESULT
OnEraseBkgnd(UINT
/*uMsg*/, WPARAM wParam
, LPARAM
/*lParam*/, BOOL
& bHandled
)
1732 T
* pT
= static_cast<T
*>(this);
1733 ATLASSERT(::IsWindow(pT
->m_hWnd
));
1734 if ((GetScrollExtendedStyle() & SCRL_ERASEBACKGROUND
))
1736 _WTYPES_NS::CRect rect
;
1737 pT
->GetClientRect(rect
);
1738 _WTYPES_NS::CSize sizeClient
=rect
.Size();
1740 if (m_sizeAll
.cx
< sizeClient
.cx
|| m_sizeAll
.cy
< sizeClient
.cy
)
1742 CDCHandle hdc
= (HDC
)wParam
;
1743 HBRUSH hbr
= GetSysColorBrush((int)T::GetWndClassInfo().m_wc
.hbrBackground
- 1);
1745 if (m_sizeAll
.cx
< sizeClient
.cx
)
1747 _WTYPES_NS::CRect
rectBG(_WTYPES_NS::CPoint(m_sizeAll
.cx
, 0), sizeClient
);
1748 hdc
.FillRect(rectBG
, hbr
);
1751 if (m_sizeAll
.cy
< sizeClient
.cy
)
1753 _WTYPES_NS::CRect
rectBG(_WTYPES_NS::CPoint(0, m_sizeAll
.cy
), sizeClient
);
1754 hdc
.FillRect(rectBG
, hbr
);
1767 #endif // _WTL_CE_NO_ZOOMSCROLL
1769 #ifndef _WTL_CE_NO_CONTROLS
1771 // --- PPC bottom TabView control ---
1773 #if defined(__ATLCTRLX_H__) && defined(WIN32_PLATFORM_PSPC)
1775 ///////////////////////////////////////////////////////////////////////////////
1776 // CBottomTabViewImpl
1778 template <class T
, class TBase
= ATL::CWindow
, class TWinTraits
= ATL::CControlWinTraits
>
1779 class ATL_NO_VTABLE CBottomTabViewImpl
: public CTabViewImpl
<T
, TBase
, TWinTraits
>
1782 DECLARE_WND_CLASS_EX(NULL
, 0, COLOR_APPWORKSPACE
)
1784 // Implementation overrideables
1785 bool CreateTabControl()
1787 m_tab
.Create(m_hWnd
, rcDefault
, NULL
, WS_CHILD
| TCS_BOTTOM
, 0, m_nTabID
);
1789 ATLASSERT(m_tab
.m_hWnd
!= NULL
);
1790 if(m_tab
.m_hWnd
== NULL
)
1793 m_tab
.SendMessage(CCM_SETVERSION
, COMCTL32_VERSION
);
1794 m_tab
.SetItemExtra(sizeof(TABVIEWPAGE
));
1796 T
* pT
= static_cast<T
*>(this);
1797 m_cyTabHeight
= pT
->CalcTabHeight();
1804 int nCount
= m_tab
.GetItemCount();
1805 TCITEMEXTRA tcix
= { 0 };
1806 tcix
.tciheader
.mask
= TCIF_TEXT
;
1807 tcix
.tciheader
.pszText
= _T("NS");
1808 int nIndex
= m_tab
.InsertItem(nCount
, tcix
);
1811 SystemParametersInfo(SPI_GETWORKAREA
, 0, &rect
, 0);
1814 m_tab
.AdjustRect(FALSE
, &rect
);
1815 rcWnd
.top
= rect
.bottom
;
1816 ::AdjustWindowRectEx(&rcWnd
, m_tab
.GetStyle(), FALSE
, m_tab
.GetExStyle());
1817 m_tab
.DeleteItem(nIndex
);
1819 return rcWnd
.bottom
- rcWnd
.top
;
1825 GetClientRect(&rect
);
1827 if(m_tab
.IsWindow() && ((m_tab
.GetStyle() & WS_VISIBLE
) != 0))
1828 m_tab
.SetWindowPos(NULL
, 0, rect
.bottom
- m_cyTabHeight
, rect
.right
- rect
.left
, m_cyTabHeight
, SWP_NOZORDER
/*| SWP_SHOWWINDOW*/);
1830 if(m_nActivePage
!= -1)
1831 ::SetWindowPos(GetPageHWND(m_nActivePage
), NULL
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- m_cyTabHeight
, SWP_NOZORDER
);
1836 class CBottomTabView
: public CBottomTabViewImpl
<CBottomTabView
>
1839 DECLARE_WND_CLASS_EX(_T("WTL_BottomTabView"), 0, COLOR_APPWORKSPACE
)
1842 #endif // defined(__ATLCTRLX_H__) && defined(WIN32_PLATFORM_PSPC)
1845 // --- PPC/SmartPhone controls ---
1847 ////////////////////////////////////////////////////////////////////////////////
1848 // These are wrapper classes for the Pocket PC 2002/2003 and SmartPhone 2003 controls
1849 // To implement a window based on a control, use following:
1850 // Example: Implementing a window based on a Html control
1852 // class CMyHtml : CWindowImpl<CMyHtml, CHtmlCtrl>
1855 // BEGIN_MSG_MAP(CMyHtml)
1856 // // put your message handler entries here
1859 ///////////////////////////////////////////////////////////////////////////////
1861 ///////////////////////////////////////////////////////////////////////////////
1864 template <class TBase
>
1865 class CHtmlCtrlT
: public TBase
1869 CHtmlCtrlT(HWND hWnd
= NULL
) : TBase(hWnd
)
1872 CHtmlCtrlT
< TBase
>& operator =(HWND hWnd
)
1878 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szWindowName
= NULL
,
1879 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
1880 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
1882 HWND hWnd
= TBase::Create(GetWndClassName(), hWndParent
, rect
.m_lpRect
, szWindowName
, dwStyle
, dwExStyle
, MenuOrID
.m_hMenu
, lpCreateParam
);
1883 ATLASSERT(hWnd
!= NULL
); // Did you remember to call InitHTMLControl(hInstance) ??
1888 static LPCTSTR
GetWndClassName()
1893 #if (_WIN32_WCE >= 400)
1894 void AddStyle(LPCWSTR pszStyle
)
1896 ATLASSERT(::IsWindow(m_hWnd
));
1897 ::SendMessage(m_hWnd
, DTM_ADDSTYLE
, 0, (LPARAM
)pszStyle
);
1899 #endif // (_WIN32_WCE >= 400)
1901 void AddText(BOOL bPlainText
, LPCSTR pszText
)
1903 ATLASSERT(::IsWindow(m_hWnd
));
1904 ::SendMessage(m_hWnd
, DTM_ADDTEXT
, (WPARAM
)bPlainText
, (LPARAM
)pszText
);
1907 void AddHTML(LPCSTR pszHTML
)
1909 ATLASSERT(::IsWindow(m_hWnd
));
1910 ::SendMessage(m_hWnd
, DTM_ADDTEXT
, (WPARAM
)FALSE
, (LPARAM
)pszHTML
);
1913 void AddText(BOOL bPlainText
, LPCWSTR pszText
)
1915 ATLASSERT(::IsWindow(m_hWnd
));
1916 ::SendMessage(m_hWnd
, DTM_ADDTEXTW
, (WPARAM
)bPlainText
, (LPARAM
)pszText
);
1919 void AddHTML(LPCWSTR pszHTML
)
1921 ATLASSERT(::IsWindow(m_hWnd
));
1922 ::SendMessage(m_hWnd
, DTM_ADDTEXTW
, (WPARAM
)FALSE
, (LPARAM
)pszHTML
);
1925 void Anchor(LPCSTR pszAnchor
)
1927 ATLASSERT(::IsWindow(m_hWnd
));
1928 ::SendMessage(m_hWnd
, DTM_ANCHOR
, 0, (LPARAM
)pszAnchor
);
1931 void Anchor(LPCWSTR pszAnchor
)
1933 ATLASSERT(::IsWindow(m_hWnd
));
1934 ::SendMessage(m_hWnd
, DTM_ANCHORW
, 0, (LPARAM
)pszAnchor
);
1937 #if (_WIN32_WCE >= 420)
1938 void GetBrowserDispatch(IDispatch
** ppDispatch
)
1940 ATLASSERT(::IsWindow(m_hWnd
));
1941 ATLASSERT(ppDispatch
);
1942 ATLASSERT(*ppDispatch
==NULL
);
1943 ::SendMessage(m_hWnd
, DTM_BROWSERDISPATCH
, 0, (LPARAM
)ppDispatch
);
1945 void GetDocumentDispatch(IDispatch
** ppDispatch
)
1947 ATLASSERT(::IsWindow(m_hWnd
));
1948 ATLASSERT(ppDispatch
);
1949 ATLASSERT(*ppDispatch
==NULL
);
1950 ::SendMessage(m_hWnd
, DTM_DOCUMENTDISPATCH
, 0, (LPARAM
)ppDispatch
);
1952 #endif // (_WIN32_WCE >= 420)
1956 ATLASSERT(::IsWindow(m_hWnd
));
1957 ::SendMessage(m_hWnd
, DTM_CLEAR
, 0, 0L);
1960 void EnableClearType(BOOL bEnable
= TRUE
)
1962 ATLASSERT(::IsWindow(m_hWnd
));
1963 ::SendMessage(m_hWnd
, DTM_ENABLECLEARTYPE
, 0, (LPARAM
)bEnable
);
1966 void EnableContextMenu(BOOL bEnable
= TRUE
)
1968 ATLASSERT(::IsWindow(m_hWnd
));
1969 ::SendMessage(m_hWnd
, DTM_ENABLECONTEXTMENU
, 0, (LPARAM
)bEnable
);
1972 void EnableScripting(BOOL bEnable
= TRUE
)
1974 ATLASSERT(::IsWindow(m_hWnd
));
1975 ::SendMessage(m_hWnd
, DTM_ENABLESCRIPTING
, 0, (LPARAM
)bEnable
);
1978 void EnableShrink(BOOL bEnable
= TRUE
)
1980 ATLASSERT(::IsWindow(m_hWnd
));
1981 ::SendMessage(m_hWnd
, DTM_ENABLESHRINK
, 0, (LPARAM
)bEnable
);
1986 ATLASSERT(::IsWindow(m_hWnd
));
1987 ::SendMessage(m_hWnd
, DTM_ENDOFSOURCE
, 0, 0L);
1990 void ImageFail(DWORD dwCookie
)
1992 ATLASSERT(::IsWindow(m_hWnd
));
1993 ::SendMessage(m_hWnd
, DTM_IMAGEFAIL
, 0, (LPARAM
)dwCookie
);
1996 int GetLayoutHeight() const
1998 ATLASSERT(::IsWindow(m_hWnd
));
1999 return (int)::SendMessage(m_hWnd
, DTM_LAYOUTHEIGHT
, 0, 0L);
2002 int GetLayoutWidth() const
2004 ATLASSERT(::IsWindow(m_hWnd
));
2005 return (int)::SendMessage(m_hWnd
, DTM_LAYOUTWIDTH
, 0, 0L);
2008 void Navigate(LPCTSTR pstrURL
, UINT uFlags
= 0)
2010 ATLASSERT(::IsWindow(m_hWnd
));
2012 ::SendMessage(m_hWnd
, DTM_NAVIGATE
, (WPARAM
)uFlags
, (LPARAM
)pstrURL
);
2017 ATLASSERT(::IsWindow(m_hWnd
));
2018 ::SendMessage(m_hWnd
, DTM_SELECTALL
, 0, 0L);
2021 void SetImage(INLINEIMAGEINFO
* pImageInfo
)
2023 ATLASSERT(::IsWindow(m_hWnd
));
2024 ATLASSERT(pImageInfo
);
2025 ::SendMessage(m_hWnd
, DTM_SETIMAGE
, 0, (LPARAM
)pImageInfo
);
2028 void ZoomLevel(int iLevel
)
2030 ATLASSERT(::IsWindow(m_hWnd
));
2031 ::SendMessage(m_hWnd
, DTM_ZOOMLEVEL
, 0, (LPARAM
)iLevel
);
2034 #if (_WIN32_WCE >= 400)
2037 ATLASSERT(::IsWindow(m_hWnd
));
2038 ::SendMessage(m_hWnd
, DTM_STOP
, 0, 0L);
2040 #endif // (_WIN32_WCE >= 400)
2042 void GetScriptDispatch(IDispatch
** ppDispatch
)
2044 ATLASSERT(::IsWindow(m_hWnd
));
2045 ATLASSERT(ppDispatch
);
2046 ATLASSERT(*ppDispatch
==NULL
);
2047 ::SendMessage(m_hWnd
, DTM_SCRIPTDISPATCH
, 0, (LPARAM
)ppDispatch
);
2051 typedef CHtmlCtrlT
<ATL::CWindow
> CHtmlCtrl
;
2054 #ifdef WIN32_PLATFORM_PSPC
2056 ///////////////////////////////////////////////////////////////////////////////
2059 template <class TBase
>
2060 class CRichInkCtrlT
: public TBase
2064 CRichInkCtrlT(HWND hWnd
= NULL
) : TBase(hWnd
)
2067 CRichInkCtrlT
< TBase
>& operator =(HWND hWnd
)
2073 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szWindowName
= NULL
,
2074 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
2075 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
2077 HWND hWnd
= TBase::Create(GetWndClassName(), hWndParent
, rect
.m_lpRect
, szWindowName
, dwStyle
, dwExStyle
, MenuOrID
.m_hMenu
, lpCreateParam
);
2078 ATLASSERT(hWnd
!= NULL
); // Did you remember to call InitRichInkDLL() ??
2083 static LPCTSTR
GetWndClassName()
2088 BOOL
CanPaste(UINT uFormat
= 0) const
2090 ATLASSERT(::IsWindow(m_hWnd
));
2091 return (BOOL
)::SendMessage(m_hWnd
, EM_CANPASTE
, (WPARAM
)uFormat
, 0L);
2094 BOOL
CanRedo() const
2096 ATLASSERT(::IsWindow(m_hWnd
));
2097 return (BOOL
)::SendMessage(m_hWnd
, EM_CANREDO
, 0, 0L);
2100 BOOL
CanUndo() const
2102 ATLASSERT(::IsWindow(m_hWnd
));
2103 return (BOOL
)::SendMessage(m_hWnd
, EM_CANUNDO
, 0, 0L);
2106 void ClearAll(BOOL bRepaint
= TRUE
) const
2108 ATLASSERT(::IsWindow(m_hWnd
));
2109 ::SendMessage(m_hWnd
, EM_CLEARALL
, (WPARAM
)bRepaint
, 0L);
2112 BOOL
GetModify() const
2114 ATLASSERT(::IsWindow(m_hWnd
));
2115 return (BOOL
)::SendMessage(m_hWnd
, EM_GETMODIFY
, 0, 0L);
2118 UINT
GetPageStyle() const
2120 ATLASSERT(::IsWindow(m_hWnd
));
2121 return (UINT
)::SendMessage(m_hWnd
, EM_GETPAGESTYLE
, 0, 0L);
2124 UINT
GetPenMode() const
2126 ATLASSERT(::IsWindow(m_hWnd
));
2127 return (UINT
)::SendMessage(m_hWnd
, EM_GETPENMODE
, 0, 0L);
2130 UINT
GetViewStyle() const
2132 ATLASSERT(::IsWindow(m_hWnd
));
2133 return (UINT
)::SendMessage(m_hWnd
, EM_GETVIEW
, 0, 0L);
2136 UINT
GetWrapMode() const
2138 ATLASSERT(::IsWindow(m_hWnd
));
2139 return (UINT
)::SendMessage(m_hWnd
, EM_GETWRAPMODE
, 0, 0L);
2142 UINT
GetZoomPercent() const
2144 ATLASSERT(::IsWindow(m_hWnd
));
2145 return (UINT
)::SendMessage(m_hWnd
, EM_GETZOOMPERCENT
, 0, 0L);
2148 void InsertLinks(LPWSTR lpString
, int cchLength
= -1)
2150 ATLASSERT(::IsWindow(m_hWnd
));
2152 cchLength
= lstrlen(lpString
);
2153 ::SendMessage(m_hWnd
, EM_INSERTLINKS
, (WPARAM
)cchLength
, (LPARAM
)lpString
);
2158 ATLASSERT(::IsWindow(m_hWnd
));
2159 ::SendMessage(m_hWnd
, EM_REDOEVENT
, 0, 0L);
2162 UINT
SetInkLayer(UINT uLayer
)
2164 ATLASSERT(::IsWindow(m_hWnd
));
2165 return (UINT
)::SendMessage(m_hWnd
, EM_SETINKLAYER
, (WPARAM
)uLayer
, 0L);
2168 void SetPageStyle(UINT uStyle
)
2170 ATLASSERT(::IsWindow(m_hWnd
));
2171 ::SendMessage(m_hWnd
, EM_SETPAGESTYLE
, (WPARAM
)uStyle
, 0L);
2174 void SetPenMode(UINT uMode
)
2176 ATLASSERT(::IsWindow(m_hWnd
));
2177 ::SendMessage(m_hWnd
, EM_SETPENMODE
, (WPARAM
)uMode
, 0L);
2180 void SetViewStyle(UINT uStyle
)
2182 ATLASSERT(::IsWindow(m_hWnd
));
2183 ::SendMessage(m_hWnd
, EM_SETVIEW
, (WPARAM
)uStyle
, 0L);
2186 void SetViewAttributes(VIEWATTRIBUTES
* pAttribs
)
2188 ATLASSERT(::IsWindow(m_hWnd
));
2189 ATLASSERT(pAttribs
);
2190 ::SendMessage(m_hWnd
, EM_SETVIEWATTRIBUTES
, 0, (LPARAM
)pAttribs
);
2193 void SetWrapMode(UINT uMode
)
2195 ATLASSERT(::IsWindow(m_hWnd
));
2196 ::SendMessage(m_hWnd
, EM_SETWRAPMODE
, (WPARAM
)uMode
, 0L);
2199 void SetZoomPercent(UINT uPercent
)
2201 ATLASSERT(::IsWindow(m_hWnd
));
2202 ::SendMessage(m_hWnd
, EM_SETZOOMPERCENT
, (WPARAM
)uPercent
, 0L);
2205 LONG
StreamIn(UINT uFormat
, EDITSTREAM
& es
)
2207 ATLASSERT(::IsWindow(m_hWnd
));
2208 return (LONG
)::SendMessage(m_hWnd
, EM_STREAMIN
, (WPARAM
)uFormat
, (LPARAM
)&es
);
2211 LONG
StreamOut(UINT uFormat
, EDITSTREAM
& es
)
2213 ATLASSERT(::IsWindow(m_hWnd
));
2214 return (LONG
)::SendMessage(m_hWnd
, EM_STREAMOUT
, (WPARAM
)uFormat
, (LPARAM
)&es
);
2219 ATLASSERT(::IsWindow(m_hWnd
));
2220 ::SendMessage(m_hWnd
, EM_UNDOEVENT
, 0, 0L);
2223 // Standard EM_xxx messages
2224 DWORD
GetSel() const
2226 ATLASSERT(::IsWindow(m_hWnd
));
2227 return (DWORD
)::SendMessage(m_hWnd
, EM_GETSEL
, 0, 0L);
2230 void GetSel(int& nStartChar
, int& nEndChar
) const
2232 ATLASSERT(::IsWindow(m_hWnd
));
2233 ::SendMessage(m_hWnd
, EM_GETSEL
, (WPARAM
)&nStartChar
, (LPARAM
)&nEndChar
);
2236 void ReplaceSel(LPCTSTR lpszNewText
, BOOL bCanUndo
= FALSE
)
2238 ATLASSERT(::IsWindow(m_hWnd
));
2239 ::SendMessage(m_hWnd
, EM_REPLACESEL
, (WPARAM
)bCanUndo
, (LPARAM
)lpszNewText
);
2242 void SetModify(BOOL bModified
= TRUE
)
2244 ATLASSERT(::IsWindow(m_hWnd
));
2245 ::SendMessage(m_hWnd
, EM_SETMODIFY
, (WPARAM
)bModified
, 0L);
2248 int GetTextLength() const
2250 ATLASSERT(::IsWindow(m_hWnd
));
2251 return (int)::SendMessage(m_hWnd
, WM_GETTEXTLENGTH
, 0, 0L);
2254 // Clipboard operations
2257 ATLASSERT(::IsWindow(m_hWnd
));
2258 ::SendMessage(m_hWnd
, WM_CLEAR
, 0, 0L);
2263 ATLASSERT(::IsWindow(m_hWnd
));
2264 ::SendMessage(m_hWnd
, WM_COPY
, 0, 0L);
2269 ATLASSERT(::IsWindow(m_hWnd
));
2270 ::SendMessage(m_hWnd
, WM_CUT
, 0, 0L);
2275 ATLASSERT(::IsWindow(m_hWnd
));
2276 ::SendMessage(m_hWnd
, WM_PASTE
, 0, 0L);
2280 typedef CRichInkCtrlT
<ATL::CWindow
> CRichInkCtrl
;
2283 ///////////////////////////////////////////////////////////////////////////////
2286 template <class TBase
>
2287 class CInkXCtrlT
: public TBase
2291 CInkXCtrlT(HWND hWnd
= NULL
) : TBase(hWnd
)
2294 CInkXCtrlT
< TBase
>& operator =(HWND hWnd
)
2300 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szWindowName
= NULL
,
2301 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
2302 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
2304 HWND hWnd
= TBase::Create(GetWndClassName(), hWndParent
, rect
.m_lpRect
, szWindowName
, dwStyle
, dwExStyle
, MenuOrID
.m_hMenu
, lpCreateParam
);
2305 ATLASSERT(hWnd
!= NULL
); // Did you remember to call InitInkX() ??
2310 static LPCTSTR
GetWndClassName()
2315 static UINT
GetHotRecordingMessage()
2317 return ::RegisterWindowMessage(szHotRecording
);
2322 ATLASSERT(::IsWindow(m_hWnd
));
2323 ::SendMessage(m_hWnd
, IM_CLEARALL
, 0, 0L);
2326 int GetData(BYTE
* lpBuffer
, INT cbBuffer
) const
2328 ATLASSERT(::IsWindow(m_hWnd
));
2329 ATLASSERT(lpBuffer
);
2330 return (int)::SendMessage(m_hWnd
, IM_GETDATA
, (WPARAM
)cbBuffer
, (LPARAM
)lpBuffer
);
2333 int GetDataLen() const
2335 ATLASSERT(::IsWindow(m_hWnd
));
2336 return (int)::SendMessage(m_hWnd
, IM_GETDATALEN
, 0, 0L);
2339 CRichInkCtrl
GetRichInk() const
2341 ATLASSERT(::IsWindow(m_hWnd
));
2342 return (HWND
)::SendMessage(m_hWnd
, IM_GETRICHINK
, 0, 0L);
2345 BOOL
IsRecording() const
2347 ATLASSERT(::IsWindow(m_hWnd
));
2348 return (BOOL
)::SendMessage(m_hWnd
, IM_RECORDING
, 0, 0L);
2353 ATLASSERT(::IsWindow(m_hWnd
));
2354 ::SendMessage(m_hWnd
, IM_REINIT
, 0, 0L);
2357 void SetData(const BYTE
* lpInkData
, INT cbInkData
)
2359 ATLASSERT(::IsWindow(m_hWnd
));
2360 ATLASSERT(lpInkData
);
2361 ::SendMessage(m_hWnd
, IM_SETDATA
, (WPARAM
)cbInkData
, (LPARAM
)lpInkData
);
2366 ATLASSERT(::IsWindow(m_hWnd
));
2367 ::SendMessage(m_hWnd
, IM_VOICE_PLAY
, 0, 0L);
2370 BOOL
IsVoicePlaying() const
2372 ATLASSERT(::IsWindow(m_hWnd
));
2373 return (BOOL
)::SendMessage(m_hWnd
, IM_VOICE_PLAYING
, 0, 0L);
2378 ATLASSERT(::IsWindow(m_hWnd
));
2379 return (BOOL
)::SendMessage(m_hWnd
, IM_VOICE_RECORD
, 0, 0L);
2384 ATLASSERT(::IsWindow(m_hWnd
));
2385 ::SendMessage(m_hWnd
, IM_VOICE_STOP
, 0, 0L);
2388 void ShowVoiceBar(BOOL bShow
= TRUE
)
2390 ATLASSERT(::IsWindow(m_hWnd
));
2391 ::SendMessage(m_hWnd
, IM_VOICEBAR
, (WPARAM
)bShow
, 0L);
2395 typedef CInkXCtrlT
<ATL::CWindow
> CInkXCtrl
;
2397 #endif // WIN32_PLATFORM_PSPC
2400 ///////////////////////////////////////////////////////////////////////////////
2401 // CVoiceRecorderCtrl
2403 template <class TBase
>
2404 class CVoiceRecorderCtrlT
: public TBase
2408 CVoiceRecorderCtrlT(HWND hWnd
= NULL
) : TBase(hWnd
)
2411 CVoiceRecorderCtrlT
< TBase
>& operator =(HWND hWnd
)
2417 HWND
Create(HWND hWndParent
, const POINT pt
, LPTSTR pstrFileName
, UINT nID
, DWORD dwStyle
= 0)
2419 ATLASSERT(pstrFileName
!= NULL
);
2420 CM_VOICE_RECORDER cmvr
= { 0 };
2421 cmvr
.cb
= sizeof(CM_VOICE_RECORDER
);
2422 cmvr
.dwStyle
= dwStyle
;
2425 cmvr
.hwndParent
= hWndParent
;
2427 cmvr
.lpszRecordFileName
= pstrFileName
;
2428 m_hWnd
= VoiceRecorder_Create(&cmvr
);
2432 HWND
Create(LPCM_VOICE_RECORDER pAttribs
)
2434 ATLASSERT(pAttribs
);
2435 m_hWnd
= VoiceRecorder_Create(pAttribs
);
2442 ATLASSERT(::IsWindow(m_hWnd
));
2443 ::SendMessage(m_hWnd
, VRM_RECORD
, 0, 0L);
2448 ATLASSERT(::IsWindow(m_hWnd
));
2449 ::SendMessage(m_hWnd
, VRM_PLAY
, 0, 0L);
2454 ATLASSERT(::IsWindow(m_hWnd
));
2455 ::SendMessage(m_hWnd
, VRM_STOP
, 0, 0L);
2460 ATLASSERT(::IsWindow(m_hWnd
));
2461 ::SendMessage(m_hWnd
, VRM_CANCEL
, 0, 0L);
2466 ATLASSERT(::IsWindow(m_hWnd
));
2467 ::SendMessage(m_hWnd
, VRM_OK
, 0, 0L);
2471 typedef CVoiceRecorderCtrlT
<ATL::CWindow
> CVoiceRecorderCtrl
;
2474 #ifdef WIN32_PLATFORM_PSPC
2476 ///////////////////////////////////////////////////////////////////////////////
2479 template <class TBase
>
2480 class CDocListCtrlT
: public TBase
2484 DOCLISTCREATE m_dlc
;
2485 TCHAR m_szPath
[MAX_PATH
];
2488 CDocListCtrlT(HWND hWnd
= NULL
) : TBase(hWnd
)
2491 CDocListCtrlT
< TBase
>& operator =(HWND hWnd
)
2497 HWND
Create(HWND hWndParent
, WORD wId
, LPCTSTR pszFolder
= NULL
, LPCTSTR pstrFilter
= NULL
,
2498 WORD wFilterIndex
= 0, DWORD dwFlags
= DLF_SHOWEXTENSION
)
2500 ATLASSERT(pstrFilter
!= NULL
); // It seems to need a filter badly!!
2501 ::ZeroMemory(&m_dlc
, sizeof(DOCLISTCREATE
));
2502 ::ZeroMemory(m_szPath
, sizeof(m_szPath
));
2503 if(pszFolder
!= NULL
)
2504 ::lstrcpyn(m_szPath
, pszFolder
, MAX_PATH
- 1);
2505 m_dlc
.dwStructSize
= sizeof(DOCLISTCREATE
);
2506 m_dlc
.hwndParent
= hWndParent
;
2507 m_dlc
.pszFolder
= m_szPath
;
2508 m_dlc
.pstrFilter
= pstrFilter
;
2509 m_dlc
.wFilterIndex
= wFilterIndex
;
2511 m_dlc
.dwFlags
= dwFlags
;
2512 m_hWnd
= DocList_Create(&m_dlc
);
2516 HWND
Create(DOCLISTCREATE
* pDlc
)
2519 m_hWnd
= DocList_Create(&m_dlc
);
2526 ATLASSERT(::IsWindow(m_hWnd
));
2527 ::SendMessage(m_hWnd
, DLM_DELETESEL
, 0, 0L);
2530 void DisableUpdates()
2532 ATLASSERT(::IsWindow(m_hWnd
));
2533 ::SendMessage(m_hWnd
, DLM_DISABLEUPDATES
, 0, 0L);
2536 void EnableUpdates()
2538 ATLASSERT(::IsWindow(m_hWnd
));
2539 ::SendMessage(m_hWnd
, DLM_ENABLEUPDATES
, 0, 0L);
2542 int GetFilterIndex() const
2544 ATLASSERT(::IsWindow(m_hWnd
));
2545 return (int)::SendMessage(m_hWnd
, DLM_GETFILTERINDEX
, 0, 0L);
2548 int GetItemCount() const
2550 ATLASSERT(::IsWindow(m_hWnd
));
2551 return (int)::SendMessage(m_hWnd
, DLM_GETITEMCOUNT
, 0, 0L);
2554 int GetNextItem(int iIndex
, DWORD dwRelation
= LVNI_ALL
) const
2556 ATLASSERT(::IsWindow(m_hWnd
));
2557 return (int)::SendMessage(m_hWnd
, DLM_GETNEXTITEM
, (WPARAM
)iIndex
, (LPARAM
)dwRelation
);
2560 int GetFirstItem(DWORD dwRelation
= LVNI_ALL
) const
2562 ATLASSERT(::IsWindow(m_hWnd
));
2563 return (int)::SendMessage(m_hWnd
, DLM_GETNEXTITEM
, (WPARAM
)-1, (LPARAM
)dwRelation
);
2566 BOOL
GetNextWave(int* pIndex
) const
2568 ATLASSERT(::IsWindow(m_hWnd
));
2570 return (BOOL
)::SendMessage(m_hWnd
, DLM_GETNEXTWAVE
, 0, (LPARAM
)pIndex
);
2573 BOOL
GetPrevWave(int* pIndex
) const
2575 ATLASSERT(::IsWindow(m_hWnd
));
2577 return (BOOL
)::SendMessage(m_hWnd
, DLM_GETPREVWAVE
, 0, (LPARAM
)pIndex
);
2580 int GetSelCount() const
2582 ATLASSERT(::IsWindow(m_hWnd
));
2583 return (int)::SendMessage(m_hWnd
, DLM_GETSELCOUNT
, 0, 0L);
2586 BOOL
GetSelPathName(LPTSTR pstrPath
, int cchMax
) const
2588 ATLASSERT(::IsWindow(m_hWnd
));
2589 ATLASSERT(pstrPath
);
2590 return (BOOL
)::SendMessage(m_hWnd
, DLM_GETSELPATHNAME
, (WPARAM
)cchMax
, (LPARAM
)pstrPath
);
2593 void ReceiveIR(LPCTSTR pstrPath
) const
2595 ATLASSERT(::IsWindow(m_hWnd
));
2596 ATLASSERT(pstrPath
);
2597 ::SendMessage(m_hWnd
, DLM_RECEIVEIR
, 0, (LPARAM
)pstrPath
);
2602 ATLASSERT(::IsWindow(m_hWnd
));
2603 ::SendMessage(m_hWnd
, DLM_REFRESH
, 0, 0L);
2606 BOOL
RenameMoveSelectedItems()
2608 ATLASSERT(::IsWindow(m_hWnd
));
2609 return (BOOL
)::SendMessage(m_hWnd
, DLM_RENAMEMOVE
, 0, 0L);
2614 ATLASSERT(::IsWindow(m_hWnd
));
2615 return (int)::SendMessage(m_hWnd
, DLM_SELECTALL
, 0, 0L);
2618 HRESULT
SelectItem(LPCTSTR pstrPath
, BOOL bVisible
= TRUE
)
2620 ATLASSERT(::IsWindow(m_hWnd
));
2621 ATLASSERT(pstrPath
);
2622 return (HRESULT
)::SendMessage(m_hWnd
, DLM_SELECTITEM
, (WPARAM
)bVisible
, (LPARAM
)pstrPath
);
2625 void SendEMail(LPCTSTR pstrAttachment
)
2627 ATLASSERT(::IsWindow(m_hWnd
));
2628 ::SendMessage(m_hWnd
, DLM_SENDEMAIL
, 0, (LPARAM
)pstrAttachment
);
2631 void SendIR(LPCTSTR pstrPath
)
2633 ATLASSERT(::IsWindow(m_hWnd
));
2634 ::SendMessage(m_hWnd
, DLM_SENDIR
, 0, (LPARAM
)pstrPath
);
2637 HRESULT
SetFilterIndex(int iIndex
)
2639 ATLASSERT(::IsWindow(m_hWnd
));
2640 return (HRESULT
)::SendMessage(m_hWnd
, DLM_SETFILTERINDEX
, (WPARAM
)iIndex
, 0L);
2643 void SetFolder(LPCTSTR pstrPath
)
2645 ATLASSERT(::IsWindow(m_hWnd
));
2646 ATLASSERT(pstrPath
);
2647 ::SendMessage(m_hWnd
, DLM_SETFOLDER
, 0, (LPARAM
)pstrPath
);
2650 BOOL
SetItemState(int iIndex
, const LVITEM
* pItem
)
2652 ATLASSERT(::IsWindow(m_hWnd
));
2654 return (BOOL
)::SendMessage(m_hWnd
, DLM_SETITEMSTATE
, (WPARAM
)iIndex
, (LPARAM
)pItem
);
2657 BOOL
SetItemState(int iIndex
, UINT uState
, UINT uMask
)
2659 ATLASSERT(::IsWindow(m_hWnd
));
2660 LV_ITEM lvi
= { 0 };
2661 lvi
.stateMask
= uMask
;
2663 return (BOOL
)::SendMessage(m_hWnd
, DLM_SETITEMSTATE
, (WPARAM
)iIndex
, (LPARAM
)&lvi
);
2666 void SetOneItem(int iIndex
, LPCVOID pPA
)
2668 ATLASSERT(::IsWindow(m_hWnd
));
2669 ::SendMessage(m_hWnd
, DLM_SETONEITEM
, (WPARAM
)iIndex
, (LPARAM
)pPA
);
2672 void SetSelect(int iIndex
)
2674 ATLASSERT(::IsWindow(m_hWnd
));
2675 ::SendMessage(m_hWnd
, DLM_SETSELECT
, (WPARAM
)iIndex
, 0L);
2678 void SetSelPathName(LPCTSTR pstrPath
)
2680 ATLASSERT(::IsWindow(m_hWnd
));
2681 ATLASSERT(pstrPath
);
2682 ::SendMessage(m_hWnd
, DLM_SETSELPATHNAME
, 0, (LPARAM
)pstrPath
);
2687 ATLASSERT(::IsWindow(m_hWnd
));
2688 return (BOOL
)::SendMessage(m_hWnd
, DLM_SETSORTORDER
, 0, 0L);
2693 ATLASSERT(::IsWindow(m_hWnd
));
2694 return (HRESULT
)::SendMessage(m_hWnd
, DLM_UPDATE
, 0, 0L);
2697 BOOL
ValidateFolder()
2699 ATLASSERT(::IsWindow(m_hWnd
));
2700 return (BOOL
)::SendMessage(m_hWnd
, DLM_VALIDATEFOLDER
, 0, 0L);
2704 BOOL
GetFirstSelectedWaveFile(int* pIndex
, LPTSTR szPath
, const size_t cchPath
)
2706 ATLASSERT(::IsWindow(m_hWnd
));
2707 return DocList_GetFirstSelectedWaveFile(m_hWnd
, pIndex
, szPath
, cchPath
);
2710 BOOL
GetNextSelectedWaveFile(int* pIndex
, LPTSTR szPath
, const size_t cchPath
)
2712 ATLASSERT(::IsWindow(m_hWnd
));
2713 return DocList_GetNextSelectedWaveFile(m_hWnd
, pIndex
, szPath
, cchPath
);
2717 typedef CDocListCtrlT
<ATL::CWindow
> CDocListCtrl
;
2719 #endif // WIN32_PLATFORM_PSPC
2722 ///////////////////////////////////////////////////////////////////////////////
2725 template <class TBase
>
2726 class CCapEditT
: public TBase
2730 CCapEditT(HWND hWnd
= NULL
) : TBase(hWnd
)
2733 CCapEditT
< TBase
>& operator =(HWND hWnd
)
2739 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szWindowName
= NULL
,
2740 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
2741 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
2743 HWND hWnd
= /*TBase*/CWindow::Create(GetWndClassName(), hWndParent
, rect
.m_lpRect
, szWindowName
, dwStyle
, dwExStyle
, MenuOrID
.m_hMenu
, lpCreateParam
);
2744 ATLASSERT(hWnd
!= NULL
); // Did you remember to call SHInitExtraControls() ??
2749 static LPCTSTR
GetWndClassName()
2755 typedef CCapEditT
<WTL::CEdit
> CCapEdit
;
2757 ///////////////////////////////////////////////////////////////////////////////
2760 #ifndef WIN32_PLATFORM_WFSP // Tooltips not supported on SmartPhone
2762 template <class TBase
>
2763 class CTTStaticT
: public TBase
2767 CTTStaticT(HWND hWnd
= NULL
) : TBase(hWnd
)
2770 CTTStaticT
< TBase
>& operator =(HWND hWnd
)
2776 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szWindowName
= NULL
,
2777 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
2778 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
2780 HWND hWnd
= TBase::Create(hWndParent
, rect
.m_lpRect
, szWindowName
, dwStyle
, dwExStyle
, MenuOrID
.m_hMenu
, lpCreateParam
);
2781 ATLASSERT(hWnd
!= NULL
); // Did you remember to call SHInitExtraControls() ??
2786 static LPCTSTR
GetWndClassName()
2792 BOOL
SetToolTipText(LPCTSTR pstrTipText
)
2794 ATLASSERT(::IsWindow(m_hWnd
));
2795 ATLASSERT(pstrTipText
);
2796 ATLASSERT(lstrlen(pstrTipText
)<= 253);
2797 CTempBuffer
<TCHAR
, _WTL_STACK_ALLOC_THRESHOLD
> buff
;
2798 LPTSTR pstr
= buff
.Allocate(lstrlen(pstrTipText
) + 3);
2801 ::lstrcpy(pstr
, _T("~~"));
2802 ::lstrcat(pstr
, pstrTipText
);
2803 return SetWindowText(pstr
);
2807 typedef CTTStaticT
<WTL::CStatic
> CTTStatic
;
2810 ///////////////////////////////////////////////////////////////////////////////
2813 template <class TBase
>
2814 class CTTButtonT
: public TBase
2818 CTTButtonT(HWND hWnd
= NULL
) : TBase(hWnd
)
2821 CTTButtonT
< TBase
>& operator =(HWND hWnd
)
2827 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szWindowName
= NULL
,
2828 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
2829 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
2831 HWND hWnd
= TBase::Create(hWndParent
, rect
.m_lpRect
, szWindowName
, dwStyle
, dwExStyle
, MenuOrID
.m_hMenu
, lpCreateParam
);
2832 ATLASSERT(hWnd
!= NULL
); // Did you remember to call SHInitExtraControls() ??
2837 static LPCTSTR
GetWndClassName()
2843 BOOL
SetToolTipText(LPCTSTR pstrTipText
)
2845 ATLASSERT(::IsWindow(m_hWnd
));
2846 ATLASSERT(pstrTipText
);
2847 ATLASSERT(lstrlen(pstrTipText
)<= 253);
2848 CTempBuffer
<TCHAR
, _WTL_STACK_ALLOC_THRESHOLD
> buff
;
2849 LPTSTR pstr
= buff
.Allocate(lstrlen(pstrTipText
) + 3);
2852 ::lstrcpy(pstr
, _T("~~"));
2853 ::lstrcat(pstr
, pstrTipText
);
2854 return SetWindowText(pstr
);
2858 typedef CTTButtonT
<WTL::CButton
> CTTButton
;
2860 #endif // !WIN32_PLATFORM_WFSP
2863 // --- SmartPhone specific controls ---
2865 #ifdef WIN32_PLATFORM_WFSP
2867 ///////////////////////////////////////////////////////////////////////////////
2868 // CSpinCtrlT - CSpinCtrl : SmartPhone adapted UpDown control
2870 template <class TBase
>
2871 class CSpinCtrlT
: public CUpDownCtrlT
< TBase
>
2875 CSpinCtrlT(HWND hWnd
= NULL
) : CUpDownCtrlT
< TBase
>(hWnd
)
2878 CSpinCtrlT
< TBase
>& operator =(HWND hWnd
)
2884 HWND
Create(HWND hWndParent
, HWND hBuddy
, DWORD dwStyle
, int nID
, LPCTSTR szExpandedName
= NULL
)
2886 ATLASSERT(::IsWindow(hWndParent
));
2887 CUpDownCtrlT
< TBase
>::Create(hWndParent
, NULL
, szExpandedName
, dwStyle
, 0, nID
, NULL
);
2888 ATLASSERT(m_hWnd
!= NULL
); // Did you remember to call AtlInitCommonControls(ICC_UPDOWN_CLASS)?
2891 ATLASSERT(::IsWindow(hBuddy
));
2898 typedef CSpinCtrlT
<ATL::CWindow
> CSpinCtrl
;
2901 ///////////////////////////////////////////////////////////////////////////////
2902 // CSpinned - SmartPhone association of control and Spin
2904 template <class TBase
, bool t_bExpandOnly
>
2905 class CSpinned
: public TBase
2908 CSpinCtrl m_SpinCtrl
;
2909 DWORD m_dwSpinnedStyle
;
2912 CSpinned(HWND hWnd
= NULL
) : TBase(hWnd
)
2914 m_dwSpinnedStyle
= WS_VISIBLE
| UDS_ALIGNRIGHT
| UDS_EXPANDABLE
;
2916 if (t_bExpandOnly
== true)
2917 m_dwSpinnedStyle
|= UDS_NOSCROLL
;
2919 m_dwSpinnedStyle
|= UDS_HORZ
| UDS_ARROWKEYS
| UDS_SETBUDDYINT
| UDS_WRAP
;
2922 AttachOrCreateSpinCtrl();
2925 CSpinned
<TBase
, t_bExpandOnly
>& operator =(HWND hWnd
)
2931 void Attach(HWND hWnd
)
2933 ATLASSERT(!IsWindow());
2934 TBase
* pT
= static_cast<TBase
*>(this);
2937 AttachOrCreateSpinCtrl();
2940 HWND
Create(HWND hWndParent
, ATL::_U_RECT rect
= NULL
, LPCTSTR szExpandedName
= NULL
,
2941 DWORD dwStyle
= 0, DWORD dwExStyle
= 0,
2942 ATL::_U_MENUorID MenuOrID
= 0U, LPVOID lpCreateParam
= NULL
)
2945 TBase
* pT
= static_cast<TBase
*>(this);
2946 TBase::Create(hWndParent
, rect
, NULL
, dwStyle
, dwExStyle
, MenuOrID
, lpCreateParam
);
2947 ATLASSERT(pT
->m_hWnd
!= NULL
);
2949 m_SpinCtrl
.Create(hWndParent
, pT
->m_hWnd
, m_dwSpinnedStyle
, ATL_IDW_SPIN_ID
+ (int)MenuOrID
.m_hMenu
, szExpandedName
);
2951 ATLASSERT(m_SpinCtrl
.m_hWnd
!= NULL
); // Did you remember to call AtlInitCommonControls(ICC_UPDOWN_CLASS)?
2957 CSpinCtrl
& GetSpinCtrl()
2963 // Attach our existing SpinCtrl or create one
2964 bool AttachOrCreateSpinCtrl()
2966 TBase
* pT
= static_cast<TBase
*>(this);
2968 HWND hSpin
= ::GetDlgItem(pT
->GetParent(), ATL_IDW_SPIN_ID
+ pT
->GetDlgCtrlID());
2972 m_SpinCtrl
.Attach(hSpin
);
2974 TCHAR sClassName
[16];
2975 ::GetClassName(hSpin
, sClassName
, 16);
2976 ATLASSERT(!_tcscmp(sClassName
, UPDOWN_CLASS
));
2977 ATLASSERT(m_SpinCtrl
.GetBuddy().m_hWnd
== pT
->m_hWnd
);
2982 m_SpinCtrl
.Create(pT
->GetParent(), pT
->m_hWnd
, m_dwSpinnedStyle
, ATL_IDW_SPIN_ID
+ pT
->GetDlgCtrlID());
2985 return m_SpinCtrl
.m_hWnd
!= NULL
;
2990 ///////////////////////////////////////////////////////////////////////////////
2991 // CSpinListBox - SmartPhone spinned ListBox control
2992 // CExpandListBox - SmartPhone expandable ListBox control
2993 // CExpandEdit - SmartPhone expandable Edit control
2994 // CExpandCapEdit - SmartPhone expandable CapEdit control
2996 typedef CSpinned
<CListBox
, false> CSpinListBox
;
2997 typedef CSpinned
<CListBox
, true> CExpandListBox
;
2998 typedef CSpinned
<CEdit
, true> CExpandEdit
;
2999 typedef CSpinned
<CCapEdit
, true> CExpandCapEdit
;
3001 #endif // WIN32_PLATFORM_WFSP
3003 #endif // _WTL_CE_NO_CONTROLS
3007 #endif // __ATLWINCE_H__