How do I modify style of edit box in a (already) displayed dialog ? 
Author Message
 How do I modify style of edit box in a (already) displayed dialog ?

I have a list box and some edit boxes in a dialog window. The dialog is
displayed. Now I want to disabled some of my edit boxes when I select
another item in my list box.

I've tried the following:

void CMyDlg::OnSelchangeMylist()
{
    nCurrentCmp = ((CListBox*) GetDlgItem(IDC_CMPLIST))->GetCurSel();
    for (int i = 0; i < NumberOfEditBoxes; i++) {
        if (i < nCurrentCmp) {
            m_pEdit[i].ModifyStyle(0, WS_DISABLED);
            m_pEdit[i].UpdateWindow();
        }
    }

Quote:
}

My question is therefore:

    How do I modify a style of an edit box in a dialog window when dialog is
displayed ?




Tue, 01 Aug 2000 03:00:00 GMT  
 How do I modify style of edit box in a (already) displayed dialog ?

m_pEdit[i]->EnableWindow(FALSE);

Glen Hytoft skrev i meddelelsen ...

Quote:
>I have a list box and some edit boxes in a dialog window. The dialog is
>displayed. Now I want to disabled some of my edit boxes when I select
>another item in my list box.

>I've tried the following:

>void CMyDlg::OnSelchangeMylist()
>{
>    nCurrentCmp = ((CListBox*) GetDlgItem(IDC_CMPLIST))->GetCurSel();
>    for (int i = 0; i < NumberOfEditBoxes; i++) {
>        if (i < nCurrentCmp) {
>            m_pEdit[i].ModifyStyle(0, WS_DISABLED);
>            m_pEdit[i].UpdateWindow();
>        }
>    }
>}

>My question is therefore:

>    How do I modify a style of an edit box in a dialog window when dialog
is
>displayed ?





Tue, 01 Aug 2000 03:00:00 GMT  
 How do I modify style of edit box in a (already) displayed dialog ?

Style bits fall into three categories:
        Those which can be set by SetStyle and which have some
        effect on the control as soon as they are changed.

        Those which control only the creation of the control and are
        ignored thereafter.

        Those which reflect the state of the control as modified by
        some other API function or message, but which have no
        effect if you change them via SetStyle.

Unfortunately, Microsoft does *not* document, for each control, which
is which!  This is a horrible oversight, and has been true for as long
as Windows has existed (like it is a major intellectual challenge to
tell us what is really happening?) It is absolutely absurd that we
have to "experiment" to discover which category a style flag falls
into.

In this case, modifiying the WS_DISABLED flag has no effect on the
control.  You must call EnableWindow(BOOL) to enable or disable a
window.

[In our book I have actually done these experiments for many of the
controls and summarize the results in various tables].
                                        joe



Quote:
>I have a list box and some edit boxes in a dialog window. The dialog is
>displayed. Now I want to disabled some of my edit boxes when I select
>another item in my list box.

>I've tried the following:

>void CMyDlg::OnSelchangeMylist()
>{
>    nCurrentCmp = ((CListBox*) GetDlgItem(IDC_CMPLIST))->GetCurSel();
>    for (int i = 0; i < NumberOfEditBoxes; i++) {
>        if (i < nCurrentCmp) {
>            m_pEdit[i].ModifyStyle(0, WS_DISABLED);
>            m_pEdit[i].UpdateWindow();
>        }
>    }
>}

>My question is therefore:

>    How do I modify a style of an edit box in a dialog window when dialog is
>displayed ?



Joseph M. Newcomer

http://www3.pgh.net/~newcomer


Thu, 03 Aug 2000 03:00:00 GMT  
 How do I modify style of edit box in a (already) displayed dialog ?

If all you want to do is disable the Edit box, code this:
m_pEdit->EnableWindow (FALSE)
This call disables mouse and keyboard input to any CWnd derived object.



Mon, 14 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Modifying style of an edit box

2. Edit boxes - modifying styles at runtime

3. Display a modified print dialog box

4. Display a modified print dialog box

5. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

6. Modify scrollbar style in edit control

7. Modifying Edit Control Styles at Runtime

8. Modifying the Edit Styles of a derived CEdit class

9. Displaying Integers in an Edit Box or List Box

10. Modify List-Box Styles

11. Modifying the Font of an Edit Box

12. Modifying Dialog Style

 

 
Powered by phpBB® Forum Software