Multiline Read only Edit

This is a discussion on Multiline Read only Edit within the Windows Programming forums, part of the Platform Specific Boards category; I got a problem with a multiline read only edit control. I use lcc-win32 as ide and placed a multiline ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    8

    Question Multiline Read only Edit

    I got a problem with a multiline read only edit control. I use lcc-win32 as ide and placed a multiline edit control on a dialog. The edit control is set to read only and I create the white background with:

    Code:
    //--------------------------------------------
    // Set background white of read only edits
    //--------------------------------------------
    case WM_CTLCOLORSTATIC:
    
    if (IDC_TXTEMAIL == GetDlgCtrlID((HWND)lParam))
    {
           SetTextColor((HDC)wParam, RGB(0, 0, 0));
           SetBkMode((HDC)wParam, TRANSPARENT);
           return (LRESULT)GetStockObject(WHITE
    }
    break;
    This works ok. But the problem starts when I use the scrollbars to move the edit box horizontal en vertical. Because of the colorstatic event the text gets mangled and therefore I use

    Code:
    InvalidateRect(GetDlgItem(hwndDlg, IDC_TXTEMAIL), NULL, TRUE);
    In the WM_COMMAND section of the dialog handler. When the edit control gets a EN_VSCROLL or EN_HSCROLL I make a call to invalidaterect and the scrolling looks ok. This only works when I move around in the edit with the cursor. So I need to invalidaterect when the scrollbars are moved. First I tried catching WM_VSCROLL and WM_HSCROLL messages in the dialog handler. But these events don't get triggered. After that I subclassed the edit control and catch WM_VSCROLL and WM_HSCROLL messages.

    It almost works now but the text still gets mangled in the edit on the last (if I scroll down) or the first line (if I scroll up) with the scrollbars. When I release the scrollbar/mouse everything looks ok (because of the SB_ENDSCROLL trigger). I also tried calling UpdateWindow right after InvalidateRect but this gives the same result.

    Is there anyone who can tell me how I can prevent the first/last line scrambled text in this case when I scroll up or down (and a little left to right).

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It looks like you may be overcomplicating things. Remove the SetBkMode call in the WM_CTLCOLORSTATIC handler as the transparency is probably responsible for the text overwriting on scrolling; the background is painted by the returned brush and will be unaffected by the back mode.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    8
    Thank you very much Ken that was indeed causing the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating an Edit Box (Subclassing)
    By csonx_p in forum Windows Programming
    Replies: 9
    Last Post: 05-05-2008, 06:36 AM
  2. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 06:58 AM
  3. Buttons + Edit Control
    By jay kay in forum Windows Programming
    Replies: 6
    Last Post: 03-09-2005, 04:36 PM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. Difficulty superclassing EDIT window class
    By cDir in forum Windows Programming
    Replies: 7
    Last Post: 02-21-2002, 04:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21