|
// MyMacros.h
//
// Author : David Shepherd
// Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MYMACROS_H__E8847601_2853_11D6_B6A6_856C06A39D46__INCLUDED_)
#define AFX_MYMACROS_H__E8847601_2853_11D6_B6A6_856C06A39D46__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// safely converts a BSTR to a wide string pointer
#define BSTR2W(s) ( (const wchar_t *) ((s) ? (s) : L"") )
// converts a BOOL to a VARIANT_BOOL
#define B2VB(b) (((b)==FALSE) ? VARIANT_FALSE : VARIANT_TRUE)
// converts a VARIANT_BOOL to a BOOL
#define VB2B(vb) (((vb)==VARIANT_FALSE) ? FALSE : TRUE)
// converts a system color index to an OLE_COLOR value
#define MAKE_OLE_COLOR(ix) (0x80000000 | (ix))
// determines the number of elements in an array
#define NUM_ELEMENTS(array,type) (sizeof(array)/sizeof(type))
// converts a point size to the size in pixels
#define POINT_SIZE_TO_PIXELS(hdc,size) \
((GetDeviceCaps((hdc),LOGPIXELSY)*(size))/72)
// determines the aspect ratio of a device context
#define ASPECT_RATIO(dc) \
((float)(dc).GetDeviceCaps(LOGPIXELSX)/(dc).GetDeviceCaps(LOGPIXELSY))
// prevents a class from being copied
#define NOCOPY(c) \
private: \
c(const c&) \
{} \
operator=(const c&) \
{}
// begin try catch all block
#define TRY \
BOOL Caught=FALSE; \
try \
{
// end try catch all block
#define CATCH_ALL \
} \
catch(std::exception &) \
{ \
ATLTRACE(_T("caught(std::exception &)\n")); \
ATLASSERT(FALSE); \
Caught=TRUE; \
} \
catch(...) \
{ \
ATLTRACE(_T("caught(...)\n")); \
ATLASSERT(FALSE); \
Caught=TRUE; \
}
// begin standard interface function implementation block
#define IMP_BEGIN \
HRESULT RetVal=S_OK; \
try \
{
// end standard interface function implementation block
#define IMP_END \
} \
catch(CHResult &hr) \
{ \
ATLTRACE(_T("caught(CHResult &) 0x%08X\n"), \
(HRESULT)hr); \
RetVal=hr; \
} \
catch(std::exception &) \
{ \
ATLTRACE(_T("caught(std::exception &)\n")); \
ATLASSERT(FALSE); \
RetVal=E_UNEXPECTED; \
} \
catch(...) \
{ \
ATLTRACE(_T("caught(...)\n")); \
ATLASSERT(FALSE); \
RetVal=E_UNEXPECTED; \
}
// standard property request edit implementation
#define REQUEST_EDIT(dispid) \
if(!m_nFreezeEvents) \
{ \
if(FireOnRequestEdit(dispid)==S_FALSE) \
{ \
throw CHResult(S_FALSE); \
} \
}
// standard property change notification implementation
#define PROPERTY_CHANGED(dispid) \
SetDirty(TRUE); \
if(!m_nFreezeEvents) \
{ \
(void)FireOnChanged(dispid); \
} \
(void)FireViewChange(); \
(void)SendOnDataChange(NULL);
#endif // !defined(AFX_MYMACROS_H__E8847601_2853_11D6_B6A6_856C06A39D46__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.