CDialogBar simple question - Programmer

This is a discussion on CDialogBar simple question - Programmer ; It was so much easier in DOS days............... CMainWin::CMainWin() { Create(NULL,"My Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu"); //so far so good m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT); // my dialog bar actually appears! A miracle at last! there is an edit box IDE_VOLTS and all I want to do ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: CDialogBar simple question

  1. CDialogBar simple question

    It was so much easier in DOS days...............


    CMainWin::CMainWin()
    {
    Create(NULL,"My Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");

    //so far so good

    m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    // my dialog bar actually appears! A miracle at last!

    there is an edit box IDE_VOLTS and all I want to do is put text into it.
    (And read it
    when I want to. DDX no needed, so should be simpler. Do I need to define a
    class
    for the CDialogBar to access its controls?
    I have and , anything else I need? Have I set up the rc
    file correctly?
    Have I any hair left to tear out?
    I've looked all over the place and tried everything that looks likely, but
    no luck - surely
    I should be able to grab the handle and read or write to the textbox any
    time I need to?
    Help would be greatly appreciated at this juncture, I know I'm being dumb
    :>)

    Steve Ralph

    // Main window class
    CMainWin();

    CDialogBar m_wndDlgBar;

    DECLARE_MESSAGE_MAP()
    };

    rc file

    IDD_VIEWSELECT DIALOG DISCARDABLE 0,0,80,40
    STYLE WS_CHILD
    {

    GROUPBOX "Device Parameters", IDGB_PARAMS, 0, 180,70,100,WS_VISIBLE

    CTEXT "Vb ", IDCT_1, 5,192, 20, 12, WS_DISABLED | WS_CHILD |
    WS_TABSTOP|WS_BORDER|SS_CENTER
    EDITTEXT IDE_VOLTS, 34, 190, 30, 12, WS_VISIBLE | WS_CHILD | WS_TABSTOP |
    ES_AUTOHSCROLL

    }



  2. Re: CDialogBar simple question


    They are an absolute pain these things. All I want is some simple controls.
    I think I'll just put them straight on the window, at least I know that
    works.


    > It was so much easier in DOS days...............
    >
    >
    > CMainWin::CMainWin()
    > {
    > Create(NULL,"My

    Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");
    >
    > //so far so good
    >
    > m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    > // my dialog bar actually appears! A miracle at last!
    >
    > there is an edit box IDE_VOLTS and all I want to do is put text into it.
    > (And read it
    > when I want to. DDX no needed, so should be simpler. Do I need to define a
    > class
    > for the CDialogBar to access its controls?
    > I have and , anything else I need? Have I set up the

    rc
    > file correctly?
    > Have I any hair left to tear out?
    > I've looked all over the place and tried everything that looks likely, but
    > no luck - surely
    > I should be able to grab the handle and read or write to the textbox any
    > time I need to?
    > Help would be greatly appreciated at this juncture, I know I'm being dumb
    > :>)
    >
    > Steve Ralph
    >
    > // Main window class
    > CMainWin();
    >
    > CDialogBar m_wndDlgBar;
    >
    > DECLARE_MESSAGE_MAP()
    > };
    >
    > rc file
    >
    > IDD_VIEWSELECT DIALOG DISCARDABLE 0,0,80,40
    > STYLE WS_CHILD
    > {
    >
    > GROUPBOX "Device Parameters", IDGB_PARAMS, 0, 180,70,100,WS_VISIBLE
    >
    > CTEXT "Vb ", IDCT_1, 5,192, 20, 12, WS_DISABLED | WS_CHILD |
    > WS_TABSTOP|WS_BORDER|SS_CENTER
    > EDITTEXT IDE_VOLTS, 34, 190, 30, 12, WS_VISIBLE | WS_CHILD | WS_TABSTOP |
    > ES_AUTOHSCROLL
    >
    > }
    >
    >




  3. Re: CDialogBar simple question

    Steve Ralph wrote:
    > It was so much easier in DOS days...............
    >
    >
    > CMainWin::CMainWin()
    > {
    > Create(NULL,"My Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");
    >
    > //so far so good
    >
    > m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    > // my dialog bar actually appears! A miracle at last!
    >
    > there is an edit box IDE_VOLTS and all I want to do is put text into it.
    > (And read it
    > when I want to. DDX no needed, so should be simpler. Do I need to define a
    > class
    > for the CDialogBar to access its controls?
    > I have and , anything else I need? Have I set up the rc
    > file correctly?
    > Have I any hair left to tear out?
    > I've looked all over the place and tried everything that looks likely, but
    > no luck - surely
    > I should be able to grab the handle and read or write to the textbox any
    > time I need to?
    > Help would be greatly appreciated at this juncture, I know I'm being dumb
    > :>)


    It's not clear exactly what your problem is. What is failing, with what
    result?

    You could define a class for the dialog bar and put control member
    variables in it. Or, you could do this from within CMainWin:

    CEdit* pEdit = (CEdit*)m_wndDlgBar.GetDlgItem(IDE_VOLTS);
    pEdit->SetWindowText("It was so much easier in DOS days");

    This is standard usage of GetDlgItem. It searches the child controls of
    the parent (m_wndDlgBar) and returns a CWnd* to the control.

    --
    Scott McPhillips [VC++ MVP]


  4. Re: CDialogBar simple question


    "Scott McPhillips [MVP]" wrote in message
    news:r5KdnaLL58qeMieiRVn-jg@comcast.com...
    > Steve Ralph wrote:
    > > It was so much easier in DOS days...............
    > >
    > >
    > > CMainWin::CMainWin()
    > > {
    > > Create(NULL,"My

    Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");
    > >
    > > //so far so good
    > >
    > > m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    > > // my dialog bar actually appears! A miracle at last!
    > >
    > > there is an edit box IDE_VOLTS and all I want to do is put text into it.
    > > (And read it
    > > when I want to. DDX no needed, so should be simpler. Do I need to define

    a
    > > class
    > > for the CDialogBar to access its controls?
    > > I have and , anything else I need? Have I set up

    the rc
    > > file correctly?
    > > Have I any hair left to tear out?
    > > I've looked all over the place and tried everything that looks likely,

    but
    > > no luck - surely
    > > I should be able to grab the handle and read or write to the textbox any
    > > time I need to?
    > > Help would be greatly appreciated at this juncture, I know I'm being

    dumb
    > > :>)

    >
    > It's not clear exactly what your problem is. What is failing, with what
    > result?
    >
    > You could define a class for the dialog bar and put control member
    > variables in it. Or, you could do this from within CMainWin:



    > CEdit* pEdit = (CEdit*)m_wndDlgBar.GetDlgItem(IDE_VOLTS);
    > pEdit->SetWindowText("It was so much easier in DOS days");
    >
    > This is standard usage of GetDlgItem. It searches the child controls of
    > the parent (m_wndDlgBar) and returns a CWnd* to the control.
    >

    CMainWin::CMainWin()
    {
    Create(NULL,"My Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");

    // this gives mw no problem
    Check1.Create("hi",WS_VISIBLE|BS_AUTOCHECKBOX,CRect(160,160,250,250) ,this,ID
    _CHECK1);


    m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    CEdit* b = (CEdit*)GetDlgItem(IDE_VOLTS);
    // so far so good
    SetWindowText("hello");
    //but this causes a failed assertion

    I haven't actually set up a dialog class, and maybe I need to create it
    inside
    onCreate rather than here
    Thanks, MFC is a fastt track to insanity I am beginning to think :>)

    Steve Ralph

    > Scott McPhillips [VC++ MVP]
    >




  5. Re: CDialogBar simple question

    Steve Ralph wrote:
    >>CEdit* pEdit = (CEdit*)m_wndDlgBar.GetDlgItem(IDE_VOLTS);
    >>pEdit->SetWindowText("It was so much easier in DOS days");
    >>
    >>This is standard usage of GetDlgItem. It searches the child controls of
    >>the parent (m_wndDlgBar) and returns a CWnd* to the control.
    >>

    >
    > CMainWin::CMainWin()
    > {
    > Create(NULL,"My Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");
    >
    > // this gives mw no problem
    > Check1.Create("hi",WS_VISIBLE|BS_AUTOCHECKBOX,CRect(160,160,250,250) ,this,ID
    > _CHECK1);
    >
    >
    > m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    > CEdit* b = (CEdit*)GetDlgItem(IDE_VOLTS);
    > // so far so good
    > SetWindowText("hello");
    > //but this causes a failed assertion
    >
    > I haven't actually set up a dialog class, and maybe I need to create it
    > inside
    > onCreate rather than here
    > Thanks, MFC is a fastt track to insanity I am beginning to think :>)
    >
    > Steve Ralph



    Highly confused, you are. You're calling the GetDlgItem and
    SetWindowText functions of CMainWin.

    // wrong window
    CEdit* b = (CEdit*)GetDlgItem(IDE_VOLTS);
    // right window
    CEdit* pEdit = (CEdit*)m_wndDlgBar.GetDlgItem(IDE_VOLTS);


    --
    Scott McPhillips [VC++ MVP]


  6. Re: CDialogBar simple question


    "Scott McPhillips [MVP]" wrote in message
    newssKdne9KvL_2wiaiRVn-jw@comcast.com...
    > Steve Ralph wrote:
    > >>CEdit* pEdit = (CEdit*)m_wndDlgBar.GetDlgItem(IDE_VOLTS);
    > >>pEdit->SetWindowText("It was so much easier in DOS days");
    > >>
    > >>This is standard usage of GetDlgItem. It searches the child controls of
    > >>the parent (m_wndDlgBar) and returns a CWnd* to the control.
    > >>

    > >
    > > CMainWin::CMainWin()
    > > {
    > > Create(NULL,"My

    Balls-up",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"MainMenu");
    > >
    > > // this gives mw no problem
    > >

    Check1.Create("hi",WS_VISIBLE|BS_AUTOCHECKBOX,CRect(160,160,250,250) ,this,ID
    > > _CHECK1);
    > >
    > >
    > > m_wndDlgBar.Create(this,IDD_VIEWSELECT,CBRS_LEFT,I DD_VIEWSELECT);
    > > CEdit* b = (CEdit*)GetDlgItem(IDE_VOLTS);
    > > // so far so good
    > > SetWindowText("hello");
    > > //but this causes a failed assertion
    > >
    > > I haven't actually set up a dialog class, and maybe I need to create it
    > > inside
    > > onCreate rather than here
    > > Thanks, MFC is a fastt track to insanity I am beginning to think :>)
    > >
    > > Steve Ralph

    >
    >
    > Highly confused, you are. You're calling the GetDlgItem and
    > SetWindowText functions of CMainWin.
    >
    > // wrong window
    > CEdit* b = (CEdit*)GetDlgItem(IDE_VOLTS);
    > // right window
    > CEdit* pEdit = (CEdit*)m_wndDlgBar.GetDlgItem(IDE_VOLTS);
    >

    Ah.
    Yes.
    Beat myself over head with programming book
    Confused I was! Now no longer thanx to Scott!

    Steve Ralph
    > --
    > Scott McPhillips [VC++ MVP]
    >




+ Reply to Thread