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. Setting BGColor to a WebBrowser Control [modified]

Setting BGColor to a WebBrowser Control [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
10 Posts 6 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.
  • P Offline
    P Offline
    pix_programmer
    wrote on last edited by
    #1

    Hi! How to set the Background color and BackGround Image to a CExplorer control in MFC?

    modified on Thursday, May 5, 2011 7:42 AM

    V M 2 Replies Last reply
    0
    • P pix_programmer

      Hi! How to set the Background color and BackGround Image to a CExplorer control in MFC?

      modified on Thursday, May 5, 2011 7:42 AM

      V Offline
      V Offline
      venkatmakam
      wrote on last edited by
      #2

      What is CExplorer?

      http://www.mono-project.com/Main\_Page

      P 1 Reply Last reply
      0
      • V venkatmakam

        What is CExplorer?

        http://www.mono-project.com/Main\_Page

        P Offline
        P Offline
        pix_programmer
        wrote on last edited by
        #3

        Html Browser control.

        _ 1 Reply Last reply
        0
        • P pix_programmer

          Html Browser control.

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #4

          You mean CHtmlView ?

          P 1 Reply Last reply
          0
          • _ _Flaviu

            You mean CHtmlView ?

            P Offline
            P Offline
            pix_programmer
            wrote on last edited by
            #5

            I've added a Html Browser control to a Dialog in MFC. Initially it is displayed with white background. I want ot change to some other color. How to do this?

            1 Reply Last reply
            0
            • P pix_programmer

              Hi! How to set the Background color and BackGround Image to a CExplorer control in MFC?

              modified on Thursday, May 5, 2011 7:42 AM

              M Offline
              M Offline
              Maximilien
              wrote on last edited by
              #6

              Don't you need to do this via HTML ?

              Watched code never compiles.

              P 1 Reply Last reply
              0
              • M Maximilien

                Don't you need to do this via HTML ?

                Watched code never compiles.

                P Offline
                P Offline
                pix_programmer
                wrote on last edited by
                #7

                No. Through C++/MFC code.

                B C 2 Replies Last reply
                0
                • P pix_programmer

                  No. Through C++/MFC code.

                  B Offline
                  B Offline
                  barneyman
                  wrote on last edited by
                  #8

                  maximilien is right; the window doesn't belong to you, you've given it to the web browser you can either embed an html resource in your own exe/dll and Navigate2 to it using the res:// namespace (see http://msdn.microsoft.com/en-us/library/aa767740.aspx[^]) or you can dynamically build an HTMLDocument2 and use IPersistStream to get it into the web browser I'd choose the res protocol - much simpler

                  1 Reply Last reply
                  0
                  • P pix_programmer

                    No. Through C++/MFC code.

                    C Offline
                    C Offline
                    Cool_Dev
                    wrote on last edited by
                    #9

                    well, if u insist on it, subclass your web browser control. I think the CExplorer class (generated from web browser activeX) would be derived from CWnd. Handle WM_PAINT or ON_WM_ERASEBKGND messages in it. do your background painting there. hopefully this may work.

                    // Explorer .h
                    DECLARE_MESSAGE_MAP()
                    afx_msg BOOL OnEraseBkgnd(CDC* pDC);

                    //Explorer.cpp

                    BEGIN_MESSAGE_MAP(CExplorer, CWnd)
                    ON_WM_ERASEBKGND()
                    END_MESSAGE_MAP()

                    BOOL CExplorer1::OnEraseBkgnd(CDC* pDC)
                    {
                    CRect rc;
                    GetClientRect(&rc);
                    pDC->FillSolidRect(&rc, RGB(255, 0, 0));

                    return TRUE;
                    }

                    *****But this lives only till you load your first web page in browser control. :)

                    V 1 Reply Last reply
                    0
                    • C Cool_Dev

                      well, if u insist on it, subclass your web browser control. I think the CExplorer class (generated from web browser activeX) would be derived from CWnd. Handle WM_PAINT or ON_WM_ERASEBKGND messages in it. do your background painting there. hopefully this may work.

                      // Explorer .h
                      DECLARE_MESSAGE_MAP()
                      afx_msg BOOL OnEraseBkgnd(CDC* pDC);

                      //Explorer.cpp

                      BEGIN_MESSAGE_MAP(CExplorer, CWnd)
                      ON_WM_ERASEBKGND()
                      END_MESSAGE_MAP()

                      BOOL CExplorer1::OnEraseBkgnd(CDC* pDC)
                      {
                      CRect rc;
                      GetClientRect(&rc);
                      pDC->FillSolidRect(&rc, RGB(255, 0, 0));

                      return TRUE;
                      }

                      *****But this lives only till you load your first web page in browser control. :)

                      V Offline
                      V Offline
                      venkatmakam
                      wrote on last edited by
                      #10

                      Yes it has to work since CExplorer1 is also Derived From CWnd. and mark your comment as answer.My 5.

                      http://www.mono-project.com/Main\_Page

                      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