Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CEdit Read-Only question

Posted on 2001-06-19
5
Medium Priority
?
573 Views
Last Modified: 2013-11-20
Hi,
I have a CEdit which I set to Read-Only mode.
But I want the color of the edit to remain white (and not gray).
How can I do it ?

Thanks,
Iris.
0
Comment
Question by:irisz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:Andrian
ID: 6209480
Use CStatic instead of CEdit(sunken) and you can color it after!
0
 

Author Comment

by:irisz
ID: 6209517
No, I need CEdit...
Can it be done in CEdit ?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6209556
u could use OnCtlColor to change the background of the CEdit color to white.
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
     HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
     
     if (pWnd->GetDlgCtrlID() == IDC_MYEDIT)
         pDC->SetBkColor(RGB(255, 255, 255));
     
     return hbr;
}

0
 
LVL 1

Accepted Solution

by:
iProgram earned 80 total points
ID: 6210734
You can also don't set it to Read-Only mode.
Add this code:(Edit Box ID:IDC_EDIT_TEST)
BOOL CYourDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->hwnd == GetDlgItem(IDC_EDIT_TEST)->GetSafeHwnd())
{
 if(pMsg->message == WM_KEYDOWN||pMsg->message ==WM_RBUTTONDOWN)
     return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}

0
 

Expert Comment

by:foreversoft
ID: 6212744
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
     HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    if (pWnd->GetDlgCtrlID() == IDC_MYEDIT)        
    {                
        pDC->SetBkColor(RGB(255, 255, 255));

        COLORREF color = RGB(255, 255, 255);
        CBrush* back_brush = new CBrush(color);
        return (HBRUSH) (back_brush->m_hObject);
    }
     return hbr;
}
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question