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

  1. //*---------------------------------------------------------------------------------
  2. //|  ODBC System Administrator
  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. //|    Title:    RESULTS.H
  8. //|        This file contains the prototypes and defines for anyone using RESULTS.H.
  9. //*---------------------------------------------------------------------------------
  10. #ifndef results_DEFS
  11. #define results_DEFS
  12.  
  13. #include <windows.h>
  14. #include "sql.h"
  15. #include "sqlext.h"
  16.  
  17. //------------------------------------------------------------------------
  18. //  Defines
  19. //------------------------------------------------------------------------
  20. #define SQL_TYPE                        1
  21. #define C_TYPE                            2
  22. #define TYPENAME                        35
  23.  
  24. #define MAXBYTES                        255
  25.  
  26.  
  27. #define RDATA_WHITE                    RGB(255,255,255)
  28. #define RDATA_GRAY                    RGB(190, 190, 190)
  29. #define RDATA_BLACK                    RGB(0, 0, 0)
  30. #define RDATA_RED                        RGB(255,0,0)
  31. #define RDATA_GREEN                     RGB(0,255,0)
  32. #define RDATA_BLUE                    RGB(0,0,255)
  33. #define RDATA_LTBLUE                    RGB(0,255,255)
  34. #define RDATA_DEFAULT_TEXT                    GetSysColor(COLOR_WINDOWTEXT)
  35. #define RDATA_DEFAULT_BKGRND                GetSysColor(COLOR_WINDOW)
  36. #define RDATA_DEFAULT_SELECT_TEXT        GetSysColor(COLOR_HIGHLIGHTTEXT)
  37. #define RDATA_DEFAULT_SELECT                GetSysColor(COLOR_HIGHLIGHT)
  38.  
  39.  
  40. //------------------------------------------------------------------------
  41. //  Declare global variables
  42. //------------------------------------------------------------------------
  43.  
  44.  
  45.  
  46. //*--------------------------------------------------------------------
  47. //|  METADATA:
  48. //|    This structure contains the meta data about each column in the
  49. //|        results set.  This information can be easily retrieved using
  50. //|        SQLColAttributes or SQLDescribeCol.
  51. //*--------------------------------------------------------------------
  52. typedef struct tagMETADATA {
  53.     LPSTR            szColumnName;                // Name of the column
  54.     char            szTypeName[TYPENAME];    //    ODBC type name
  55.     SDWORD        fSqlType;                    // Numeric SQL type
  56.     UDWORD        precision;                    // Precision of the data type
  57.     SWORD            scale;                        // Scale of the data type
  58.     int            cbDisplaySize;                // How many bytes to display
  59.     UINT            fAlign;                        // What alignment to take
  60.     int            xCol;                            // x offset from 0 for column
  61.     UINT            cColWidth;                    // Width of column in pixels
  62.     UINT            cbOffset;                    // Byte offset in row storage
  63.     } METADATA;
  64.  
  65.  
  66. //*--------------------------------------------------------------------
  67. //|  This structure is created when the user creates a results set.
  68. //|    It must be used for all major function calls.
  69. //*--------------------------------------------------------------------
  70. typedef struct tagRESULTSSET {
  71.     char            szTitle[MAXBUFF];            // Title for the window
  72.     int            cbColumns;                    // How many columns in results?
  73.     HINSTANCE    hInst;                        // Instance handle for this dll
  74.     HWND            hwndResults;                // Window handle for the MDI client window
  75.     HWND            hwndClient;                    // Window handle of the client window
  76.     HWND            hwndTitle;                    // Column names
  77.     HWND            hwndList;                    // Window handle for list box
  78.     HWND            hwndHScroll;                // Window handle for horizontal scroll bar
  79.     HWND            hwndVScroll;                // Window handle for vertical scroll bar
  80.     HFONT            hFont;                        // Logical font for window
  81.     int            cx;                            // Width of the average character
  82.     int            cy;                            // Height of the average character
  83.     int            cTitleHeight;                // Height of the title bar
  84.     int            yTitleLoc;                    // What y value to use when drawing title text
  85.     int            cRowWidth;                    // Overall width if completely shown
  86.     METADATA        FAR * md;                    // Structure with meta data
  87.     } RESULTSSET, FAR * lpRESULTSSET;
  88.  
  89.  
  90. //------------------------------------------------------------------------
  91. //  Following structure is used to keep track of data for each column
  92. //------------------------------------------------------------------------
  93. typedef struct tagCOLUMNDATA {
  94.     LPSTR        szCols;                                        // Column data
  95.     } COLUMNDATA, FAR * lpCOLUMNDATA;
  96.  
  97. //------------------------------------------------------------------------
  98. //  Following structure should be allocated for each row
  99. //------------------------------------------------------------------------
  100. typedef struct tagRowData {
  101.    COLUMNDATA FAR *         cd;                            // Pointer to column information
  102.     LPSTR                        data;                            // Buffer for all column data
  103.    COLORREF                 textColor;                    // Color of text
  104.    COLORREF                 bkgrnd;                        // Color of background
  105.    } ROWDATA, FAR * lpROWDATA;
  106.  
  107.  
  108.  
  109. //------------------------------------------------------------------------
  110. //  Declare function prototypes
  111. //------------------------------------------------------------------------
  112. BOOL EXTFUN CreateResultsSet(RESULTSSET FAR * rs, HWND hwndClient, HINSTANCE hInst,
  113.                                     int count, LPSTR szTitle);
  114. BOOL EXTFUN SetMetaDataColumn(RESULTSSET FAR * rs, int iCol, LPSTR szCol,
  115.                                     LPSTR szTypeName, SDWORD fSqlType, UDWORD precision, SWORD scale,
  116.                                     int cbDisplay, UINT fAlign);
  117. ROWDATA FAR * AllocateRowData(RESULTSSET FAR * rs, COLORREF cColor, COLORREF cBkg);
  118. BOOL EXTFUN SetColumnData(int icol, ROWDATA FAR * rd, LPSTR str);
  119. void EXTFUN FreeRowData(RESULTSSET FAR * rs, ROWDATA FAR * rd);
  120. void EXTFUN FreeResultsSet(RESULTSSET FAR * rs);
  121. int  FindRightCol(RESULTSSET FAR * rs, int xLeftCol, int cWidth);
  122. void CreateResultsFont(RESULTSSET FAR * rs, HWND hwnd, LOGFONT FAR * lf);
  123. void DrawRowData(RESULTSSET FAR * rs, DRAWITEMSTRUCT FAR * dwitem,
  124.                                     int xLeftCol, int xRightCol);
  125. void INTFUN DrawColumnTitles(HDC hdc, RESULTSSET FAR * rs, 
  126.                                     RECT FAR * crect, int xLeftCol, int xRightCol);
  127. void     HandleHScroll(WORD wParam, RESULTSSET FAR * rs,
  128.                                     HWND hwnd, HWND hwndHScroll, int FAR * xLeftCol, int FAR * xRightCol,
  129.                                     HWND hwndList, int cbColumns, int cbClient, RECT FAR * tRect);
  130. void HandleVirtualHScroll(WORD wParam, HWND hwndList, HWND hwndOwner);
  131. int     AddRowData(RESULTSSET FAR * rs, ROWDATA FAR * rd);
  132. SWORD GetNumResultsCols(HSTMT hstmt);
  133. LPSTR GetTypeName(int type, int fType);
  134. void     ConvertSqlTypeToChar(RESULTSSET FAR * rs, int col, LPSTR inbuff, 
  135.                                     LPSTR outbuff, SDWORD rtnd);
  136. void     BinToChar(LPSTR outstr, LPSTR instr, SDWORD count);
  137.                 
  138.  
  139. #endif
  140.