3 #define ATLASSERT_SUCCESS(X) {auto RetVal = (X); ATLASSERT( RetVal ); } 8 m_wnd.SetRedraw(FALSE);
11 m_wnd.SetRedraw(TRUE);
20 if (
m_wnd.IsWindowVisible()) {
22 m_wnd.SetRedraw(FALSE);
27 m_wnd.SetRedraw(TRUE);
28 m_wnd.RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
37 #define MSG_WM_TIMER_EX(timerId, func) \ 38 if (uMsg == WM_TIMER && (UINT_PTR)wParam == timerId) \ 40 SetMsgHandled(TRUE); \ 47 #define MESSAGE_HANDLER_SIMPLE(msg, func) \ 50 SetMsgHandled(TRUE); \ 58 #define MSG_WM_SYSCOMMAND_HELP(func) \ 59 if (uMsg == WM_SYSCOMMAND && wParam == SC_CONTEXTHELP) \ 61 SetMsgHandled(TRUE); \ 69 #define END_MSG_MAP_HOOK() \ 72 return __super::ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \ 90 CThemeT(HTHEME source = NULL) : m_theme(source) {}
98 return m_theme = ::OpenThemeData(wnd, classList);
103 if (managed && releaseme != NULL) CloseThemeData(releaseme);
106 operator HTHEME()
const {
return m_theme;}
115 void ToggleCheck(
bool state) {SetCheck(state ? BST_CHECKED : BST_UNCHECKED);}
116 bool IsChecked()
const {
return GetCheck() == BST_CHECKED;}
127 MSG_WM_GETDLGCODE(OnEditGetDlgCode)
130 UINT OnEditGetDlgCode(LPMSG lpMsg) {
132 SetMsgHandled(FALSE);
return 0;
134 switch(lpMsg->message) {
137 switch(lpMsg->wParam) {
141 SetMsgHandled(FALSE);
return 0;
144 SetMsgHandled(FALSE);
return 0;
155 MSG_WM_GETDLGCODE(OnEditGetDlgCode)
158 UINT OnEditGetDlgCode(LPMSG lpMsg) {
160 SetMsgHandled(FALSE);
return 0;
162 switch(lpMsg->message) {
165 switch(lpMsg->wParam) {
170 SetMsgHandled(FALSE);
return 0;
173 SetMsgHandled(FALSE);
return 0;
186 void Set(
const TCHAR * n) {ATLASSERT( name == NULL ); name = n; }
189 const TCHAR * n = name; name = NULL;
190 if (n != NULL) ATLASSERT_SUCCESS( UnregisterClass(n, (HINSTANCE)&__ImageBase) );
201 template<
typename TClass,
typename TBaseClass = CWindow>
205 return CS_VREDRAW | CS_HREDRAW;
208 return ::LoadCursor(NULL, IDC_ARROW);
215 static
void Register() {
219 wc.style = TClass::GetClassStyle();
220 wc.cbWndExtra =
sizeof(
void*);
221 wc.lpszClassName = TClass::GetClassName();
222 wc.lpfnWndProc = myWindowProc;
223 wc.hInstance = (HINSTANCE)&__ImageBase;
224 wc.hCursor = TClass::GetCursor();
225 ATLASSERT_SUCCESS( RegisterClass(&wc) != 0 );
226 scope.
Set(wc.lpszClassName);
232 static LRESULT CALLBACK
myWindowProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) {
234 if (msg == WM_NCCREATE) {
237 ::SetWindowLongPtr(wnd, 0, reinterpret_cast<LONG_PTR>(i));
239 i =
reinterpret_cast<TClass*
>( ::GetWindowLongPtr(wnd, 0) );
242 if (i == NULL || !i->ProcessWindowMessage(wnd, msg, wp, lp, r)) r = ::DefWindowProc(wnd, msg, wp, lp);
243 if (msg == WM_NCDESTROY) {
244 ::SetWindowLongPtr(wnd, 0, 0);
257 #if _WIN32_WINNT < 0x600 258 auto dll = GetModuleHandle(_T(
"kernel32"));
259 Bind(AcquireSRWLockExclusive, dll,
"AcquireSRWLockExclusive");
260 Bind(AcquireSRWLockShared, dll,
"AcquireSRWLockShared");
261 Bind(ReleaseSRWLockExclusive, dll,
"ReleaseSRWLockExclusive");
262 Bind(ReleaseSRWLockShared, dll,
"ReleaseSRWLockShared");
267 #if _WIN32_WINNT < 0x600 268 return AcquireSRWLockExclusive != NULL;
275 AcquireSRWLockShared( & theLock );
278 AcquireSRWLockExclusive( & theLock );
281 ReleaseSRWLockShared( & theLock );
284 ReleaseSRWLockExclusive( &theLock );
292 #if _WIN32_WINNT < 0x600 293 template<
typename func_t>
static void Bind(func_t & func, HMODULE dll,
const char * name) {
294 func =
reinterpret_cast<func_t
>(GetProcAddress( dll, name ) );
297 VOID (WINAPI * AcquireSRWLockExclusive)(PSRWLOCK SRWLock);
298 VOID (WINAPI * AcquireSRWLockShared)(PSRWLOCK SRWLock);
299 VOID (WINAPI * ReleaseSRWLockExclusive)(PSRWLOCK SRWLock);
300 VOID (WINAPI * ReleaseSRWLockShared)(PSRWLOCK SRWLock);
304 #if _WIN32_WINNT < 0x600 311 if (!srw.HaveAPI()) DeleteCriticalSection(& cs );
314 if (srw.HaveAPI()) srw.EnterShared();
315 else EnterCriticalSection(&cs);
318 if (srw.HaveAPI()) srw.EnterExclusive();
319 else EnterCriticalSection(&cs);
322 if (srw.HaveAPI()) srw.LeaveShared();
323 else LeaveCriticalSection(&cs);
326 if (srw.HaveAPI()) srw.LeaveExclusive();
327 else LeaveCriticalSection(&cs);
BEGIN_MSG_MAP_EX(CEditNoEscSteal) MSG_WM_GETDLGCODE(OnEditGetDlgCode) END_MSG_MAP() private
CThemeT(HTHEME source=NULL)
CThemeT< false > CThemeHandle
t_type replace_null_t(t_type &p_var)
NoRedrawScopeEx(HWND p_wnd)
~CWindowClassUnregisterScope()
NoRedrawScope(HWND p_wnd)
CCheckBox & operator=(HWND wnd)
static UINT GetClassStyle()
void ToggleCheck(bool state)
CWindowClassUnregisterScope()
static void Bind(func_t &func, HMODULE dll, const char *name)
CCheckBox(HWND hWnd=NULL)
BEGIN_MSG_MAP_EX(CWindowRegisteredT) END_MSG_MAP() static void Register()
void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
BEGIN_MSG_MAP_EX(CEditNoEscSteal) MSG_WM_GETDLGCODE(OnEditGetDlgCode) END_MSG_MAP() private
static LRESULT CALLBACK myWindowProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
virtual ~CWindowRegisteredT()
HTHEME OpenThemeData(HWND wnd, LPCWSTR classList)
static HCURSOR GetCursor()