📄 atlapp.h
字号:
// Windows Template Library - WTL version 7.5
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license. You must not remove this notice, or
// any other, from this software.
#ifndef __ATLAPP_H__
#define __ATLAPP_H__
#pragma once
#ifndef __cplusplus
#error ATL requires C++ compilation (use a .cpp suffix)
#endif
#ifndef __ATLBASE_H__
#error atlapp.h requires atlbase.h to be included first
#endif
#ifndef _WIN32_WCE
#if (WINVER < 0x0400)
#error WTL requires Windows version 4.0 or higher
#endif
#if (_WIN32_IE < 0x0300)
#error WTL requires IE version 3.0 or higher
#endif
#endif
#ifdef _ATL_NO_COMMODULE
#error WTL requires that _ATL_NO_COMMODULE is not defined
#endif //_ATL_NO_COMMODULE
#if defined(_WIN32_WCE) && defined(_ATL_MIN_CRT)
#pragma message("Warning: WTL for Windows CE doesn't use _ATL_MIN_CRT")
#endif //defined(_WIN32_WCE) && defined(_ATL_MIN_CRT)
#include <limits.h>
#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE)
#include <process.h> // for _beginthreadex
#endif
#include <commctrl.h>
#ifndef _WIN32_WCE
#pragma comment(lib, "comctl32.lib")
#endif //!_WIN32_WCE
#ifndef _WIN32_WCE
#include <atlres.h>
#else // CE specific
#include <atlresce.h>
#endif //_WIN32_WCE
// We need to disable this warning because of template class arguments
#pragma warning(disable: 4127)
///////////////////////////////////////////////////////////////////////////////
// WTL version number
#define _WTL_VER 0x0750
///////////////////////////////////////////////////////////////////////////////
// Classes in this file:
//
// CMessageFilter
// CIdleHandler
// CMessageLoop
//
// CAppModule
// CServerAppModule
//
// Global functions:
// AtlGetDefaultGuiFont()
// AtlCreateBoldFont()
// AtlInitCommonControls()
///////////////////////////////////////////////////////////////////////////////
// Global support for Windows CE
#ifdef _WIN32_WCE
#ifndef SW_SHOWDEFAULT
#define SW_SHOWDEFAULT SW_SHOWNORMAL
#endif //!SW_SHOWDEFAULT
// These get's OR-ed in a constant and will have no effect.
// Defining them reduces the number of #ifdefs required for CE.
#define LR_DEFAULTSIZE 0
#define LR_LOADFROMFILE 0
inline BOOL IsMenu(HMENU hMenu)
{
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
::SetLastError(0);
BOOL bRet = ::GetMenuItemInfo(hMenu, 0, TRUE, &mii);
if(!bRet)
bRet = (::GetLastError() != ERROR_INVALID_MENU_HANDLE) ? TRUE : FALSE;
return bRet;
}
extern "C" void WINAPI ListView_SetItemSpacing(HWND hwndLV, int iHeight);
inline int MulDiv(IN int nNumber, IN int nNumerator, IN int nDenominator)
{
__int64 multiple = nNumber * nNumerator;
return static_cast<int>(multiple / nDenominator);
}
#if (_ATL_VER >= 0x0800)
#ifndef _WTL_KEEP_WS_OVERLAPPEDWINDOW
#ifdef WS_OVERLAPPEDWINDOW
#undef WS_OVERLAPPEDWINDOW
#define WS_OVERLAPPEDWINDOW 0
#endif //WS_OVERLAPPEDWINDOW
#endif //!_WTL_KEEP_WS_OVERLAPPEDWINDOW
#ifndef RDW_FRAME
#define RDW_FRAME 0
#endif //!RDW_FRAME
#ifndef WM_WINDOWPOSCHANGING
#define WM_WINDOWPOSCHANGING 0
#endif //!WM_WINDOWPOSCHANGING
#define FreeResource(x)
#define UnlockResource(x)
namespace ATL
{
inline HRESULT CComModule::RegisterClassObjects(DWORD /*dwClsContext*/, DWORD /*dwFlags*/) throw()
{ return E_NOTIMPL; }
inline HRESULT CComModule::RevokeClassObjects() throw()
{ return E_NOTIMPL; }
}; // namespace ATL
#ifndef lstrlenW
#define lstrlenW (int)ATL::lstrlenW
#endif //lstrlenW
inline int WINAPI lstrlenA(LPCSTR lpszString)
{ return ATL::lstrlenA(lpszString); }
#ifdef lstrcpyn
#undef lstrcpyn
#define lstrcpyn ATL::lstrcpynW
#endif //lstrcpyn
#ifndef SetWindowLongPtrW
inline LONG_PTR tmp_SetWindowLongPtrW( HWND hWnd, int nIndex, LONG_PTR dwNewLong )
{
return( ::SetWindowLongW( hWnd, nIndex, LONG( dwNewLong ) ) );
}
#define SetWindowLongPtrW tmp_SetWindowLongPtrW
#endif
#ifndef GetWindowLongPtrW
inline LONG_PTR tmp_GetWindowLongPtrW( HWND hWnd, int nIndex )
{
return( ::GetWindowLongW( hWnd, nIndex ) );
}
#define GetWindowLongPtrW tmp_GetWindowLongPtrW
#endif
#ifndef LongToPtr
#define LongToPtr(x) ((void*)x)
#endif
#ifndef PtrToInt
#define PtrToInt( p ) ((INT)(INT_PTR) (p) )
#endif
#else //!(_ATL_VER >= 0x0800)
#ifdef lstrlenW
#undef lstrlenW
#define lstrlenW (int)::wcslen
#endif //lstrlenW
#define lstrlenA (int)strlen
#ifndef lstrcpyn
inline LPTSTR lstrcpyn(LPTSTR lpstrDest, LPCTSTR lpstrSrc, int nLength)
{
if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0)
return NULL;
int nLen = min(lstrlen(lpstrSrc), nLength - 1);
LPTSTR lpstrRet = (LPTSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(TCHAR));
lpstrDest[nLen] = 0;
return lpstrRet;
}
#endif //!lstrcpyn
#ifdef TrackPopupMenu
#undef TrackPopupMenu
#endif // TrackPopupMenu
#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \
static CWndClassInfo& GetWndClassInfo() \
{ \
static CWndClassInfo wc = \
{ \
{ style, StartWindowProc, \
0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \
NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \
}; \
return wc; \
}
#ifndef _MAX_FNAME
#define _MAX_FNAME _MAX_PATH
#endif //_MAX_FNAME
#if (_WIN32_WCE < 400)
#define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
#define WHEEL_PAGESCROLL (UINT_MAX)
#define WHEEL_DELTA 120
#endif //(_WIN32_WCE < 400)
#ifdef DrawIcon
#undef DrawIcon
#endif
#ifndef VARCMP_LT
#define VARCMP_LT 0
#endif
#ifndef VARCMP_EQ
#define VARCMP_EQ 1
#endif
#ifndef VARCMP_GT
#define VARCMP_GT 2
#endif
#ifndef VARCMP_NULL
#define VARCMP_NULL 3
#endif
#ifndef RDW_ALLCHILDREN
#define RDW_ALLCHILDREN 0
#endif
#endif //!(_ATL_VER >= 0x0800)
#endif //_WIN32_WCE
///////////////////////////////////////////////////////////////////////////////
// Global support for using original VC++ 6.0 headers with WTL
#ifndef _ATL_NO_OLD_HEADERS_WIN64
#if !defined(_WIN64) && (_ATL_VER < 0x0700)
#ifndef PSM_INSERTPAGE
#define PSM_INSERTPAGE (WM_USER + 119)
#endif //!PSM_INSERTPAGE
#ifndef GetClassLongPtr
#define GetClassLongPtrA GetClassLongA
#define GetClassLongPtrW GetClassLongW
#ifdef UNICODE
#define GetClassLongPtr GetClassLongPtrW
#else
#define GetClassLongPtr GetClassLongPtrA
#endif // !UNICODE
#endif // !GetClassLongPtr
#ifndef GCLP_HICONSM
#define GCLP_HICONSM (-34)
#endif //!GCLP_HICONSM
#ifndef GetWindowLongPtr
#define GetWindowLongPtrA GetWindowLongA
#define GetWindowLongPtrW GetWindowLongW
#ifdef UNICODE
#define GetWindowLongPtr GetWindowLongPtrW
#else
#define GetWindowLongPtr GetWindowLongPtrA
#endif // !UNICODE
#endif // !GetWindowLongPtr
#ifndef SetWindowLongPtr
#define SetWindowLongPtrA SetWindowLongA
#define SetWindowLongPtrW SetWindowLongW
#ifdef UNICODE
#define SetWindowLongPtr SetWindowLongPtrW
#else
#define SetWindowLongPtr SetWindowLongPtrA
#endif // !UNICODE
#endif // !SetWindowLongPtr
#ifndef GWLP_WNDPROC
#define GWLP_WNDPROC (-4)
#endif
#ifndef GWLP_HINSTANCE
#define GWLP_HINSTANCE (-6)
#endif
#ifndef GWLP_HWNDPARENT
#define GWLP_HWNDPARENT (-8)
#endif
#ifndef GWLP_USERDATA
#define GWLP_USERDATA (-21)
#endif
#ifndef GWLP_ID
#define GWLP_ID (-12)
#endif
#ifndef DWLP_MSGRESULT
#define DWLP_MSGRESULT 0
#endif
typedef long LONG_PTR;
typedef unsigned long ULONG_PTR;
typedef ULONG_PTR DWORD_PTR;
#ifndef HandleToUlong
#define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
#endif
#ifndef HandleToLong
#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
#endif
#ifndef LongToHandle
#define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
#endif
#ifndef PtrToUlong
#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
#endif
#ifndef PtrToLong
#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
#endif
#ifndef PtrToUint
#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
#endif
#ifndef PtrToInt
#define PtrToInt( p ) ((INT)(INT_PTR) (p) )
#endif
#ifndef PtrToUshort
#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
#endif
#ifndef PtrToShort
#define PtrToShort( p ) ((short)(LONG_PTR)(p) )
#endif
#ifndef IntToPtr
#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
#endif
#ifndef UIntToPtr
#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
#endif
#ifndef LongToPtr
#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
#endif
#ifndef ULongToPtr
#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
#endif
#endif //!defined(_WIN64) && (_ATL_VER < 0x0700)
#endif //!_ATL_NO_OLD_HEADERS_WIN64
///////////////////////////////////////////////////////////////////////////////
// Miscellaneous global support
// define useful macros from winuser.h
#ifndef IS_INTRESOURCE
#define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0)
#endif //IS_INTRESOURCE
// protect template members from windowsx.h macros
#ifdef _INC_WINDOWSX
#undef SubclassWindow
#endif //_INC_WINDOWSX
// define useful macros from windowsx.h
#ifndef GET_X_LPARAM
#define GET_X_LPARAM(lParam) ((int)(short)LOWORD(lParam))
#endif
#ifndef GET_Y_LPARAM
#define GET_Y_LPARAM(lParam) ((int)(short)HIWORD(lParam))
#endif
// Dummy structs for compiling with /CLR
#if (_MSC_VER >= 1300) && defined(_MANAGED)
__if_not_exists(_IMAGELIST::_IMAGELIST) { struct _IMAGELIST { }; }
__if_not_exists(_TREEITEM::_TREEITEM) { struct _TREEITEM { }; }
__if_not_exists(_PSP::_PSP) { struct _PSP { }; }
#endif
// Define ATLVERIFY macro for ATL3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -