void ghdspShowComInfWnd::ShowNormal()
{
ShellExecute(NULL, TEXT("open"), TEXT("notepad.exe"), m_filepath, NULL, SW_SHOWMAXIMIZED);
}
void ShowWindow()
{
CWnd* pBaseWnd = InterfaceMgr::m_pMainFrame;
if (nullptr == pBaseWnd)
{
ShowNormal();
return;
}
CRect rect;
pBaseWnd->GetWindowRect(rect);
int x = rect.left;
int y = rect.top + 10;
int cx = static_cast<int>(rect.Width() * 0.5);
int cy = rect.Height() - 10;
//将数据写入 计算机\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Notepad
do
{
CRegKey regkey;
if (ERROR_SUCCESS != regkey.Create(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Notepad")))
{
break;
}
if (ERROR_SUCCESS != regkey.SetDWORDValue(_T("iWindowPosX"), x))
{
break;
}
if (ERROR_SUCCESS != regkey.SetDWORDValue(_T("iWindowPosY"), y))
{
break;
}
if (ERROR_SUCCESS != regkey.SetDWORDValue(_T("iWindowPosDX"), cx))
{
break;
}
if (ERROR_SUCCESS != regkey.SetDWORDValue(_T("iWindowPosDY"), cy))
{
break;
}
ShellExecute(NULL, TEXT("open"), TEXT("notepad.exe"), m_filepath, NULL, SW_SHOW);
return;
} while (0);
ShowNormal();
}
控制打开的notepad的位置
最新推荐文章于 2024-07-19 23:10:09 发布