3dsmaxdlport.h File Reference
 
 
 
3dsmaxdlport.h File Reference

This reference page is linked to from the following overview topics: New Files, SDK Change Details, SetWindowLong() and GetWindowLong().


#include "utilexp.h"
#include "strbasic.h"
#include "BuildWarnings.h"
#include <wtypes.h>
#include <cmath>
#include <cstdlib>

Defines

#define  DL_STDEXT   stdext
#define  DL_NON_RTTI_OBJECT   std::__non_rtti_object
#define  DL_TYPENAME_OUTSIDE_TEMPLATE   typename

Typedefs

typedef INT_PTR(CALLBACK *  DL_NOTQUITE_WNDPROC )(HWND, UINT, WPARAM, LPARAM)

Enumerations

enum   { FNV1_32_INIT = 0x811c9dc5, FNV_32_PRIME = 0x01000193 }

Functions

template<typename DataPtr >
DataPtr  DLGetWindowLongPtr (HWND hWnd, int n=GWLP_USERDATA, DataPtr=NULL)
template<typename DataPtr >
DataPtr  DLGetWindowLongPtrA (HWND hWnd, int n=GWLP_USERDATA)
template<typename DataPtr >
DataPtr  DLGetWindowLongPtrW (HWND hWnd, int n=GWLP_USERDATA)
template<typename DataPtr >
DataPtr  DLGetWindowLongPtr (HWND hWnd, DataPtr *pPtr, int n=GWLP_USERDATA)
template<>
bool  DLGetWindowLongPtr (HWND hWnd, int n, bool)
WNDPROC  DLGetWindowProc (HWND hWnd)
WNDPROC  DLGetWindowProcA (HWND hWnd)
WNDPROC  DLGetWindowProcW (HWND hWnd)
HINSTANCE  DLGetWindowInstance (HWND hWnd)
template<typename Type >
Type  DLSetWindowLongPtr (HWND hWnd, Type ptr, int n=GWLP_USERDATA)
template<>
bool  DLSetWindowLongPtr (HWND hWnd, bool bo, int n)
WNDPROC  DLSetWindowLongPtr (HWND hWnd, WNDPROC pfn)
WNDPROC  DLSetWindowProc (HWND hWnd, WNDPROC pfn)
template<typename DataPtr >
DataPtr  DLGetClassLongPtr (HWND hWnd, int n, DataPtr=NULL)
template<typename DataPtr >
DataPtr  DLGetClassLongPtrA (HWND hWnd, int n)
template<typename DataPtr >
DataPtr  DLGetClassLongPtrW (HWND hWnd, int n)
template<typename DataPtr >
DataPtr  DLGetClassLongPtr (HWND hWnd, DataPtr *pPtr, int n)
template<>
bool  DLGetClassLongPtr (HWND hWnd, int n, bool)
WNDPROC  DLGetClassWindowProc (HWND hWnd)
WNDPROC  DLGetClassWindowProcA (HWND hWnd)
WNDPROC  DLGetClassWindowProcW (HWND hWnd)
template<typename Type >
Type  DLSetClassLongPtr (HWND hWnd, Type ptr, int n)
template<>
bool  DLSetClassLongPtr (HWND hWnd, bool bo, int n)
template<typename Type >
Type  DLSetClassLongPtrA (HWND hWnd, Type ptr, int n)
template<typename Type >
Type  DLSetClassLongPtrW (HWND hWnd, Type ptr, int n)
WNDPROC  DLSetClassWindowProc (HWND hWnd, WNDPROC pfn)
WNDPROC  DLSetClassWindowProcA (HWND hWnd, WNDPROC pfn)
WNDPROC  DLSetClassWindowProcW (HWND hWnd, WNDPROC pfn)
UtilExport LONG  DLRegSetString (HKEY key, const MCHAR *data, const MCHAR *name=NULL)
  Wrapper around the windows function RegSetValueEx.
UtilExport LONG  DLRegSetDWord (HKEY key, DWORD data, const MCHAR *name=NULL)
  Wrapper around the windows function RegSetValueEx for DWORD data.
template<typename BlobType >
LONG  DLRegSetBlob (HKEY key, const BlobType *lpbValue, DWORD n, LPCMSTR lpValueName=NULL)
UtilExport BOOL  DLGetTextExtent (HDC hDC, const MCHAR *text, LPSIZE lpExtent)
UtilExport BOOL  DLGetTextExtent (HDC hDC, const MCHAR *text, size_t len, LPSIZE lpExtent)
UtilExport BOOL  DLTextOut (HDC hDC, int x, int y, const MCHAR *text)
UtilExport BOOL  DLTextOut (HDC hDC, int x, int y, const MCHAR *text, size_t len)
UtilExport LONG  DLTabbedTextOut (HDC hDC, int x, int y, const MCHAR *text, int nTabs, const INT *pTabPositions, int nTabOrigin)
UtilExport int  DLDrawText (HDC hDC, const MCHAR *lpString, LPRECT lpRect, UINT uFormat)
UtilExport int  DLDrawText (HDC hDC, const MCHAR *lpString, size_t len, LPRECT lpRect, UINT uFormat)
WORD  PointerHiPart (ULONG_PTR ptr)
WORD  PointerLoPart (ULONG_PTR ptr)
WORD  PointerHiPart (LONG_PTR ptr)
WORD  PointerLoPart (LONG_PTR ptr)
WORD  PointerHiPart (void *ptr)
WORD  PointerLoPart (void *ptr)
unsigned int  fnv_32_buf (const void *buf, int len, unsigned int hval)
template<typename T >
unsigned int  DLObjectHash (T &t, int HashTableSize=0)
unsigned int  DLPointerHash (const void *pv, int HashTableSize=0)
int  DL_abs (int n)
__int64  DL_abs (__int64 n)
float  DL_abs (float f)
double  DL_abs (double f)
long double  DL_abs (long double f)

Define Documentation

#define DL_STDEXT   stdext
#define DL_NON_RTTI_OBJECT   std::__non_rtti_object
#define DL_TYPENAME_OUTSIDE_TEMPLATE   typename

Typedef Documentation

typedef INT_PTR(CALLBACK* DL_NOTQUITE_WNDPROC)(HWND, UINT, WPARAM, LPARAM)

Enumeration Type Documentation

anonymous enum
Enumerator:
FNV1_32_INIT 
FNV_32_PRIME 
{
   FNV1_32_INIT = 0x811c9dc5,
   FNV_32_PRIME = 0x01000193
};

Function Documentation

DataPtr DLGetWindowLongPtr ( HWND  hWnd,
int  n = GWLP_USERDATA,
DataPtr  = NULL 
)
{
   return (DataPtr)(static_cast<LONG_PTR>(::GetWindowLongPtr(hWnd, n)));
}
DataPtr DLGetWindowLongPtrA ( HWND  hWnd,
int  n = GWLP_USERDATA 
)
{
        return (DataPtr)(static_cast<LONG_PTR>(::GetWindowLongPtrA(hWnd, n)));
}
DataPtr DLGetWindowLongPtrW ( HWND  hWnd,
int  n = GWLP_USERDATA 
)
{
        return (DataPtr)(static_cast<LONG_PTR>(::GetWindowLongPtrW(hWnd, n)));
}
DataPtr DLGetWindowLongPtr ( HWND  hWnd,
DataPtr *  pPtr,
int  n = GWLP_USERDATA 
)
{
   *pPtr = DLGetWindowLongPtr<DataPtr>(hWnd, n);

   return *pPtr;
}
bool DLGetWindowLongPtr ( HWND  hWnd,
int  n,
bool   
) [inline]
{
   // Specialize for bool so we can quietly deal 
   // warning C4800: 'LONG_PTR' : forcing value to bool 'true' or 'false' (performance warning)
   return ::GetWindowLongPtr(hWnd, n) != 0;
}
WNDPROC DLGetWindowProc ( HWND  hWnd ) [inline]
{
   return DLGetWindowLongPtr<WNDPROC>(hWnd, GWLP_WNDPROC);
}
WNDPROC DLGetWindowProcA ( HWND  hWnd ) [inline]
{
        return DLGetWindowLongPtrA<WNDPROC>(hWnd, GWLP_WNDPROC);
}
WNDPROC DLGetWindowProcW ( HWND  hWnd ) [inline]
{
        return DLGetWindowLongPtrW<WNDPROC>(hWnd, GWLP_WNDPROC);
}
HINSTANCE DLGetWindowInstance ( HWND  hWnd ) [inline]
{
   return DLGetWindowLongPtr<HINSTANCE>(hWnd, GWLP_HINSTANCE);
}
Type DLSetWindowLongPtr ( HWND  hWnd,
Type  ptr,
int  n = GWLP_USERDATA 
) [inline]
{
#if !defined( _WIN64 )
   // SetWindowLongPtr() maps to SetWindowLong() in 32 bit land; react accordingly to keep
   // the compiler happy, even with /Wp64.
   return (Type)(static_cast<LONG_PTR>(::SetWindowLongPtr(hWnd, n, (LONG)((LONG_PTR)(ptr)))));
#else
   return (Type)(static_cast<LONG_PTR>(::SetWindowLongPtr(hWnd, n, (LONG_PTR)(ptr))));
#endif
}
bool DLSetWindowLongPtr ( HWND  hWnd,
bool  bo,
int  n 
) [inline]
{
   // Specialize for bool so we can quietly deal 
   // warning C4800: 'LONG_PTR' : forcing value to bool 'true' or 'false' (performance warning)
   return ::SetWindowLongPtr(hWnd, n, bo) != 0;
}
WNDPROC DLSetWindowLongPtr ( HWND  hWnd,
WNDPROC  pfn 
) [inline]
{
   return DLSetWindowLongPtr<WNDPROC>(hWnd, pfn, GWLP_WNDPROC);
}
WNDPROC DLSetWindowProc ( HWND  hWnd,
WNDPROC  pfn 
) [inline]
{
   return DLSetWindowLongPtr<WNDPROC>(hWnd, pfn, GWLP_WNDPROC);
}
DataPtr DLGetClassLongPtr ( HWND  hWnd,
int  n,
DataPtr  = NULL 
)
{
   return (DataPtr)(static_cast<LONG_PTR>(::GetClassLongPtr(hWnd, n)));
}
DataPtr DLGetClassLongPtrA ( HWND  hWnd,
int  n 
)
{
        return (DataPtr)(static_cast<LONG_PTR>(::GetClassLongPtrA(hWnd, n)));
}
DataPtr DLGetClassLongPtrW ( HWND  hWnd,
int  n 
)
{
        return (DataPtr)(static_cast<LONG_PTR>(::GetClassLongPtrW(hWnd, n)));
}
DataPtr DLGetClassLongPtr ( HWND  hWnd,
DataPtr *  pPtr,
int  n 
)
{
   *pPtr = DLGetClassLongPtr<DataPtr>(hWnd, n);

   return *pPtr;
}
bool DLGetClassLongPtr ( HWND  hWnd,
int  n,
bool   
) [inline]
{
   return ::GetClassLongPtr(hWnd, n) != 0;
}
WNDPROC DLGetClassWindowProc ( HWND  hWnd ) [inline]
{
   return DLGetClassLongPtr<WNDPROC>(hWnd, GCLP_WNDPROC);
}
WNDPROC DLGetClassWindowProcA ( HWND  hWnd ) [inline]
{
        return DLGetClassLongPtrA<WNDPROC>(hWnd, GCLP_WNDPROC);
}
WNDPROC DLGetClassWindowProcW ( HWND  hWnd ) [inline]
{
        return DLGetClassLongPtrW<WNDPROC>(hWnd, GCLP_WNDPROC);
}
Type DLSetClassLongPtr ( HWND  hWnd,
Type  ptr,
int  n 
) [inline]
{
#if !defined( _WIN64 )
   // SetClassLongPtr() maps to SetClassLong() in 32 bit land; react accordingly to keep
   // the compiler happy, even with /Wp64.
   return (Type)(static_cast<LONG_PTR>(::SetClassLongPtr(hWnd, n, (LONG)((LONG_PTR)(ptr)))));
#else
   return (Type)(static_cast<LONG_PTR>(::SetClassLongPtr(hWnd, n, (LONG_PTR)(ptr))));
#endif
}
bool DLSetClassLongPtr ( HWND  hWnd,
bool  bo,
int  n 
) [inline]
{
   // Specialize for bool so we can quietly deal 
   // warning C4800: 'LONG_PTR' : forcing value to bool 'true' or 'false' (performance warning)
   return ::SetClassLongPtr(hWnd, n, bo) != 0;
}
Type DLSetClassLongPtrA ( HWND  hWnd,
Type  ptr,
int  n 
) [inline]
{
#if !defined( _WIN64 )
        // SetClassLongPtr() maps to SetClassLong() in 32 bit land; react accordingly to keep
        // the compiler happy, even with /Wp64.
        return (Type)(static_cast<LONG_PTR>(::SetClassLongPtrA(hWnd, n, (LONG)((LONG_PTR)(ptr)))));
#else
        return (Type)(static_cast<LONG_PTR>(::SetClassLongPtrA(hWnd, n, (LONG_PTR)(ptr))));
#endif
}
Type DLSetClassLongPtrW ( HWND  hWnd,
Type  ptr,
int  n 
) [inline]
{
#if !defined( _WIN64 )
        // SetClassLongPtr() maps to SetClassLong() in 32 bit land; react accordingly to keep
        // the compiler happy, even with /Wp64.
        return (Type)(static_cast<LONG_PTR>(::SetClassLongPtrW(hWnd, n, (LONG)((LONG_PTR)(ptr)))));
#else
        return (Type)(static_cast<LONG_PTR>(::SetClassLongPtrW(hWnd, n, (LONG_PTR)(ptr))));
#endif
}
WNDPROC DLSetClassWindowProc ( HWND  hWnd,
WNDPROC  pfn 
) [inline]
{
        return DLSetClassLongPtr<WNDPROC>(hWnd, pfn, GCLP_WNDPROC);
}
WNDPROC DLSetClassWindowProcA ( HWND  hWnd,
WNDPROC  pfn 
) [inline]
{
        return DLSetClassLongPtrA<WNDPROC>(hWnd, pfn, GCLP_WNDPROC);
}
WNDPROC DLSetClassWindowProcW ( HWND  hWnd,
WNDPROC  pfn 
) [inline]
{
        return DLSetClassLongPtrW<WNDPROC>(hWnd, pfn, GCLP_WNDPROC);
}
UtilExport LONG DLRegSetString ( HKEY  key,
const MCHAR *  data,
const MCHAR *  name = NULL 
)

Wrapper around the windows function RegSetValueEx.

Parameters:
key - The handle to an open registry key
data - The actual data to be added to the registry
name - The name of the registry key
                HKEY query;
                TSTR sub_key;
                sub_key.printf(_T("Software\\Autodesk\\3dsMax\\%d.0"), MAX_VERSION_MAJOR);
                LONG opened = ::RegOpenKeyEx(HKEY_CURRENT_USER, sub_key.data(), 0, KEY_ALL_ACCESS, &query);
                if (opened != ERROR_SUCCESS)
                        return;

                LONG result = DLRegSetString(query, _T("TestValue"), _T("TestKey"));
UtilExport LONG DLRegSetDWord ( HKEY  key,
DWORD  data,
const MCHAR *  name = NULL 
)

Wrapper around the windows function RegSetValueEx for DWORD data.

Parameters:
key - The handle to an open registry key
data - The actual data to be added to the registry
name - The name of the registry key
LONG DLRegSetBlob ( HKEY  key,
const BlobType *  lpbValue,
DWORD  n,
LPCMSTR  lpValueName = NULL 
) [inline]
{
   return ::RegSetValueEx(key, lpValueName, 0, REG_BINARY, 
                          reinterpret_cast<LPBYTE>(const_cast<BlobType*>(lpbValue)), 
                          n * sizeof(BlobType));
}
UtilExport BOOL DLGetTextExtent ( HDC  hDC,
const MCHAR *  text,
LPSIZE  lpExtent 
)
UtilExport BOOL DLGetTextExtent ( HDC  hDC,
const MCHAR *  text,
size_t  len,
LPSIZE  lpExtent 
)
UtilExport BOOL DLTextOut ( HDC  hDC,
int  x,
int  y,
const MCHAR *  text 
)
UtilExport BOOL DLTextOut ( HDC  hDC,
int  x,
int  y,
const MCHAR *  text,
size_t  len 
)
UtilExport LONG DLTabbedTextOut ( HDC  hDC,
int  x,
int  y,
const MCHAR *  text,
int  nTabs,
const INT *  pTabPositions,
int  nTabOrigin 
)
UtilExport int DLDrawText ( HDC  hDC,
const MCHAR *  lpString,
LPRECT  lpRect,
UINT  uFormat 
)
UtilExport int DLDrawText ( HDC  hDC,
const MCHAR *  lpString,
size_t  len,
LPRECT  lpRect,
UINT  uFormat 
)
WORD PointerHiPart ( ULONG_PTR  ptr ) [inline]
{
   return static_cast<WORD>(ptr >> 16);
}
WORD PointerLoPart ( ULONG_PTR  ptr ) [inline]
{
   return static_cast<WORD>(ptr);
}
WORD PointerHiPart ( LONG_PTR  ptr ) [inline]
{
   return static_cast<WORD>((ptr >> 16) & 0xffff);
}
WORD PointerLoPart ( LONG_PTR  ptr ) [inline]
{
   return static_cast<WORD>(ptr & 0xffff);
}
WORD PointerHiPart ( void *  ptr ) [inline]
{
   return PointerHiPart(reinterpret_cast<ULONG_PTR>(ptr));
}
WORD PointerLoPart ( void *  ptr ) [inline]
{
   return PointerLoPart(reinterpret_cast<ULONG_PTR>(ptr));
}
unsigned int fnv_32_buf ( const void *  buf,
int  len,
unsigned int  hval 
) [inline]
{
   const unsigned char *bp = (const unsigned char *)buf; /* start of buffer */
   const unsigned char *be = bp + len;                   /* beyond end of buffer */

   /*
    * FNV-1 hash each octet in the buffer
    */
   while (bp < be) 
   {
      /* multiply by the 32 bit FNV magic prime mod 2^32 */
      hval *= FNV_32_PRIME;

      /* xor the bottom with the current octet */
      hval ^= (unsigned int)*bp++;
   }

   /* return our new hash value */
   return hval;
}
unsigned int DLObjectHash ( T &  t,
int  HashTableSize = 0 
) [inline]
{
   // Since we're always hashing single objects, we hash using the 'init value';
   // we'd have to carry it over if we were hashing all fields in a structure, for
   // instance.
   // You should never never never never attempt to hash a structure by passing its
   // pointer, since you'd end up hashing the padding bytes as well, which are definitely
   // not going to be preserved.
   unsigned int hash = fnv_32_buf(&t, sizeof(t), (unsigned int)FNV1_32_INIT);

   return HashTableSize ? hash % HashTableSize : hash;
}
unsigned int DLPointerHash ( const void *  pv,
int  HashTableSize = 0 
) [inline]
{
   return DLObjectHash(pv, HashTableSize);
}
int DL_abs ( int  n ) [inline]
{ return std::abs(n); }
__int64 DL_abs ( __int64  n ) [inline]
{ return (n < 0) ? -n : n; }
float DL_abs ( float  f ) [inline]
{ return std::fabsf(f); }
double DL_abs ( double  f ) [inline]
{ return std::fabs(f); }
long double DL_abs ( long double  f ) [inline]
{ return std::fabsl(f); }