CComboBox m_ChangeCombo;
CEdit m_Change;
CSring m_sChange;
CMSFlexGrid m_FlexGrid;
void CChartInfoEditDlg::OnClickMsflexgrid()
{
long lRow = m_FlexGrid.GetRowSel;
long lCol = m_FlexGrid.GetColSel();
if(lRow > m_SAttrInfo.attrNum) return;
if(lRow == 0) return;
CRect rect;
m_FlexGrid.GetWindowRect(rect);
ScreenToClient(rect);
CDC* pDC = GetDC();
int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX);
int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY);
long y = m_FlexGrid.GetRowPos(lRow) / nTwipsPerDotY;
long x = m_FlexGrid.GetColPos(lCol) / nTwipsPerDotX;
long width = m_FlexGrid.GetColWidth(lCol) / nTwipsPerDotX+1;
long height = m_FlexGrid.GetRowHeight(lRow) / nTwipsPerDotY+1;
CRect rc(x, y, x + width, y + height);
rc.OffsetRect(rect.left+1,rect.top+1);
m_ChangeCombo.ResetContent( );
CString strValue = m_FlexGrid.GetTextMatrix(lRow, lCol);
int num = m_ChangeCombo.GetCount();
if(num!=0)
{
m_ChangeCombo.ShowWindow(SW_SHOW);
m_ChangeCombo.MoveWindow(rc);
m_ChangeCombo.SelectString(-1, strValue);
m_ChangeCombo.SetFocus();
UpdateData(false);
return;
}
m_Change.ShowWindow(SW_SHOW);
m_Change.SetWindowText(strValue);
m_Change.SetFocus();
m_Change.SetSel(0, -1);
m_Change.MoveWindow(rc);
}
void CChartInfoEditDlg::OnKillfocusEditChange()
{
UpdateData(true);
m_FlexGrid.SetText(m_SChange);
m_Change.ShowWindow(SW_HIDE);
UpdateData(false);
}
void CChartInfoEditDlg::OnKillfocusChangecombo()
{
UpdateData(true);
CString str;
m_ChangeCombo.GetWindowText(str);
m_FlexGrid.SetText(str);
m_ChangeCombo.ShowWindow(SW_HIDE);
UpdateData(false);
}