home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Internet Business Development Kit / PRODUCT_CD.iso / sqlsvr / odbcsdk / samples / cppdemo / cppdemo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-07  |  6.1 KB  |  208 lines

  1. /*--------------------------------------------------------------------------
  2.   CPPDEMO.H -- Shared constants, types, prototypes, variables
  3.  
  4.   This code is furnished on an as-is basis as part of the ODBC SDK and is
  5.   intended for example purposes only.
  6.  
  7. --------------------------------------------------------------------------*/
  8.       
  9. #ifndef __CPPDEMO_H
  10. #define __CPPDEMO_H
  11.  
  12. #ifdef    INCL_GLOBAL
  13. #define    GLOBAL
  14. #define    INITHAND(name, type)        type name = NULL;
  15. #define    CONSTSTR(name, str)            const char* name = str
  16. #else
  17. #define    GLOBAL                        extern
  18. #define    INITHAND(name, type)        extern type name
  19. #define CONSTSTR(name, str)            extern const char* name
  20. #endif
  21.  
  22.  
  23. //////////////////////////////////////////////////////////////////////////////
  24. //
  25. //    Defines
  26. //
  27. #ifdef _AFX
  28. IMPLEMENT_DYNAMIC(CODBCException, CException);
  29. IMPLEMENT_DYNAMIC(CODBC, CObject);
  30. IMPLEMENT_DYNAMIC(CENV,  CODBC);
  31. IMPLEMENT_DYNAMIC(CDBC,  CODBC);
  32. IMPLEMENT_DYNAMIC(CSTMT, CODBC);
  33. #endif
  34.  
  35. #ifdef WIN32
  36. #define EXPFUNC CALLBACK
  37. #define INTFUNC WINAPI
  38. #else
  39. #ifndef EXPORT
  40. #define EXPORT        _export
  41. #endif
  42. #define EXPFUNC EXPORT CALLBACK
  43. #define INTFUNC WINAPI
  44. #endif
  45.  
  46. #ifdef    _DEBUG
  47. #define    DASSERT(x)        assert(x)
  48. #else
  49. #define    DASSERT(x)        (x)
  50. #endif
  51.  
  52. #define    AllocPtr(x)        GlobalAllocPtr(GHND, (x))
  53. #define    FreePtr(x)        if( (x) ) GlobalFreePtr((x))
  54.  
  55. #define    MF_ENABLE        MF_ENABLED | MF_BYCOMMAND
  56. #define MF_DISABLE        MF_GRAYED | MF_BYCOMMAND
  57.  
  58. #define    HOURGLASS(h)    {\
  59.                         h = SetCursor(LoadCursor(NULL, IDC_WAIT));\
  60.                         ShowCursor(TRUE);\
  61.                         }
  62. #define ARROW(h)        {\
  63.                         ShowCursor(FALSE);\
  64.                         SetCursor(h);\
  65.                         }
  66.  
  67. #ifndef min
  68. #define min(a,b)        (((a) < (b)) ? (a) : (b))
  69. #endif
  70.  
  71. #ifndef max
  72. #define max(a,b)        (((a) > (b)) ? (a) : (b))
  73. #endif
  74.  
  75.  
  76. //////////////////////////////////////////////////////////////////////////////
  77. //
  78. //    Constants
  79. //
  80.  
  81. // Miscellaneous
  82. GLOBAL  const           cbSTRLEN        = 256;      // Max string length
  83. GLOBAL  const           cbMAXSQL        = 512;      // Max SQL string length
  84. GLOBAL  const           cPOINTS         = 10;       // Font point size
  85. GLOBAL  const           cxBORDER        = 6;        // Column border
  86. GLOBAL  const           cbCOLMEMMAX     = 10000L;   // Maximum column mem size
  87. GLOBAL  const           HLP_CPPDEMO     = 20;       // Help context number
  88.  
  89. // Strings
  90. CONSTSTR(szCLASSNAME,   "ODBC_CPP_DEMO");           // Window class name
  91. CONSTSTR(szDATATRUNC,   "01004");                   // ODBC truncation error
  92. CONSTSTR(szDSNKEY,      "DSN=");                    // Data source name key
  93. CONSTSTR(szDASH,        " - ");                     // Title separator
  94. CONSTSTR(szNODSN,       "no DSN");                  // DSN name when no DSN
  95. CONSTSTR(szFONT,        "MS Sans Serif");           // Window font name
  96. CONSTSTR(szSCROLLCLASS, "SCROLLBAR");               // Scrollbar class name
  97. CONSTSTR(szHELPFILE,    "..\\help\\odbcsmpl.hlp");  // Samples help file
  98.  
  99.  
  100. //////////////////////////////////////////////////////////////////////////////
  101. //
  102. //    Types
  103. //
  104. typedef struct tagCOL
  105.     {
  106.     char        szName[cbSTRLEN];    // Column name
  107.     SDWORD        cb;                    // Column width (transfer width)
  108.     SDWORD        cbc;                // Column width (display  width)
  109.     SDWORD        fCType;                // C data type
  110.     SDWORD        fSqlType;            // ODBC SQL data type
  111.     LPSDWORD    lpcb;                // Pointer to returned width
  112.     LPBYTE        lpb;                // Pointer to returned data
  113.     LPSDWORD    lpcbuf;                // Aggregate width buffer
  114.     LPBYTE        lpbuf;                // Aggregate data buffer
  115.     }
  116.     COL, FAR *LPCOL;
  117.     
  118. typedef struct tagAPPINST
  119.     {
  120.     HINSTANCE    hinst;                // Application instance handle
  121.     char        szTitle[cbSTRLEN];    // Current window title
  122.  
  123.     HWND        hwndVScroll;        // Vertical scrollbar handle
  124.     HWND        hwndHScroll;        // Horizontal scrollbar handle
  125.     
  126.     BOOL        fVScroll;            // Vertical scrollbar present
  127.     BOOL        fHScroll;            // Horizontal scrollbar present
  128.     
  129.     BOOL        fIsMinimized;        // Window is minimized
  130.     
  131.     BOOL        fCtl3d;                // Ctl3d enabled
  132.     BOOL        fAutoCtl3d;            // Ctl3d in auto-subclass mode
  133.     
  134.     CENV*        cEnv;                // Environment object
  135.     CDBC*        cDbc;                // Connection object
  136.     CSTMT*        cStmt;                // Statement object
  137.     
  138.     BOOL        fConnected;            // Connected to data source
  139.     BOOL        fData;                // Data fetched from data source
  140.     BOOL        fResultSet;            // Result set exists
  141.     
  142.     UWORD        cCol;                // # of columns in the result set
  143.     UWORD        cRow;                // # of rows in the result set
  144.     UWORD        cMaxRow;            // max # of rows in the result set
  145.     UWORD        crowwin;            // # of rows to display at once
  146.     UWORD        ccolwin;            // # of cols to display at once
  147.     UWORD        ccols;                // Number of display chars per row
  148.     UWORD        cbrow;                // Number of storage bytes per row
  149.     
  150.     LPCOL        lpcol;                // Column information array
  151.     
  152.     char        szSQL[cbMAXSQL];    // SQL statement buffer
  153.     char
  154.         szDSN[SQL_MAX_DSN_LENGTH+1];// DSN buffer
  155.     }
  156.     APPINST, FAR *LPAPPINST;
  157.     
  158. typedef struct tagAPPGLOB
  159.     {
  160.     char        szTitle[cbSTRLEN];    // Application title
  161.     
  162.     HICON        hicon;                // Application icon
  163.     
  164.     HBRUSH        hbrWin;                // Window background brush
  165.     HBRUSH        hbrBtn;                // Button face brush
  166.     HBRUSH        hbrScroll;            // Scrollbar brush
  167.     
  168.     HFONT        hfontName;            // Column name font
  169.     HFONT        hfontData;            // Data item font
  170.     
  171.     int            cxVScroll;            // Width of vertical scrollbar
  172.     int            cyHScroll;            // Height of horizontal scrollbar
  173.     
  174.     int            cx;                    // Width of a character
  175.     int            cy;                    // Height of a character
  176.     
  177.     char        szNull[cbSTRLEN];    // <NULL> string
  178.     
  179.     int            cInstance;            // instance counter
  180.     }
  181.     APPGLOB, FAR *LPAPPGLOB;
  182.         
  183.         
  184. //////////////////////////////////////////////////////////////////////////////
  185. //
  186. //    Globals
  187. //
  188.  
  189.  
  190. //////////////////////////////////////////////////////////////////////////////
  191. //
  192. //    Prototypes
  193. //
  194.  
  195. //    General routines
  196. void    INTFUNC    vDoMessage(HWND, UINT);
  197. BOOL    INTFUNC    fODBCError(HWND, RETCODE);
  198.  
  199. //    Window and dialog procedures
  200. BOOL    EXPFUNC AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
  201. BOOL    EXPFUNC    ConfirmDlgProc(HWND, UINT, WPARAM, LPARAM);
  202. BOOL    EXPFUNC OkDlgProc(HWND, UINT, WPARAM, LPARAM);
  203. BOOL    EXPFUNC    SQLDlgProc(HWND, UINT, WPARAM, LPARAM);
  204. LRESULT    EXPFUNC WndProc(HWND, UINT, WPARAM, LPARAM);
  205.  
  206.  
  207. #endif    // __CPPDEMO_H
  208.