I am creating a very very simple spreadsheet type application. It has a grid that draws cells and the user can specify the cell type (text, check box, radio button).
I'm trying to get the text to work out. In the main View class I have:
void CSpreadView::OnInsertText()
{
CEdit* pEdit = new CEdit;
CWnd* pParentWnd = this;
grid.CellType(pEdit, pParentWnd);
Invalidate();
UpdateWindow();
}
I'm passing the parent window because I don't know if there is a way to find the parent window if I'm in another class.
So the function that receives it:
void Grid::CellType(CEdit* pEdit, CWnd* pParentWnd)
{
for (int a=0; a<(int) cells.size(); a++)
{
if(cells[a]->selected)
cells[a]->Type(pEdit, pParentWnd);
}
}
Finally, when the cell is drawn it does:
if(type=="text")
{
CEdit* pEdit = new CEdit;
pEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(x1+10, y1+10, x2-10, y2-10), pParentWnd, 1);
}
The problem: it actually draws the box, however, the text is invisible. When I type it flashes, but when I stop it disappears. Does anyone know why this is happening?
Just so you know, I want the cell to control its type and do the drawing because the user can add/delete rows and columns. That I way I don't need to keep track of what text boxes where previously drawn. The grid is drawn by:
CBrush brush(RGB(color, color, color));
pDC->SelectObject(&brush);
pDC->Rectangle(x1, y1, x2, y2);
This is what I see: