Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - [solved]wrong bg color in disabled CXTPControlEdit
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved]wrong bg color in disabled CXTPControlEdit

 Post Reply Post Reply
Author
Message
JoseAngel View Drop Down
Groupie
Groupie


Joined: 21 March 2006
Location: Spain
Status: Offline
Points: 35
Post Options Post Options   Thanks (1) Thanks(1)   Quote JoseAngel Quote  Post ReplyReply Direct Link To This Post Topic: [solved]wrong bg color in disabled CXTPControlEdit
    Posted: 28 March 2016 at 3:37pm
CXTPControlEdit is actually a RichEdit control.

The background of the RichEdit for the selected theme is controlled in CXTPControlEditCtrl::UpdateCharFormat() sending to it a EM_SETBKGNDCOLOR message with the correspondent background color.

The problem is that when the RichEdit control is disabled, it doesn't use the specified color and it always use COLOR_BTNFACE as background color.

I purpose to change the CXTPControlEdit::OnEnabledChanged() from

void CXTPControlEdit::OnEnabledChanged()
{
 if (m_pEdit && m_pEdit->GetSafeHwnd())
 {
  m_pEdit->EnableWindow(GetEnabled());
  m_pEdit->UpdateCharFormat();
 }
}

to

void CXTPControlEdit::OnEnabledChanged()
{
 if (m_pEdit && m_pEdit->GetSafeHwnd())
 {
  m_pEdit->SetReadOnly(!GetEnabled());
  m_pEdit->UpdateCharFormat();
 }
}

and now the background color will be the correct one when the toolbar is disabled.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 29 March 2018 at 7:57am
Hello,

We solved this issue in similar way
BEGIN_MESSAGE_MAP(CXTPControlEditCtrl, CXTPCommandBarEditCtrl)
    ON_WM_SETFOCUS()
    ON_WM_MOUSEMOVE()
    ON_WM_KILLFOCUS()
    ON_WM_DESTROY()
    ON_WM_LBUTTONDOWN()
    ON_WM_RBUTTONDOWN()
    ON_WM_CONTEXTMENU()
    ON_WM_KEYDOWN()
    ON_MESSAGE(XTP_TTM_WINDOWFROMPOINT, OnWindowFromPoint)
    ON_CONTROL_REFLECT(EN_CHANGE, OnEditChanged)
    ON_MESSAGE(WM_ENABLE, OnEnableDisable)
END_MESSAGE_MAP()

// [IP] This trick (handling WM_ENABLE) allows to skip using COLOR_GRAYTEXT for disabled control background (default Win32)
// You can now handle the WM_CTLCOLOR/CTL_COLOREDIT message in the parent or the reflected (=WM_CTLCOLOR) message in the
// derived subclass as you normally would. And you can still use IsWindowEnabled should you care to.
LRESULT CXTPControlEditCtrl::OnEnableDisable(WPARAM, LPARAM)
{
    Invalidate();

    return 0;
}

also in theme Office2016****Black.ini   text color is very close to background.
[CommandBars]
Back = 54 54 54
....
EditTextDisabled = 106 106 106

Regards,
 Oleksandr Lebed
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.137 seconds.