Note that there are some explanatory texts on larger screens.

plurals
  1. POMFC CEdit passing pParentWnd
    primarykey
    data
    text
    <p>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).</p> <p>I'm trying to get the text to work out. In the main View class I have:</p> <pre><code>void CSpreadView::OnInsertText() { CEdit* pEdit = new CEdit; CWnd* pParentWnd = this; grid.CellType(pEdit, pParentWnd); Invalidate(); UpdateWindow(); } </code></pre> <p>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.</p> <p>So the function that receives it:</p> <pre><code>void Grid::CellType(CEdit* pEdit, CWnd* pParentWnd) { for (int a=0; a&lt;(int) cells.size(); a++) { if(cells[a]-&gt;selected) cells[a]-&gt;Type(pEdit, pParentWnd); } } </code></pre> <p>Finally, when the cell is drawn it does:</p> <pre><code>if(type=="text") { CEdit* pEdit = new CEdit; pEdit-&gt;Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(x1+10, y1+10, x2-10, y2-10), pParentWnd, 1); } </code></pre> <p>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?</p> <p>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:</p> <pre><code>CBrush brush(RGB(color, color, color)); pDC-&gt;SelectObject(&amp;brush); pDC-&gt;Rectangle(x1, y1, x2, y2); </code></pre> <p>This is what I see: <img src="https://i.stack.imgur.com/sRk9i.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload