问题描述:
Excel2007自动化程序打开文档时,会有鼠标无法点进文档进行编辑的情况出现。而Excel2010没有这样的问题。
解决办法:
double dVersion = _ttof(m_ipExcelApp->GetVersion());
m_ipExcelApp->PutVisible(1, VARIANT_TRUE);//在SetParent之前显示文档
HWND hwnd = ::SetParent(m_hwndExcel, GetSafeHwnd());
if (hwnd == NULL)
{
return false;
}
CRect rcBound;
GetClientRect(&rcBound);
//隐藏标题栏
long lStyle = GetWindowLong(m_hwndExcel, GWL_STYLE);
lStyle &= ~WS_CAPTION;
//lStyle &= ~WS_CHILD;
SetWindowLong(m_hwndExcel, GWL_STYLE, lStyle);
::SetWindowPos(m_hwndExcel, GetSafeHwnd(), 0, 0, rcBound.Width(), rcBound.Height(), SWP_NOZORDER | SWP_NOMOVE | SWP_DRAWFRAME | SWP_NOSIZE);
::MoveWindow(m_hwndExcel, rcBound.left, rcBound.top, rcBound.Width(), rcBound.Height()+20, TRUE);