CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Threaded View

  1. #1
    Join Date
    Oct 2005
    Posts
    27

    Finding value of control from another dialog

    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
    Code:
     
    #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
    Dialog 1 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";
    }
    And a small piece of Dialog 2 CPP file.
    Code:
     
    BOOL CLCZoomDlg::OnInitDialog()
    {
     CDialog::OnInitDialog();
     CString newtext = CCheckLCDemoDlg::GetZoomLevels();
     //Update textbox
     m_edit_zoom_low = newtext;
     UpdateData(FALSE);
     
     return TRUE;
    }
    Last edited by ill_comms; March 24th, 2009 at 02:13 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured