編者:李國帥
背景原因:
對話框是PC程式中相當重要的内容,功能不複雜的時候常用用到。
這是一段老舊的代碼,拿出來打個卡。
古老而老生常談的技術,過去的記憶,留在手裡隻會發黴,拿出來也許有人看。
問題描述及期望效果:
打開一個對話框,内容全屏顯示。
所需資源:
Vc,mfc
解決方案:
void CSimpleDlgDlg::OnBnClickedButton1()
{
CDialog* pDlg;
pDlg = this;
//pDlg = m_pDlg;
if(pDlg == NULL)return;
DWORD WinStyle = pDlg->GetStyle();
WINDOWPLACEMENT m_OldWndPlacement;
pDlg->ModifyStyle(WS_CHILD,WS_POPUP);//修改風格
pDlg->GetWindowPlacement(&m_OldWndPlacement); //儲存位置資訊
// 擷取螢幕的分辨率
CRect m_FullScreenRect;
m_FullScreenRect.left= 0;
m_FullScreenRect.top = 0;
m_FullScreenRect.right = ::GetSystemMetrics(SM_CXSCREEN);
m_FullScreenRect.bottom = ::GetSystemMetrics(SM_CYSCREEN);
BOOL m_bFullScreen=TRUE; // 設定全屏顯示标志為 TRUE
// 進入全屏顯示狀态
WINDOWPLACEMENT wndpl;
wndpl.length=sizeof(WINDOWPLACEMENT);
wndpl.flags=0;
wndpl.showCmd=SW_SHOWNORMAL;
wndpl.rcNormalPosition= m_FullScreenRect;
CWnd* _tempparent=pDlg->SetParent(NULL);//修改父視窗
::ShowWindow(_tempparent->m_hWnd,SW_HIDE);
pDlg->SetWindowPlacement(&wndpl);
return ;
} |