Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. about dialog color?

about dialog color?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vividtang
    wrote on last edited by
    #1

    hi:i create a dialog such as CMyDlg, i define a variable :CBrush m_brush, then i in onInitDialog :m_brush.CreateSolidBrush(RGB(255,255,0)) then HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (pWnd->GetDlgCtrlID() == IDC_STATIC) {// Set the text color to red pDC->SetTextColor(RGB(255, 0, 0)); // Set the background mode for text to transparent pDC->SetBkMode(TRANSPARENT); // Return handle to our CBrush object hbr = m_brush; } return hbr; } but the text color is not i expected,and at the back of the text ,always exist white ?how to modify?but if i do these work in main dialog ,all is ok.

    A 1 Reply Last reply
    0
    • V vividtang

      hi:i create a dialog such as CMyDlg, i define a variable :CBrush m_brush, then i in onInitDialog :m_brush.CreateSolidBrush(RGB(255,255,0)) then HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (pWnd->GetDlgCtrlID() == IDC_STATIC) {// Set the text color to red pDC->SetTextColor(RGB(255, 0, 0)); // Set the background mode for text to transparent pDC->SetBkMode(TRANSPARENT); // Return handle to our CBrush object hbr = m_brush; } return hbr; } but the text color is not i expected,and at the back of the text ,always exist white ?how to modify?but if i do these work in main dialog ,all is ok.

      A Offline
      A Offline
      Arman S
      wrote on last edited by
      #2

      Seems brushing is ok, so it should work. Though I want to point out two things; 1) Do not use pWnd->GetDlgCtrlID() == IDC_STATIC condition unless you assign a unique id to a static control (e.g. IDC_MYSTATIC). Instead, if you want to consider all the static controls, test against nCtlColor == CTLCOLOR_STATIC. 2) Why not to set the text color; pDC->SetTextColor( some rgb );

      -- ===== Arman

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups