In VC interface application development, the data display function of the MSFlexGrid control is very beautiful, but if you want to edit it, it is more difficult for the initiator, mainly difficult: 1, inline Edit positioning, 2, embedd Edit Display control. I have written the article on this issue. I have tried two ways here. I would like to use MSFLExGrid to use MSFLExGrid to apply for reference to avoid waste of valuable time to do experiments.
For positioning problems, there are two main points:
1. Inline Edit is a parent window in Dialog or MSFlexGrid.
2. Coordinate system conversion problem, the coordinate system and general controls used by MSFlexGrid, so in operation, it is necessary to convert.
For solutions with MSFLEXGRID, please refer to "Implementation of MSFLEXGRID EDIT, ComboBox" in the VC, which is not wasteful here.
Let me add a solution to Dialog as a parent window:
1, embedded EDIT generation:
M_txtedit.create (WS_CHILD | ES_WANTRETURN, CRECT (0, 0, 0), this, IDC_EDit_Value);
Here, m_txtedit is the CEDIT variable. Indicates that the resource ID is to trigger the EDIT message.
2, position the initial value of the EDIT control:
RECT rect3, rect4; m_txtEdit.GetWindowRect (& rect4); m_msfgCellData.GetWindowRect (& rect3); // m_msfgCellData to MSFlexGrid control m_lTop = rect3.top - rect4.top; m_lLeft = rect3.left - rect4.left;
3, edit box positioning int m_nlogy; int m_nlogx; cdc * pdc = getdc (); m_nlogx = pdc-> getDevicecaps (Logpixelsy); methodcaps (Logpixelsy); ReleaseDC (PDC);
m_txtEdit.MoveWindow (m_lLeft (m_msfgCellData.GetCellLeft () * m_nLogX) / 1440, m_lTop (m_msfgCellData.GetCellTop () * m_nLogY) / 1440, (m_msfgCellData.GetCellWidth () * m_nLogX) / 1440, (m_msfgCellData.GetCellHeight () * m_nlogy) / 1440);
m_txtedit.showWindow (sw_show); m_txtedit.setfocus ();
4, display control
/ / For the LeaveCell event for the MSFlexGrid control
OnleAvecellmsflexGrid () {bool bvisible = :: getWindowlong (m_txtedit.getsafehwnd (), gwl_style) & ws_visible;
IF (bvisible) {cstring cstr; m_txtedit.getWindowText (cstr); m_msfgceldata.settext (cstr); m_txtedit.SetWindowText ("); m_txtedit.showWindow (sw_hide);}}
// Edit's KillFocus message event ON_EN_KILLFOCUS (idc_edit_value, onkillfocusedit) // Resolving if the Resize Grid cannot control EditonkillFocusedit () {OnleAveCellmsflexGridShow ();
// Solve if the scroll cannot control Edit
OnScrollmsflexGridShow () {OnleAvecellmsflexGridshow ();
Let's talk about it, I hope that friends can help.
Email: jiecwj@163.com