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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Transparent edit box

Transparent edit box

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpquestion
10 Posts 3 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.
  • F Offline
    F Offline
    fx9200
    wrote on last edited by
    #1

    Hello, i want to make my edit boxes and labels transparent to show my own bitmap; can somene help me?:doh:

    _ H 2 Replies Last reply
    0
    • F fx9200

      Hello, i want to make my edit boxes and labels transparent to show my own bitmap; can somene help me?:doh:

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      fx9200 wrote:

      i want to make my edit boxes and labels transparent to show my own bitmap;

      Override the OnCtlColor method: Ex:

      if(pWnd->GetDlgCtrlID()==/*ID of the item*/)
      	{		
      		COLORREF clrStruct=RGB(/*back ground color*/);
      		hbr = CreateSolidBrush(clrStruct);		
      		pDC->SetBkColor(clrStruct);
      		pDC->SetTextColor(RGB(0,0,0));
      	}
      

      You can do something like this. Try this....

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      F 1 Reply Last reply
      0
      • F fx9200

        Hello, i want to make my edit boxes and labels transparent to show my own bitmap; can somene help me?:doh:

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        See Creating a Transparent Editbox with No Redraw Problems[^] and CEdit & CStatic Transparency Control[^] for transparent editbox

        _**


        **_

        WhiteSky


        F 1 Reply Last reply
        0
        • _ _AnsHUMAN_

          fx9200 wrote:

          i want to make my edit boxes and labels transparent to show my own bitmap;

          Override the OnCtlColor method: Ex:

          if(pWnd->GetDlgCtrlID()==/*ID of the item*/)
          	{		
          		COLORREF clrStruct=RGB(/*back ground color*/);
          		hbr = CreateSolidBrush(clrStruct);		
          		pDC->SetBkColor(clrStruct);
          		pDC->SetTextColor(RGB(0,0,0));
          	}
          

          You can do something like this. Try this....

          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          F Offline
          F Offline
          fx9200
          wrote on last edited by
          #4

          I didn't find that method it ssems it cannot be added by class wizard !

          _ H 2 Replies Last reply
          0
          • F fx9200

            I didn't find that method it ssems it cannot be added by class wizard !

            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #5

            fx9200 wrote:

            I didn't find that method

            What version of editor are you using. VS6.0 / VS .NET 2003 or something else.

            fx9200 wrote:

            it ssems it cannot be added by class wizard !

            You can also add the code with your hands In the header file HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) In the .cpp file HBRUSH CadfDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // Add your code here return hbr; } In Message map of your class ON_WM_CTLCOLOR() But avoid doing so...

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            F 1 Reply Last reply
            0
            • H Hamid Taebi

              See Creating a Transparent Editbox with No Redraw Problems[^] and CEdit & CStatic Transparency Control[^] for transparent editbox

              _**


              **_

              WhiteSky


              F Offline
              F Offline
              fx9200
              wrote on last edited by
              #6

              thanks , i'm testing it

              1 Reply Last reply
              0
              • F fx9200

                I didn't find that method it ssems it cannot be added by class wizard !

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                if you use VS2003 you can use from property window for insert WM_CTLCOLOR yto your class.

                _**


                **_

                WhiteSky


                F 1 Reply Last reply
                0
                • _ _AnsHUMAN_

                  fx9200 wrote:

                  I didn't find that method

                  What version of editor are you using. VS6.0 / VS .NET 2003 or something else.

                  fx9200 wrote:

                  it ssems it cannot be added by class wizard !

                  You can also add the code with your hands In the header file HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) In the .cpp file HBRUSH CadfDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // Add your code here return hbr; } In Message map of your class ON_WM_CTLCOLOR() But avoid doing so...

                  Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                  F Offline
                  F Offline
                  fx9200
                  wrote on last edited by
                  #8

                  thanks, it worked; but with this i can't set a bitmap as a back round of the edit box;

                  _ 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    if you use VS2003 you can use from property window for insert WM_CTLCOLOR yto your class.

                    _**


                    **_

                    WhiteSky


                    F Offline
                    F Offline
                    fx9200
                    wrote on last edited by
                    #9

                    i'm in the end of the project; and i dont think its a good idea to convert it automatically with wizard;

                    1 Reply Last reply
                    0
                    • F fx9200

                      thanks, it worked; but with this i can't set a bitmap as a back round of the edit box;

                      _ Offline
                      _ Offline
                      _AnsHUMAN_
                      wrote on last edited by
                      #10
                      	HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
                      {
                      	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
                      	CBrush m_Brush;
                      	m_pBrush.CreateStockObject (NULL_BRUSH);
                      	if(pWnd->GetDlgCtrlID()==IDC_STATIC1/*ID of the item*/)
                      	{		
                      		pDC->SetBkMode (1);
                      		return (HBRUSH)mBrush;
                      	}
                      	return hbr;
                      }
                      

                      I hope that your problem would be solved with this.

                      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                      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