home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / MSJMAR94.ZIP / DYNDLG.ZIP / DYNDLG1.ZIP / WINXEXT.H < prev   
C/C++ Source or Header  |  1994-03-01  |  2KB  |  86 lines

  1. /**************************************************************************
  2.     Header File for Win32 compatibilty
  3.  
  4.     Written by Atif Aziz, Sep 1993
  5.  
  6.     This file helps Win16 applications to be more source-compatible
  7.     with Win32. It defines certain values that translate to the most
  8.     appropriate values depending on the target environment.
  9. **************************************************************************/
  10.  
  11. #ifndef _WINXEXT_H_
  12. #define _WINXEXT_H_
  13.  
  14. #ifndef __WINDOWS_H
  15. #include <windows.h>
  16. #endif
  17.  
  18.     // Macro to define pointer version of a given typedef
  19.  
  20. #define TYPEDEF_POINTERS(base, type)            \
  21. typedef base *                  P##type;        \
  22. typedef const base *            PC##type;       \
  23. typedef base NEAR *             NP##type;       \
  24. typedef const base NEAR *       NPC##type;      \
  25. typedef base FAR *              LP##type;       \
  26. typedef const base FAR *        LPC##type;
  27.  
  28. //-------------------------------------------------------------------------
  29. // WIN16 and WIN32 Compatibility definitions 
  30. //-------------------------------------------------------------------------
  31.  
  32. #ifdef WIN32
  33.  
  34.   // Portable resource character type
  35.   typedef WCHAR RCHAR;
  36.  
  37.   // Macro returning the length of a resource string. 
  38.   #define _rcslen(lpcrsz)    lstrlenW(lpcrsz)
  39.  
  40.   // Missing lstrcpyn() from Win32 API
  41.  
  42.   #include <tchar.h>
  43.   #include <wchar.h>
  44.  
  45.   #define lstrcpyn    _tcsncpy
  46.  
  47. #else    // WIN32
  48.  
  49.   // Portable basic character unit not included in Win16 header files
  50.   // but is defined here.
  51.  
  52.   typedef char  TCHAR;
  53.  
  54.   TYPEDEF_POINTERS(TCHAR, TSTR)
  55.   TYPEDEF_POINTERS(TCHAR, TCH)
  56.  
  57.   // Macro returning the length of a resource string.
  58.   #define _rcslen(lpcsz)    lstrlen(lpcsz)
  59.  
  60.   // The following macro is to be used for string and character literals
  61.   // appearing in the code. It is already defined in the Win32 SDK
  62.   // header file.
  63.   #define TEXT(text)            text
  64.  
  65.   // Portable resource character type 
  66.   typedef char  RCHAR;
  67.  
  68. #endif    // WIN32
  69.  
  70. //-------------------------------------------------------------------------
  71. // Definitions common to WIN16 and WIN32 
  72. //-------------------------------------------------------------------------
  73.  
  74. // Define string versions of RCHAR (PRSTR, LPRSTR, etc.)
  75. TYPEDEF_POINTERS(RCHAR, RSTR)
  76.  
  77.     // Miscellaneous type definitions
  78.  
  79. typedef HWND NEAR *    NPHWND;
  80.  
  81.     // Other useful macros
  82.  
  83. #define ARRAY_COUNT(a)        (sizeof(a) / sizeof((a)[0]))
  84.  
  85. #endif  // _WINXEXT_H_
  86.