Dialog Edit box updating - Programmer

This is a discussion on Dialog Edit box updating - Programmer ; I have searched the website and have figured out how to do some things I have been stuggling on but would like some help on a few things. But I will take it one step at a time. First, the ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Dialog Edit box updating

  1. Dialog Edit box updating

    I have searched the website and have figured out how to do some things
    I have been stuggling on but would like some help on a few things.
    But I will take it one step at a time.

    First, the easy one: I have a slider that I am using to control the
    intensity of lights and I want the user to see the value as they
    adjust it so they know how many milliamps they are at. So I have a
    text box that I wish to update with the current value as the user
    moves the slider. So my problem is that the text box does not update
    unless I actually select in the text box. Here is some of my code to
    help you understand the problem.

    void CTlc_winDlg::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT*
    pResult)
    {
    nIntensity = intensity.GetPos (); //get value from slider
    m_slide_val.Format ("Intensity: %d", nIntensity);
    SetDlgItemText (IDC_EDIT1, m_slide_val); // change text in window
    *pResult = 0;
    }

    void CTlc_winDlg::OnUpdateEdit()
    {
    //after value is changed the software does come here but not sure how
    to update the screen
    }

    Right now what happens is: I move the slider and the value in the text
    box does not change. I select in the box with my mouse and the value
    updates. How do I get it to update without having to select inside
    the text box?

    Thanks for any help you can give!

    S

  2. Re: Dialog Edit box updating

    Hello
    "Scott" schrieb im Newsbeitrag
    news:fbb76955.0407221448.23db4d8a@posting.google.c om...
    > I have searched the website and have figured out how to do some things
    > I have been stuggling on but would like some help on a few things.
    > But I will take it one step at a time.
    >
    > First, the easy one: I have a slider that I am using to control the
    > intensity of lights and I want the user to see the value as they
    > adjust it so they know how many milliamps they are at. So I have a
    > text box that I wish to update with the current value as the user
    > moves the slider. So my problem is that the text box does not update
    > unless I actually select in the text box. Here is some of my code to
    > help you understand the problem.
    >
    > void CTlc_winDlg::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT*
    > pResult)
    > {
    > nIntensity = intensity.GetPos (); //get value from slider
    > m_slide_val.Format ("Intensity: %d", nIntensity);
    > SetDlgItemText (IDC_EDIT1, m_slide_val); // change text in window
    > *pResult = 0;
    > }
    >
    > void CTlc_winDlg::OnUpdateEdit()
    > {
    > //after value is changed the software does come here but not sure how
    > to update the screen
    > }
    >
    > Right now what happens is: I move the slider and the value in the text
    > box does not change. I select in the box with my mouse and the value
    > updates. How do I get it to update without having to select inside
    > the text box?
    >
    > Thanks for any help you can give!
    >
    > S


    OnReleasedcaptureSlider will update your edit control only if you release
    the mouse button from the slider. To continually show the slider changes
    you can implement OnHScroll like the following code:

    void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    {
    if(nSBCode==8)
    return;
    if((CWnd *)pScrollBar==(CWnd *)&m_Slider)
    {
    int i=m_Slider.GetPos();
    CString sTmp;
    sTmp.Format("Slider=%d",i);
    SetDlgItemText (IDC_EDIT_SHOW,sTmp);
    }
    CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
    }

    Hope this helps.
    Roland



  3. Re: Dialog Edit box updating

    "Roland Wunderer" wrote in message news:...
    > Hello
    > "Scott" schrieb im Newsbeitrag
    > news:fbb76955.0407221448.23db4d8a@posting.google.c om...
    > > I have searched the website and have figured out how to do some things
    > > I have been stuggling on but would like some help on a few things.
    > > But I will take it one step at a time.
    > >
    > > First, the easy one: I have a slider that I am using to control the
    > > intensity of lights and I want the user to see the value as they
    > > adjust it so they know how many milliamps they are at. So I have a
    > > text box that I wish to update with the current value as the user
    > > moves the slider. So my problem is that the text box does not update
    > > unless I actually select in the text box. Here is some of my code to
    > > help you understand the problem.
    > >
    > > void CTlc_winDlg::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT*
    > > pResult)
    > > {
    > > nIntensity = intensity.GetPos (); //get value from slider
    > > m_slide_val.Format ("Intensity: %d", nIntensity);
    > > SetDlgItemText (IDC_EDIT1, m_slide_val); // change text in window
    > > *pResult = 0;
    > > }
    > >
    > > void CTlc_winDlg::OnUpdateEdit()
    > > {
    > > //after value is changed the software does come here but not sure how
    > > to update the screen
    > > }
    > >
    > > Right now what happens is: I move the slider and the value in the text
    > > box does not change. I select in the box with my mouse and the value
    > > updates. How do I get it to update without having to select inside
    > > the text box?
    > >
    > > Thanks for any help you can give!
    > >
    > > S

    >
    > OnReleasedcaptureSlider will update your edit control only if you release
    > the mouse button from the slider. To continually show the slider changes
    > you can implement OnHScroll like the following code:
    >
    > void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    > {
    > if(nSBCode==8)
    > return;
    > if((CWnd *)pScrollBar==(CWnd *)&m_Slider)
    > {
    > int i=m_Slider.GetPos();
    > CString sTmp;
    > sTmp.Format("Slider=%d",i);
    > SetDlgItemText (IDC_EDIT_SHOW,sTmp);
    > }
    > CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
    > }
    >
    > Hope this helps.
    > Roland


    Actually, I already knew that I had to release the mouse for it to
    display. Maybe I didn't phrase my Q in the correct way.

    What I want to happen is this:
    - (I move the slider and release it)
    - Slider value is formated and stored into "m_slide_val"
    - The formatted "m_slide_val" text is then set to the text box
    - New value is shown in textbox on screen

    The problem is that the last step does not occur. The value is set by
    "SetDlgItemText" but is never actually visible on the screen unless I
    click with the mouse into the text box (NOT the slider box). For some
    reason it updates the screen when I do that. (selecting within the
    text box should not relate to "OnReleasedcaptureSlider1" ... I know
    that "OnReleasedcaptureSlider1" is called when I release the slider
    but it is not called when I select within an edit box) So really what
    my problem is that the edit box does not update when I call
    "SetDlgItemText" method.

    S

  4. Re: Dialog Edit box updating


    "Scott" schrieb im Newsbeitrag
    news:fbb76955.0407230923.67fb5c70@posting.google.c om...
    > "Roland Wunderer" wrote in message

    news:...
    > > Hello
    > > "Scott" schrieb im Newsbeitrag
    > > news:fbb76955.0407221448.23db4d8a@posting.google.c om...
    > > > I have searched the website and have figured out how to do some things
    > > > I have been stuggling on but would like some help on a few things.
    > > > But I will take it one step at a time.
    > > >
    > > > First, the easy one: I have a slider that I am using to control the
    > > > intensity of lights and I want the user to see the value as they
    > > > adjust it so they know how many milliamps they are at. So I have a
    > > > text box that I wish to update with the current value as the user
    > > > moves the slider. So my problem is that the text box does not update
    > > > unless I actually select in the text box. Here is some of my code to
    > > > help you understand the problem.
    > > >
    > > > void CTlc_winDlg::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT*
    > > > pResult)
    > > > {
    > > > nIntensity = intensity.GetPos (); //get value from slider
    > > > m_slide_val.Format ("Intensity: %d", nIntensity);
    > > > SetDlgItemText (IDC_EDIT1, m_slide_val); // change text in window
    > > > *pResult = 0;
    > > > }
    > > >
    > > > void CTlc_winDlg::OnUpdateEdit()
    > > > {
    > > > //after value is changed the software does come here but not sure how
    > > > to update the screen
    > > > }
    > > >
    > > > Right now what happens is: I move the slider and the value in the text
    > > > box does not change. I select in the box with my mouse and the value
    > > > updates. How do I get it to update without having to select inside
    > > > the text box?
    > > >
    > > > Thanks for any help you can give!
    > > >
    > > > S

    > >
    > > OnReleasedcaptureSlider will update your edit control only if you

    release
    > > the mouse button from the slider. To continually show the slider changes
    > > you can implement OnHScroll like the following code:
    > >
    > > void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    > > {
    > > if(nSBCode==8)
    > > return;
    > > if((CWnd *)pScrollBar==(CWnd *)&m_Slider)
    > > {
    > > int i=m_Slider.GetPos();
    > > CString sTmp;
    > > sTmp.Format("Slider=%d",i);
    > > SetDlgItemText (IDC_EDIT_SHOW,sTmp);
    > > }
    > > CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
    > > }
    > >
    > > Hope this helps.
    > > Roland

    >
    > Actually, I already knew that I had to release the mouse for it to
    > display. Maybe I didn't phrase my Q in the correct way.
    >
    > What I want to happen is this:
    > - (I move the slider and release it)
    > - Slider value is formated and stored into "m_slide_val"
    > - The formatted "m_slide_val" text is then set to the text box
    > - New value is shown in textbox on screen
    >
    > The problem is that the last step does not occur. The value is set by
    > "SetDlgItemText" but is never actually visible on the screen unless I
    > click with the mouse into the text box (NOT the slider box). For some
    > reason it updates the screen when I do that. (selecting within the
    > text box should not relate to "OnReleasedcaptureSlider1" ... I know
    > that "OnReleasedcaptureSlider1" is called when I release the slider
    > but it is not called when I select within an edit box) So really what
    > my problem is that the edit box does not update when I call
    > "SetDlgItemText" method.
    >
    > S

    What Version of VC do you use? On Win2000 and VC6 SP6 it works well.
    Maybe it helps, when you update the window of the edit control.
    GetDlgItem(...)->InvalidateRect(NULL);
    GetDlgItem(...)->UpdateWindow();
    Another posibility is to bind a variable to the edit control and after
    changing
    the variable do a UpdateData(FALSE).
    Hope it helps
    Roland



  5. Re: Dialog Edit box updating

    > What Version of VC do you use? On Win2000 and VC6 SP6 it works well.
    > Maybe it helps, when you update the window of the edit control.
    > GetDlgItem(...)->InvalidateRect(NULL);
    > GetDlgItem(...)->UpdateWindow();
    > Another posibility is to bind a variable to the edit control and after
    > changing
    > the variable do a UpdateData(FALSE).
    > Hope it helps
    > Roland


    Thanks so much Roland ... that is exactly what I needed to get it to
    work. I am currently doing an internship and want to do a good job so
    they keep me on but they have assigned me to work with MFC (which I
    have never done before). They told me they don't expect me to
    understand it right away but should be able to work through it and
    that is what I have been trying to do ... but sometimes I hit some
    areas where I get lost. I am sure I will be posting some more
    questions the further I go but thanks for your help on this one!

    S

+ Reply to Thread