/* Loads some values into the table. Some cells are filled via grid control, * some are set directly through table model API after we get a pointer to * the table from the grid control. */ static void LoadGrid(void) { MC_HTABLE hTable; MC_TABLECELL tc; TCHAR buffer[32]; int row; int height; /* Set size of the table to 8 columns and 16 rows. */ SendMessage(hwndGrid, MC_GM_RESIZE, MAKEWPARAM(8, 16), 0); /* Setup first column which serves as row headers. This is due the style * MC_GS_ROWHEADERNORMAL. */ tc.fMask = MC_TCMF_TEXT; tc.pszText = buffer; for(row = 0; row < 16; row++) { _sntprintf(buffer, 32, _T("Row %d"), row+1); SendMessage(hwndGrid, MC_GM_SETCELL, MAKEWPARAM(MC_TABLE_HEADER, row), (LPARAM) &tc); } /* Set a text of some cell */ tc.fMask = MC_TCMF_TEXT; tc.pszText = buffer; _sntprintf(buffer, 32, _T("Hello world!")); SendMessage(hwndGrid, MC_GM_SETCELL, MAKEWPARAM(1, 1), (LPARAM) &tc); /* We can also get the data model of the grid control and manipulate it * directly. */ hTable = (MC_HTABLE) SendMessage(hwndGrid, MC_GM_GETTABLE, 0, 0); tc.fMask = MC_TCMF_TEXT | MC_TCMF_FLAGS; tc.pszText = _T("top left"); tc.dwFlags = MC_TCF_ALIGNLEFT | MC_TCF_ALIGNTOP; mcTable_SetCell(hTable, 4, 10, &tc); tc.pszText = _T("top center"); tc.dwFlags = MC_TCF_ALIGNCENTER | MC_TCF_ALIGNTOP; mcTable_SetCell(hTable, 5, 10, &tc); tc.pszText = _T("top right"); tc.dwFlags = MC_TCF_ALIGNRIGHT | MC_TCF_ALIGNTOP; mcTable_SetCell(hTable, 6, 10, &tc); tc.pszText = _T("middle left"); tc.dwFlags = MC_TCF_ALIGNLEFT | MC_TCF_ALIGNVCENTER; mcTable_SetCell(hTable, 4, 11, &tc); tc.pszText = _T("middle center"); tc.dwFlags = MC_TCF_ALIGNCENTER | MC_TCF_ALIGNVCENTER; mcTable_SetCell(hTable, 5, 11, &tc); tc.pszText = _T("middle right"); tc.dwFlags = MC_TCF_ALIGNRIGHT | MC_TCF_ALIGNVCENTER; mcTable_SetCell(hTable, 6, 11, &tc); tc.pszText = _T("bottom left"); tc.dwFlags = MC_TCF_ALIGNLEFT | MC_TCF_ALIGNBOTTOM; mcTable_SetCell(hTable, 4, 12, &tc); tc.pszText = _T("bottom center"); tc.dwFlags = MC_TCF_ALIGNCENTER | MC_TCF_ALIGNBOTTOM; mcTable_SetCell(hTable, 5, 12, &tc); tc.pszText = _T("bottom right"); tc.dwFlags = MC_TCF_ALIGNRIGHT | MC_TCF_ALIGNBOTTOM; mcTable_SetCell(hTable, 6, 12, &tc); /* Set heights of few rows to a different value. */ height = LOWORD(SendMessage(hwndGrid, MC_GM_GETROWHEIGHT, 10, 0)); height *= 2; SendMessage(hwndGrid, MC_GM_SETROWHEIGHT, 10, MAKEWPARAM(height, 0)); SendMessage(hwndGrid, MC_GM_SETROWHEIGHT, 11, MAKEWPARAM(height, 0)); SendMessage(hwndGrid, MC_GM_SETROWHEIGHT, 12, MAKEWPARAM(height, 0)); }
/* Loads some values into the table. Some cells are filled via grid control, * some are set directly through table model API after we get a pointer to * the table from the grid control. */ static void LoadGrid(void) { int row; HICON hIcon; MC_HTABLE hTable; MC_TABLECELL tc; /* Set size of the table to 8 columns and 16 rows. */ SendMessage(hwndGrid, MC_GM_RESIZE, MAKEWPARAM(8, 16), 0); /* Setup first column which serves as row headers. This is due the style * MC_GS_ROWHEADERCUSTOM. */ for(row = 0; row < 16; row++) { TCHAR buffer[32]; _stprintf_s(buffer, 32, _T("Row %d"), row); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(0, row), (LPARAM) mcValue_CreateString(buffer)); } /* Setup few cells and show that the table can contain various kinds * of data. */ SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(1, 0), (LPARAM) mcValue_CreateImmString(_T("imm string"))); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(1, 1), (LPARAM) mcValue_CreateString(_T("string"))); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(1, 2), (LPARAM) mcValue_CreateColor(RGB(200, 0, 0))); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(2, 2), (LPARAM) mcValue_CreateColor(RGB(0, 200, 0))); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(3, 2), (LPARAM) mcValue_CreateColor(RGB(0, 0, 200))); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(1, 3), (LPARAM) mcValue_CreateInt32(42)); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(1, 4), (LPARAM) mcValue_CreateImmString(_T("This is very long string " "which does not fit in the cell."))); hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_BEAR), IMAGE_ICON, 0, 0, LR_SHARED); SendMessage(hwndGrid, MC_GM_SETVALUE, MAKEWPARAM(6, 14), (LPARAM) mcValue_CreateIcon(hIcon)); /* We can also get the data model of the grid control and manipulate it * directly. */ hTable = (MC_HTABLE) SendMessage(hwndGrid, MC_GM_GETTABLE, 0, 0); tc.fMask = MC_TCMF_VALUE | MC_TCMF_FLAGS; tc.hValue = mcValue_CreateImmString(_T("top left")); tc.dwFlags = MC_TCF_ALIGNLEFT | MC_TCF_ALIGNTOP; mcTable_SetCell(hTable, 4, 6, &tc); tc.hValue = mcValue_CreateImmString(_T("top center")); tc.dwFlags = MC_TCF_ALIGNCENTER | MC_TCF_ALIGNTOP; mcTable_SetCell(hTable, 5, 6, &tc); tc.hValue = mcValue_CreateImmString(_T("top right")); tc.dwFlags = MC_TCF_ALIGNRIGHT | MC_TCF_ALIGNTOP; mcTable_SetCell(hTable, 6, 6, &tc); tc.hValue = mcValue_CreateImmString(_T("middle left")); tc.dwFlags = MC_TCF_ALIGNLEFT | MC_TCF_ALIGNVCENTER; mcTable_SetCell(hTable, 4, 7, &tc); tc.hValue = mcValue_CreateImmString(_T("middle center")); tc.dwFlags = MC_TCF_ALIGNCENTER | MC_TCF_ALIGNVCENTER; mcTable_SetCell(hTable, 5, 7, &tc); tc.hValue = mcValue_CreateImmString(_T("middle right")); tc.dwFlags = MC_TCF_ALIGNRIGHT | MC_TCF_ALIGNVCENTER; mcTable_SetCell(hTable, 6, 7, &tc); tc.hValue = mcValue_CreateImmString(_T("bottom left")); tc.dwFlags = MC_TCF_ALIGNLEFT | MC_TCF_ALIGNBOTTOM; mcTable_SetCell(hTable, 4, 8, &tc); tc.hValue = mcValue_CreateImmString(_T("bottom center")); tc.dwFlags = MC_TCF_ALIGNCENTER | MC_TCF_ALIGNBOTTOM; mcTable_SetCell(hTable, 5, 8, &tc); tc.hValue = mcValue_CreateImmString(_T("bottom right")); tc.dwFlags = MC_TCF_ALIGNRIGHT | MC_TCF_ALIGNBOTTOM; mcTable_SetCell(hTable, 6, 8, &tc); }