CEdit color & scroll 
Author Message
 CEdit color & scroll

I have a view and create a CEdit inside the view. I encountered two
problems:

1.  Scroll problem.  Why HScroll not show up automatically when the line
is too long?

  m_editCtrl.Create(ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL |
      ES_AUTOVSCROLL | WS_VISIBLE, CRect(0,0,100,100), this,
      IDC_EDIT_CTRL);

2.  OnCtlColor(...)
    nCtlColor  never equals to CTLCOLOR_EDIT, instead equals to
    CTLCOLOR_STATIC.  what happened?

HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
     HBRUSH hbr = CView::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here

    if (nCtlColor==CTLCOLOR_EDIT ||
              pWnd->IsKindOf(RUNTIME_CLASS(CEdit)) )  // I have to add
this line
   {
       pDC->SetBkMode(TRANSPARENT);
       hbr = CreateSolidBrush(RGB(255,255,255));
   }

   // TODO: Return a different brush if the default is not desired

   return hbr;

Quote:
}

------------
Your time and help is highly appreciated.
Daxin


Tue, 20 Mar 2001 03:00:00 GMT  
 CEdit color & scroll
For some reason (unknown to me) read-only edit controls send a
CTLCOLOR_STATIC notification instead of CTLCOLOR_EDIT, which is what they
should. It's annoying, but very easy to fix, as you yourself noticed.

--
Tomas Restrepo

http://www.geocities.com/SiliconValley/Heights/3401


Quote:
>I have a view and create a CEdit inside the view. I encountered two
>problems:

>1.  Scroll problem.  Why HScroll not show up automatically when the line
>is too long?

>  m_editCtrl.Create(ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL |
>      ES_AUTOVSCROLL | WS_VISIBLE, CRect(0,0,100,100), this,
>      IDC_EDIT_CTRL);

>2.  OnCtlColor(...)
>    nCtlColor  never equals to CTLCOLOR_EDIT, instead equals to
>    CTLCOLOR_STATIC.  what happened?

>HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
>     HBRUSH hbr = CView::OnCtlColor(pDC, pWnd, nCtlColor);

>    // TODO: Change any attributes of the DC here

>    if (nCtlColor==CTLCOLOR_EDIT ||
>              pWnd->IsKindOf(RUNTIME_CLASS(CEdit)) )  // I have to add
>this line
>   {
>       pDC->SetBkMode(TRANSPARENT);
>       hbr = CreateSolidBrush(RGB(255,255,255));
>   }

>   // TODO: Return a different brush if the default is not desired

>   return hbr;
>}

>------------
>Your time and help is highly appreciated.
>Daxin



Tue, 20 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Background & Text color CEdit

2. CEdit & Color (Newbie)

3. CEdit font & color

4. MM_ANISOTROPIC && Scrolling View

5. Caption bar color & CSliderCtrl Color

6. CEditView Background Color & Font Color :: MFC

7. Scrolling problems with CEdit - Multiline on a dialog

8. CEdit Scrolling

9. Programmatically scroll CEdit in a dialog?

10. CEdit Scroll by code

11. CEdit scrolling

12. changing font height causes cedit to scroll

 

 
Powered by phpBB® Forum Software