2012-11-17 45 views
1

我有一個子對話框。我啓動其他兒童對話。 在第二個對話框中,我有以下列表框代碼。 我需要訪問第一個子對話框中的m_selcomponents。試圖訪問這個像 dlg-> m_selcomponents。但它變得空了。我怎樣才能做到這一點?謝謝你的幫助。從子對話框訪問變量

int count = m_OutList.GetCount(); 

for (i = 0; i <m_OutList.GetCount(); i++) 
    { 
     m_OutList.GetText(buf[i], text); 
     m_selcomponents->Add(text); 

    } 
MSelCFLCompDlg *SelCflCompDlg= new MSelCFLCompDlg(&allcomponents, &m_cflcomponents,m_FileDecimal,this) ; 

如果(SelCflCompDlg->的DoModal()== IDOK){selectedcomponents.Append(* SelCflCompDlg-> m_selcomponents); }

MSelCFLCompDlg::MSelCFLCompDlg(CStringArray *all, CStringArray *sel,int, CWnd* pParent /*=NULL*/) 
    : CDialog(MSelCFLCompDlg::IDD, pParent) 
{ 
    //{{AFX_DATA_INIT(MSelCFLCompDlg) 
     // NOTE: the ClassWizard will add member initialization here 
    //}}AFX_DATA_INIT 
    m_allcomponents = all; 
    m_selcomponents = sel; 

} 

回答

0

當您創建子對話框時,將父對話框的指針傳遞給子對話框的構造函數。如果你向我們展示了更多的代碼,我可以更詳細地解釋一下。

+0

PLZ查看我編輯的問題 – user1783998

+0

謝謝@john。我仍然無法完成這件事。 – user1783998

+0

它現在正在工作。謝謝約翰 – user1783998