[英]Keep a thread running in a modal dialog c++ mfc
所以我通過DoModal()
從我的主對話框打開一個模態對話框我應該把我的線程 function 放在哪里讓它保持活力,我可以把它放在構造函數中嗎? (創建的對話框在我的主對話框中沒有像OnInitDialog()
那樣的任何 function)
您可以使用 AfxBeginThread 啟動線程https://docs.microsoft.com/en-us/cpp/mfc/reference/cwinthread-class?view=vs-2019並將其放入 oninitdialog 之類的
BOOL CSimpleDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here, like AfxBeginThread
m_cMyEdit.SetWindowText(_T("My Name")); // Initialize control values
m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc.
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
https://docs.microsoft.com/en-us/cpp/mfc/reference/cdialog-class?view=vs-2019#oninitdialog
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.