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. how to create a transparent Edit control on a CWnd object, while not a CDialog object?

how to create a transparent Edit control on a CWnd object, while not a CDialog object?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 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.
  • S Offline
    S Offline
    samfromcn
    wrote on last edited by
    #1

    I want to create a transparent RichEdit control, and find many example use follow code in parent dialog class: HBRUSH CParentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if((nCtlColor == CTLCOLOR_EDIT) && (pWnd->GetDlgCtrlID()==IDC_MYRICHEDIT)) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(255,0,0)); return HBRUSH(GetStockObject(HOLLOW_BRUSH)); } } It does not work in my application. I think maybe because which I create is CRichEditCtrl while those example create CEdit, or maybe because my parent window is CWnd class while those example use CDialog class. Anyone can tell me what the problem is, and how to fix it? help me create a transparent RichEdit control successfully, thanks a lot.:confused:

    N 1 Reply Last reply
    0
    • S samfromcn

      I want to create a transparent RichEdit control, and find many example use follow code in parent dialog class: HBRUSH CParentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if((nCtlColor == CTLCOLOR_EDIT) && (pWnd->GetDlgCtrlID()==IDC_MYRICHEDIT)) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(255,0,0)); return HBRUSH(GetStockObject(HOLLOW_BRUSH)); } } It does not work in my application. I think maybe because which I create is CRichEditCtrl while those example create CEdit, or maybe because my parent window is CWnd class while those example use CDialog class. Anyone can tell me what the problem is, and how to fix it? help me create a transparent RichEdit control successfully, thanks a lot.:confused:

      N Offline
      N Offline
      NiceNaidu fo
      wrote on last edited by
      #2

      Hi, Have u called AfxInitRichEdit in InitInstance of your application ?? Appu.. "If you judge people, you have no time to love them."

      S 1 Reply Last reply
      0
      • N NiceNaidu fo

        Hi, Have u called AfxInitRichEdit in InitInstance of your application ?? Appu.. "If you judge people, you have no time to love them."

        S Offline
        S Offline
        samfromcn
        wrote on last edited by
        #3

        Yes, I called the function in InitInstance().:doh:

        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