Print Page | Close Window

[solved]wrong bg color in disabled CXTPControlEdit

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=22976
Printed Date: 21 November 2024 at 3:34pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved]wrong bg color in disabled CXTPControlEdit
Posted By: JoseAngel
Subject: [solved]wrong bg color in disabled CXTPControlEdit
Date 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.



Replies:
Posted By: olebed
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net