Click here to Skip to main content
16,011,436 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Andy Moore16-Jul-04 8:07
Andy Moore16-Jul-04 8:07 
GeneralRe: Automatically determing Save File Dialog filter type Pin
David Crow16-Jul-04 8:16
David Crow16-Jul-04 8:16 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Andy Moore16-Jul-04 10:08
Andy Moore16-Jul-04 10:08 
GeneralRe: Automatically determing Save File Dialog filter type Pin
Maximilien16-Jul-04 7:46
Maximilien16-Jul-04 7:46 
GeneralCustom data type in ActiveX property Pin
iluha16-Jul-04 7:12
iluha16-Jul-04 7:12 
GeneralCEdit's Text Color when Disabled Pin
Vladimir Georgiev16-Jul-04 7:06
Vladimir Georgiev16-Jul-04 7:06 
GeneralRe: CEdit's Text Color when Disabled Pin
David Crow16-Jul-04 7:08
David Crow16-Jul-04 7:08 
GeneralRe: CEdit's Text Color when Disabled Pin
Ulric Auger20-Oct-09 18:36
Ulric Auger20-Oct-09 18:36 
I found a way to change the text color of a disabled CEdit.

1- You must derive a class from CEdit

2- Overwrite WindowProc and do the following:
LRESULT CMyEditBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
  if (message == WM_PAINT)
  {
      DWORD dwStyle = GetStyle();
      if (dwStyle & WS_DISABLED)
      {
          EnableWindow(TRUE); //Trick paint by temporarily enabling CEdit
          SetReadOnly(TRUE);  //Temporarily making CEdit read only

          LRESULT res = CEdit::WindowProc(message, wParam, lParam);

          SetRedraw(FALSE);

          if ((dwStyle&ES_READONLY) == 0) SetReadOnly(FALSE); //Restore READ ONLY style
          EnableWindow(FALSE); //Restore DISABLED style

          SetRedraw(TRUE);

          CRect rcClient;
          GetWindowRect(rcClient);
          ScreenToClient(rcClient);
          ValidateRect(rcClient);

          return res;
      }
  }

  return CEdit::WindowProc(message, wParam, lParam);
}


3- Overwrite CtlColor and change color when control is in read-only state (of course you can use a member variable instead of the read-only style to set disabled text color)
HBRUSH CMyEditBox::CtlColor(CDC* pDC, UINT nCtlColor)
{
  if (GetStyle() & ES_READONLY)
  {
    pDC->SetBkColor(GetSysColor(COLOR_3DFACE));
    pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
    return GetSysColorBrush(COLOR_3DFACE);
  }

  return NULL;
}

GeneralAccessing Shared Resource from a Windows "Service" Pin
Petrus Scott16-Jul-04 7:03
Petrus Scott16-Jul-04 7:03 
GeneralRe: Accessing Shared Resource from a Windows "Service" Pin
palbano16-Jul-04 7:09
palbano16-Jul-04 7:09 
GeneralRe: Accessing Shared Resource from a Windows "Service" Pin
Petrus Scott16-Jul-04 7:48
Petrus Scott16-Jul-04 7:48 
GeneralRe: Accessing Shared Resource from a Windows "Service" Pin
palbano16-Jul-04 8:29
palbano16-Jul-04 8:29 
GeneralAccessing resources Pin
0v3rloader16-Jul-04 6:46
0v3rloader16-Jul-04 6:46 
GeneralRe: Accessing resources Pin
David Crow16-Jul-04 7:06
David Crow16-Jul-04 7:06 
Questionhow to receive outgoing message Pin
Anton Zarubin16-Jul-04 5:37
Anton Zarubin16-Jul-04 5:37 
GeneralRe: how to receive outgoing message Pin
David Crow16-Jul-04 7:02
David Crow16-Jul-04 7:02 
GeneralRe: how to receive outgoing message Pin
Eugene Grudina16-Jul-04 8:27
sussEugene Grudina16-Jul-04 8:27 
AnswerRe: how to receive outgoing message Pin
Antti Keskinen16-Jul-04 8:22
Antti Keskinen16-Jul-04 8:22 
GeneralRe: how to receive outgoing message Pin
Anton Zarubin17-Jul-04 0:36
Anton Zarubin17-Jul-04 0:36 
GeneralRe: how to receive outgoing message Pin
Antti Keskinen17-Jul-04 5:30
Antti Keskinen17-Jul-04 5:30 
GeneralWindows Logon Dialog Pin
Anthony988716-Jul-04 5:11
Anthony988716-Jul-04 5:11 
GeneralRe: Windows Logon Dialog Pin
David Crow16-Jul-04 5:21
David Crow16-Jul-04 5:21 
GeneralRe: Windows Logon Dialog Pin
Antony M Kancidrowski16-Jul-04 5:47
Antony M Kancidrowski16-Jul-04 5:47 
Generalsingle instance SDI Pin
vanne16-Jul-04 4:41
vanne16-Jul-04 4:41 
GeneralRe: single instance SDI Pin
Antti Keskinen16-Jul-04 8:39
Antti Keskinen16-Jul-04 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.