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. WM_CTLCOLOR

WM_CTLCOLOR

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.
  • T Offline
    T Offline
    Tara14
    wrote on last edited by
    #1

    Hi, I am using WM_CTLCOLOR to make the static text transparent and change the font and colour. Please can you tell me how to do the font-clean-up action if any is required here?

    HBRUSH CF4_NewEstimate::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CResizableFormView::OnCtlColor(pDC, pWnd, nCtlColor);

    CFont \*m\_pFont = new CFont;
    m\_pFont->CreateFont(12,0,0,0,600,0,0,0,0,0,0,ANTIALIASED\_QUALITY,0,"MS Sans Serif");
    CFont \*pOldFont = NULL;
    

    // Make transparent static control
    switch (nCtlColor)
    {
    case CTLCOLOR_STATIC:
    pDC->SelectObject(m_pFont);
    hbr = (HBRUSH)::GetStockObject (HOLLOW_BRUSH);
    pDC->SetBkMode (TRANSPARENT);
    pDC->SetTextColor(RGB(255,128,0));

    	break;
    }
    
    
    return hbr;
    

    }

    Thanks.

    _


    Fortitudine Vincimus!_

    N 1 Reply Last reply
    0
    • T Tara14

      Hi, I am using WM_CTLCOLOR to make the static text transparent and change the font and colour. Please can you tell me how to do the font-clean-up action if any is required here?

      HBRUSH CF4_NewEstimate::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
      {
      HBRUSH hbr = CResizableFormView::OnCtlColor(pDC, pWnd, nCtlColor);

      CFont \*m\_pFont = new CFont;
      m\_pFont->CreateFont(12,0,0,0,600,0,0,0,0,0,0,ANTIALIASED\_QUALITY,0,"MS Sans Serif");
      CFont \*pOldFont = NULL;
      

      // Make transparent static control
      switch (nCtlColor)
      {
      case CTLCOLOR_STATIC:
      pDC->SelectObject(m_pFont);
      hbr = (HBRUSH)::GetStockObject (HOLLOW_BRUSH);
      pDC->SetBkMode (TRANSPARENT);
      pDC->SetTextColor(RGB(255,128,0));

      	break;
      }
      
      
      return hbr;
      

      }

      Thanks.

      _


      Fortitudine Vincimus!_

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      Tara14 ase CTLCOLOR_STATIC: pDC->SelectObject(m_pFont);

      This is not the correct way to change the font of a window. You should call the SetFont() function to change the font and this need to be done only once( in OnInitdialog() or OnIntitialUpdate() function etc ).

      nave [OpenedFileFinder]

      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