Hi,
I've created a listbox in a dialog, now when I select a button another dialog pops up which has textbox that I'd like to load the column text value into.
The issue I'm having is accessing that listbox, so far I've created a static CString function on the first dialog class that I can access from second dialog class. However I'm not sure how to proceed in accessing the control.
Any recommendations would be greatly appreciated,
Regards Hayden
Dialog 1 Header file
Dialog 1 CPP fileCode:#if !defined(AFX_CHECKLCDEMODLG_H__8F9BBED5_8C3E_447A_ADF4_C4E47DCEC10D__INCLUDED_) #define AFX_CHECKLCDEMODLG_H__8F9BBED5_8C3E_447A_ADF4_C4E47DCEC10D__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "LCZoomDlg.h" #include <string> ///////////////////////////////////////////////////////////////////////////// // CCheckLCDemoDlg dialog class CCheckLCDemoDlg : public CDialog { // Construction public: CCheckLCDemoDlg(CWnd* pParent = NULL); // standard constructor static CString GetZoomLevels(); // Dialog Data //{{AFX_DATA(CCheckLCDemoDlg) enum { IDD = IDD_CHECKLCDEMO_DIALOG }; CCheckListCtrl m_listCtrl; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CCheckLCDemoDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Operations private: CImageList m_checkLCImgList; // Implementation protected: // Generated message map functions //{{AFX_MSG(CCheckLCDemoDlg) virtual BOOL OnInitDialog(); afx_msg void EditZoomLevels(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif
And a small piece of Dialog 2 CPP file.Code:CCheckLCDemoDlg::CCheckLCDemoDlg(CWnd* pParent /*=NULL*/) : CDialog(CCheckLCDemoDlg::IDD, pParent) { //{{AFX_DATA_INIT(CCheckLCDemoDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CCheckLCDemoDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCheckLCDemoDlg) DDX_Control(pDX, IDC_LIST1, m_listCtrl); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCheckLCDemoDlg, CDialog) //{{AFX_MSG_MAP(CCheckLCDemoDlg) ON_BN_CLICKED(IDC_ZOOM, EditZoomLevels) ON_BN_CLICKED(IDC_LABEL, EditLabels) //}}AFX_MSG_MAP END_MESSAGE_MAP() /////////////////////////////////////////////////////// // CCheckLCDemoDlg message handlers BOOL CCheckLCDemoDlg::OnInitDialog() { CDialog::OnInitDialog(); return TRUE; } void CCheckLCDemoDlg::EditZoomLevels() { CLCZoomDlg dlgZoom; dlgZoom.DoModal(); } CString CCheckLCDemoDlg::GetZoomLevels() { //***********IN HERE I WOULD LIKE TO ACCESS THE LIST CTRL SOMEHOW ******** return "some value"; }
Code:BOOL CLCZoomDlg::OnInitDialog() { CDialog::OnInitDialog(); CString newtext = CCheckLCDemoDlg::GetZoomLevels(); //Update textbox m_edit_zoom_low = newtext; UpdateData(FALSE); return TRUE; }




Reply With Quote