home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / Software / TemaCD / tcvpa / data1.cab / MyFileGroup / INCLUDE / tcTable.h < prev    next >
C/C++ Source or Header  |  1999-06-03  |  9KB  |  291 lines

  1. #define WC_TcTbl        "TcTable"
  2.  
  3. #define WS_TBL_MULTIPLESEL        0x0004
  4. #define WS_TBL_PRIVATEIMAGE        0x0008
  5. #define WS_TBL_ALWAYSEDIT        0x0010
  6. #define WS_TBL_AUTO                0x0020
  7.  
  8. //***********************************************************
  9. enum
  10. {
  11.     TBL_DT_TEXT,
  12.     TBL_DT_BOOL,
  13.     TBL_DT_INT,
  14.     TBL_DT_FLOAT,
  15.     TBL_DT_PTR,
  16.     TBL_DT_CUSTOM
  17. };
  18. enum
  19. {
  20. //    TBL_CTRL_NONE,
  21.     TBL_CTRL_EDIT,
  22.     TBL_CTRL_MLEDIT,
  23.     TBL_CTRL_ECOMBO,
  24.     TBL_CTRL_LCOMBO,
  25.     TBL_CTRL_CHECK,
  26.     TBL_CTRL_3STATE,
  27.     TBL_CTRL_CUSTOM,
  28. };
  29. //***********************************************************
  30. #define TBLCF_READONLY        (1U<<0)
  31. #define TBLCF_TITLEIMAGE    (1U<<1)
  32. #define TBLCF_ALIGNRIGHT    (1U<<2)
  33. #define TBLCF_ALIGNCENTER    (1U<<3)
  34. #define TBLCF_HWND_AS_ID    (1U<<4)
  35. //***********************************************************
  36. struct ADDTBLCOLUMN
  37. {
  38.     WORD        ctrlType;
  39.     WORD        dataType;
  40.     WORD        dataSize;    // only for TBL_DT_CUSTOM, TBL_DT_TEXT
  41.     WORD        textLength;    // only for TBL_DT_CUSTOM
  42.  
  43.     WORD        iTblGrp;
  44.     short        iTitleImgIdx;
  45.     WORD        exRows;
  46.     WORD        dummy1;
  47.  
  48.     DWORD        dwFlags;
  49.     short        iWidth;        // Column in Pixels (0:Default, -1:Hidden)
  50.     short        dummy2;
  51.  
  52.     HIMAGELIST    hImageListCB;        // Combo box
  53.     HIMAGELIST    hImageListTitle;    // 1, 2, 3 = Standard
  54.  
  55.     HWND    hwnd;
  56.  
  57.     char *    Title;
  58. };
  59. //***********************************************************
  60. typedef struct _TBL_GETFIELD {
  61.     long    row;
  62.     long    col;
  63.     char    buf[256];
  64.     WORD    changed;    // FOR GET ONLY
  65.     WORD    dummy1;
  66. }
  67. TBL_GETFIELD;
  68. //***********************************************************
  69. enum
  70. {
  71. WM_TBL_INSERTCOLUMN        // wParam - Column Index; (-1)-Add ; lParam - (ADDTBLCOLUMN*)
  72.      = (0x1000+1),
  73. WM_TBL_INIT,            // wParam - numCols, lParam - (ADDTBLCOLUMN*)
  74. WM_TBL_RESET,            //
  75. WM_TBL_CLEAR,            //
  76. WM_TBL_USERCACHE,
  77.  
  78. WM_TBL_GRPTITLE,        // wParam - num, lParam = Title
  79.  
  80. WM_TBL_HWNDCONTROL,        // wParam - Column Index; Return HWND
  81. WM_TBL_SHOWCTRL,        // wParam - 0-Hide,1-Show,2-Switch
  82. WM_TBL_GETCURCOL,        // Return CURRENT CONTROL COLUMN
  83.  
  84. WM_TBL_GETROWCOUNT,        // Return Rows
  85. WM_TBL_GETCURROW,        // Return CurRow
  86. WM_TBL_SETCURROW,        // wParam = row; Return CurRow
  87.  
  88. WM_TBL_INSERTROW,        // wParam - Row_Index, lParam = flags; Return Row_Index
  89. #define INSROW_SETCUR    1
  90. #define INSROW_NODRAW    2
  91. WM_TBL_DELETEROW,        // wParam - Row_Index
  92.  
  93. WM_TBL_GETFIELD,        // lParam = (TBL_GETFIELD*)
  94. WM_TBL_SETFIELD,        // lParam = (TBL_GETFIELD*), if(row==FocusRow ) wParam = ChgFlag(1)
  95. WM_TBL_SETCTRLFLAG,        // wParam = col, lParam = flag
  96.  
  97. WM_TBL_GETROWFLAG,        // wParam - Row_Index; Return Flag
  98. WM_TBL_SETROWFLAG,        // wParam - Row_Index; lParam - Flag
  99.  
  100. WM_TBL_GETCOLWIDTH,        // wParam - col; Return Width
  101. WM_TBL_SETCOLWIDTH,        // wParam - col, lParam - Width
  102.  
  103. WM_TBL_CTRLMODIFY,        // wParam - col
  104. WM_TBL_CTRLKEY,            // wParam - VK_....
  105. WM_TBL_CTRLFOCUS,        // wParam - BOOL
  106.  
  107. WM_TBL_FIXCOLS,            // wParam - number of cols
  108. WM_TBL_SAVEROW,            // -
  109.  
  110. WM_TBL_SAVE_DIM,        // lParam = (int*)
  111. WM_TBL_RESTORE_DIM,        // lParam = (int*)
  112.  
  113. WM_TBL_GETCOLCOUNT,        // Return Cols()
  114. WM_TBL_GETCOLINIT,        // lParam = ADDTBLCOLUMN []
  115. WM_TBL_GETCOLTITLE,        // wParam = col, lParam = char[256]
  116. WM_TBL_DRAWROW,            // lParam = row
  117. WM_TBL_UNDOROW,            // -
  118.  
  119. WM_TBL_GETEXTROW,        // Return ...
  120. WM_TBL_SETEXTROW,        // wParam = ...
  121. WM_TBL_GETVISROWCOUNT,    // return num_rows_visible
  122.  
  123. WM_TBL_SETFTITLECLR,    // wParam=col, lParam = COLORREF
  124. WM_TBL_SETBTITLECLR,    // wParam=col, lParam = COLORREF
  125.  
  126. WM_TBL_SETVTBL,            // wParam = auto_delete, lParam = vtbl
  127. WM_TBL_TEXT4FIND,        // lParam = (TBL_GETFIELD*)
  128.  
  129. WM_TBL_SETCURCOL,        // wParam = col
  130. WM_TBL_MOUSE2CELL,        // lParam = (POINT*) Input:mouse_pos; Output:y=Row x=Column
  131. WM_TBL_SETCOLTITLE,        // wParam = col, lParam = char*
  132. WM_TBL_SETROWHDRWIDTH,    // wParam = left_btn_cx
  133.  
  134. };
  135. //***********************************************************
  136. #define TcTbl_InsertColumn(table,idx,s)    SendMessage(table,WM_TBL_INSERTCOLUMN,idx,(LPARAM)(s))
  137. #define TcTbl_Init(table,num,p)            SendMessage(table,WM_TBL_INIT,num,(LPARAM)(p))
  138. #define TcTbl_Reset(table)                SendMessage(table,WM_TBL_RESET,0,0)
  139. #define TcTbl_Clear(table)                SendMessage(table,WM_TBL_CLEAR,0,0)
  140. #define TcTbl_SetGrpTitle(tbl,num,title)    SendMessage(tbl,WM_TBL_GRPTITLE,num,(LPARAM)title)
  141. #define TcTbl_GetHWndControl(table,col)    ((HWND)SendMessage(table,WM_TBL_HWNDCONTROL,col,0))
  142. #define TcTbl_GetRowCount(table)        SendMessage(table,WM_TBL_GETROWCOUNT,0,0)
  143. #define TcTbl_GetColCount(table)        SendMessage(table,WM_TBL_GETCOLCOUNT,0,0)
  144. #define TcTbl_GetCurRow(table)            SendMessage(table,WM_TBL_GETCURROW,0,0)
  145. #define TcTbl_SetCurRow(table,row)        SendMessage(table,WM_TBL_SETCURROW,row,0)
  146. #define TcTbl_GetCurCol(table)            SendMessage(table,WM_TBL_GETCURCOL,0,0)
  147. #define TcTbl_InsertRow(table,row,f)    SendMessage(table,WM_TBL_INSERTROW,row,f)
  148. #define TcTbl_DeleteRow(table,row)        SendMessage(table,WM_TBL_DELETEROW,row,0)
  149. #define TcTbl_GetField(table,s)            SendMessage(table,WM_TBL_GETFIELD,0,(LPARAM)(s))
  150. #define TcTbl_SetField(table,s,f)        SendMessage(table,WM_TBL_SETFIELD,f,(LPARAM)(s))
  151. #define TcTbl_GetRowFlag(table,r)        SendMessage(table,WM_TBL_GETROWFLAG,r,0)
  152. #define TcTbl_SetRowFlag(table,r,f)        SendMessage(table,WM_TBL_SETROWFLAG,r,f)
  153. #define TcTbl_SaveRow(table)            SendMessage(table,WM_TBL_SAVEROW,0,0)
  154. #define TcTbl_UndoRow(table)            SendMessage(table,WM_TBL_UNDOROW,0,0)
  155. #define TcTbl_SetFTitleColor(tbl,col,clr)    SendMessage(tbl,WM_TBL_SETFTITLECLR,col,clr)
  156. #define TcTbl_SetBTitleColor(tbl,col,clr)    SendMessage(tbl,WM_TBL_SETBTITLECLR,col,clr)
  157. #define TcTbl_SetVTbl(tbl,vtbl,auto_del)    SendMessage(tbl,WM_TBL_SETVTBL,auto_del,vtbl)
  158.  
  159.  
  160. #define ROWFLAG_CHANGE    1U
  161. #define ROWFLAG_NEW        2U
  162.  
  163. #define CTRLFLAG_CHANGED    1
  164. //#define CTRLFLAG_FILLED        2
  165.  
  166. //***********************************************************
  167.  
  168. /* typedef struct tagNMHDR {  
  169.     HWND hwndFrom; 
  170.     UINT idFrom; 
  171.     UINT code; 
  172. } NMHDR; */
  173.  
  174. typedef struct _TBL_NOTIFY {
  175.     NMHDR   hdr;
  176.     HWND    hwndCtrl;
  177.     long    row;
  178.     long    col;
  179.     long    idx;
  180.     char    buf[256];
  181. }
  182. TBL_NOTIFY;
  183.  
  184. typedef struct _TBL_DNOTIFY {
  185.     NMHDR   hdr;
  186.     HWND    hwndCtrl;    // not used
  187.     long    row;
  188.     long    col;
  189.     long    idx;
  190.     char    buf[256];
  191.  
  192.     HDC        hDC;
  193.     RECT    rect;
  194.     BOOL    flag;    // 1-focused, 2-selected
  195. }
  196. TBL_DRAWCELL;
  197.  
  198. typedef struct _TBL_CUSTMSG {
  199.     NMHDR   hdr;
  200.  
  201.     HWND    hwndCtrl;    // not used
  202.     long    row;
  203.     long    col;
  204.     long    idx;
  205.     char    buf[256];
  206.  
  207.     UINT    msg;
  208.     WPARAM    wParam;
  209.     LPARAM    lParam;
  210. }
  211. TBL_CUSTMSG;
  212.  
  213. /*typedef struct _TBL_DRAGDROP {
  214.     NMHDR   hdr;
  215.     POINT    ms;
  216.     DWORD    row;
  217. }
  218. TBL_DRAGDROP;*/
  219.  
  220. enum
  221. {
  222. TBLN_RowChanging = -200,    // (row); Return TBL_ROWING_...
  223. #define TBL_ROWING_OK        0
  224. #define TBL_ROWING_ERR        1
  225. #define TBL_ROWING_USER        2
  226. TBLN_RowChanged,        // (new_row)
  227.  
  228. TBLN_CreateControl,        // (col); // hwndCtrl = CreateWindow(...
  229.  
  230. TBLN_Edit,                // (row,col); Return TRUE to prevent to set change flag
  231. TBLN_Validate,            // (row,col); Return TRUE to prevent to leave control
  232. TBLN_Expand,            // (row=wanted_max_rows)
  233. TBLN_ColHdrClick,        // (row,col)
  234.  
  235. TBLN_Ctrl2Buf,            // (row,col,buf); Return OK
  236. TBLN_Data2Ctrl,            // (row,col,buf); Return OK
  237. TBLN_Data2Draw,            // (row,col,buf,idx); Return OK
  238.  
  239. TBLN_GetField,            // (row,col,buf)
  240. TBLN_SetField,            // (row,col,buf)
  241. TBLN_GetRowFlag,        // (row); Return flag
  242. TBLN_SetRowFlag,        // (row,idx); Return BOOL(is_flag_changed)
  243. TBLN_IsRowSel,            // (row); Return BOOL
  244. TBLN_SetRowSel,            // (row,idx=is_sel)
  245. TBLN_ClearAllSelect,    //
  246. TBLN_Rows,                // Return Rows()
  247. TBLN_InsertRow,            // (row); Return row; -1 = no_insert
  248. TBLN_DeleteRow,            // (row); Return BOOL(ok)
  249. TBLN_DrawCell,            // (row,col,buf=data); Return BOOL(ok)
  250. TBLN_CustMsg,            // return LRESULT;
  251. TBLN_RowHdrClick,        // (row)
  252. TBLN_2Link,                // (col)
  253. TBLN_Edit2,                // (row,col)
  254. TBLN_Text4Find,            // (row,col)
  255. TBLN_ClearCustom,        // (col)
  256. TBLN_DrawRowHdr,        // (row); Return BOOL(ok)
  257.  
  258. };
  259. //***********************************************************
  260.  
  261. /*
  262. switch( uMsg )
  263. {
  264. case WM_GETDLGCODE : return (DLGC_WANTARROWS | DLGC_WANTTAB);
  265. case WM_KEYDOWN :
  266.     if( wParam == VK_RETURN && GetKeyState(VK_SHIFT) >= 0 ) break;
  267.     switch( wParam )
  268.     {
  269.     case VK_RETURN : case VK_TAB :
  270.     case VK_UP : case VK_DOWN : case VK_NEXT : case VK_PRIOR :
  271.         SendMessage(GetParent(hWnd),WM_TBL_CTRLKEY,wParam,0);
  272.         return 0;
  273.     }
  274.     break;
  275.  
  276. case WM_CHAR :
  277.     // else may be beep ?
  278.     if( wParam == '\t' || wParam == '\r' || wParam == '\n' ) return 0;
  279.     break;
  280. }
  281.  
  282. LRESULT ret = CallWindowProc( old_Proc, hWnd, uMsg, wParam, lParam );
  283.     or
  284. LRESULT ret = DefWindowProc( hWnd, uMsg, wParam, lParam );
  285.  
  286. if( uMsg == WM_SETFOCUS || uMsg == WM_KILLFOCUS )
  287.     SendMessage(GetParent(hWnd),WM_TBL_CTRLFOCUS,(uMsg == WM_SETFOCUS),0);
  288.  
  289. return ret;
  290. */
  291.