// TODO: Add extra initialization here
// { CString s;
m_grid.SetRows(20);
m_grid.SetCols(11);
for (int a=0;a<20;a++) {
for (int b=0;b<11;b++) {
s.Format("Row %d, Col %d",a,b);
m_grid.SetTextMatrix(a,b,s);
}
}
m_grid.SetRow(1);
for (a=1;a<11;a++) { static long
color[]={0x00ff0000,0x0000ff00,0x000000ff,0x00cc00ff,0x0000ccff,0x00ffffcc,0x002000aa,0x00ffccff,0x0020aab0,0x00b53589};
m_grid.SetCol(a);
m_grid.SetCellBackColor(color[a-1]);
m_grid.SetCellForeColor(color[10-a]);
}
// }
return TRUE; // return TRUE unless you set the focus to a control
}
CGridExDlg::CGridExDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGridExDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGridExDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// { m_crFore = RGB(0,0,0); m_crBack = RGB(255,255,255);
// }
}
BEGIN_MESSAGE_MAP(CGridExDlg, CDialog)
//{{AFX_MSG_MAP(CGridExDlg)
...
ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_CELLFORECOLOR, OnCellforecolor) ON_BN_CLICKED(IDC_CELLBACKCOLOR, OnCellbackcolor) ON_BN_CLICKED(IDC_TEXT, OnText) ON_BN_CLICKED(IDC_FLOAT, OnFloat) ON_BN_CLICKED(IDC_MERGECOL, OnMergecol) ON_BN_CLICKED(IDC_MERGEROW, OnMergerow) ON_BN_CLICKED(IDC_BITMAP, OnBitmap) ON_BN_CLICKED(IDC_ICON1, OnIcon1) ON_WM_CLOSE() ON_BN_CLICKED(IDC_FORECOLOR, OnForecolor) ON_BN_CLICKED(IDC_BACKCOLOR, OnBackcolor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
...
BOOL CGridExDlg::OnInitDialog()
{
...
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
// { InitializeGrid();
// }
return TRUE; // return TRUE unless you set the focus to a control
}
... BOOL CGridExDlg::InitializeGrid() { m_FlexGrid.SetCols(8); m_FlexGrid.SetRows(1);
for(int i = 1; i <= 10; i++) m_FlexGrid.AddItem(i);
return TRUE; }
void CGridExDlg::OnCellforecolor() { // TODO: Add your control notification handler code here UINT rt = IsDlgButtonChecked( IDC_CELLFORECOLOR ); if (rt == 0) { m_crFore = RGB(0,0,0); } else { m_crFore = RGB(0,255,0);; } }
void CGridExDlg::OnCellbackcolor() { // TODO: Add your control notification handler code here UINT rt = IsDlgButtonChecked( IDC_CELLBACKCOLOR ); if (rt == 0) { m_crBack = RGB(255,255,255); } else { m_crBack = RGB(255,0,0); } }
void CGridExDlg::OnText() { // TODO: Add your control notification handler code here m_FlexGrid.SetCellForeColor(m_crFore); m_FlexGrid.SetCellBackColor(m_crBack); m_FlexGrid.SetText("텍스트"); }
void CGridExDlg::OnFloat() { // TODO: Add your control notification handler code here m_FlexGrid.SetCellForeColor(m_crFore); m_FlexGrid.SetCellBackColor(m_crBack); m_FlexGrid.SetText(200); }
void CGridExDlg::OnMergecol() { // TODO: Add your control notification handler code here m_FlexGrid.SetTextMatrix(1,1,"텍스트"); m_FlexGrid.SetTextMatrix(1,2,"텍스트"); m_FlexGrid.SetTextMatrix(1,3,"텍스트");