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. Bitmap behind documents

Bitmap behind documents

Scheduled Pinned Locked Moved C / C++ / MFC
graphicstutorialquestion
8 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.
  • D Offline
    D Offline
    Dean Michaud
    wrote on last edited by
    #1

    I want to add a logo bitmap, either tiled or centered, behind my document windows so that when they are minimized it displays the logo. I'm not quite sure how to approach this, any ideas? : Dean 'Karnatos' Michaud

    J 1 Reply Last reply
    0
    • D Dean Michaud

      I want to add a logo bitmap, either tiled or centered, behind my document windows so that when they are minimized it displays the logo. I'm not quite sure how to approach this, any ideas? : Dean 'Karnatos' Michaud

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      This post of mine shows you how. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      D 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        This post of mine shows you how. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        D Offline
        D Offline
        Dean Michaud
        wrote on last edited by
        #3

        What was the date it was written? For some reason the link doesn't forward me onto the post, but I am guessing it has something to do with my job-place's horrible caching server messing things up yet again. If you could repost it, or point me to the date it was published I might be able to work around this caching server's annoyance. Thank you for the help! : Dean 'Karnatos' Michaud

        J 1 Reply Last reply
        0
        • D Dean Michaud

          What was the date it was written? For some reason the link doesn't forward me onto the post, but I am guessing it has something to do with my job-place's horrible caching server messing things up yet again. If you could repost it, or point me to the date it was published I might be able to work around this caching server's annoyance. Thank you for the help! : Dean 'Karnatos' Michaud

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          I guess the problem is you're not using DHTML, and the URL changes with this optio on. Anyway, here's the post again. --repost It's simple task, but many steps are required:

          1. Create a new CWnd-derived class, say CBackgroundWnd.

          2. Add these two members to CBackgroundWnd:

            CBitmap m_bitmap_background;
            BITMAP m_bmInfo_background;

            along with this piece of code in CBackgroundWnd ctor:

            m\_bitmap\_background.LoadBitmap(IDB\_BACKGROUND); // change IDB\_BACKGROUND to whatever your resource-located bitmap is called.
            ::GetObject(m\_bitmap\_background,sizeof(BITMAP),&m\_bmInfo\_background);
            
          3. Add a handler for WM_ERASEBKGND in CBackgroundWnd and plug this code (which draws the bitmap in tesellation mode)

            BOOL CBackgroundWnd::OnEraseBkgnd(CDC* pDC)
            {
            CRect rect;
            GetClientRect(rect);

            CDC dcMem;
            dcMem.CreateCompatibleDC(pDC);
            
            HBITMAP\* pBmpOld=(HBITMAP\*)::SelectObject(dcMem.m\_hDC,m\_bitmap\_background);
            
            for(int y=rect.top;y<rect.bottom;y+=m\_bmInfo\_background.bmHeight){
                for(int x=rect.left;x<=rect.right;x+=m\_bmInfo\_background.bmWidth){
                    pDC->BitBlt(x,y,m\_bmInfo\_background.bmWidth,m\_bmInfo\_background.bmHeight,
                                &dcMem,0,0,SRCCOPY);
                }
            }
            
            ::SelectObject(dcMem.m\_hDC, pBmpOld);
            
            return TRUE;
            

            }

          4. Add a member of type CBackgroundWnd to your CMainFrame class, say m_wndClient.

          5. Override CMainFrame::OnCreateClient with this:

            BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
            {
            if(!CMDIFrameWnd::OnCreateClient(lpcs, pContext))return FALSE;
            m_wndClient.SubclassWindow(m_hWndMDIClient);
            return TRUE;
            }

          That's it, I think. Good luck. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo --end repost Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          J D 2 Replies Last reply
          0
          • J Joaquin M Lopez Munoz

            I guess the problem is you're not using DHTML, and the URL changes with this optio on. Anyway, here's the post again. --repost It's simple task, but many steps are required:

            1. Create a new CWnd-derived class, say CBackgroundWnd.

            2. Add these two members to CBackgroundWnd:

              CBitmap m_bitmap_background;
              BITMAP m_bmInfo_background;

              along with this piece of code in CBackgroundWnd ctor:

              m\_bitmap\_background.LoadBitmap(IDB\_BACKGROUND); // change IDB\_BACKGROUND to whatever your resource-located bitmap is called.
              ::GetObject(m\_bitmap\_background,sizeof(BITMAP),&m\_bmInfo\_background);
              
            3. Add a handler for WM_ERASEBKGND in CBackgroundWnd and plug this code (which draws the bitmap in tesellation mode)

              BOOL CBackgroundWnd::OnEraseBkgnd(CDC* pDC)
              {
              CRect rect;
              GetClientRect(rect);

              CDC dcMem;
              dcMem.CreateCompatibleDC(pDC);
              
              HBITMAP\* pBmpOld=(HBITMAP\*)::SelectObject(dcMem.m\_hDC,m\_bitmap\_background);
              
              for(int y=rect.top;y<rect.bottom;y+=m\_bmInfo\_background.bmHeight){
                  for(int x=rect.left;x<=rect.right;x+=m\_bmInfo\_background.bmWidth){
                      pDC->BitBlt(x,y,m\_bmInfo\_background.bmWidth,m\_bmInfo\_background.bmHeight,
                                  &dcMem,0,0,SRCCOPY);
                  }
              }
              
              ::SelectObject(dcMem.m\_hDC, pBmpOld);
              
              return TRUE;
              

              }

            4. Add a member of type CBackgroundWnd to your CMainFrame class, say m_wndClient.

            5. Override CMainFrame::OnCreateClient with this:

              BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
              {
              if(!CMDIFrameWnd::OnCreateClient(lpcs, pContext))return FALSE;
              m_wndClient.SubclassWindow(m_hWndMDIClient);
              return TRUE;
              }

            That's it, I think. Good luck. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo --end repost Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            J Offline
            J Offline
            Joao Vaz
            wrote on last edited by
            #5

            Joaquín , what does it mean "tesellation mode" ? Could you explain ? Cheers, Joao Vaz A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)

            J 1 Reply Last reply
            0
            • J Joao Vaz

              Joaquín , what does it mean "tesellation mode" ? Could you explain ? Cheers, Joao Vaz A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)

              J Offline
              J Offline
              Joaquin M Lopez Munoz
              wrote on last edited by
              #6

              Same as "mosaic mode": the bitmap is repeated horizontally and vertically to cover all the area. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

              J 1 Reply Last reply
              0
              • J Joaquin M Lopez Munoz

                Same as "mosaic mode": the bitmap is repeated horizontally and vertically to cover all the area. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                J Offline
                J Offline
                Joao Vaz
                wrote on last edited by
                #7

                Okay. Thanks :-) Cheers, Joao Vaz A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)

                1 Reply Last reply
                0
                • J Joaquin M Lopez Munoz

                  I guess the problem is you're not using DHTML, and the URL changes with this optio on. Anyway, here's the post again. --repost It's simple task, but many steps are required:

                  1. Create a new CWnd-derived class, say CBackgroundWnd.

                  2. Add these two members to CBackgroundWnd:

                    CBitmap m_bitmap_background;
                    BITMAP m_bmInfo_background;

                    along with this piece of code in CBackgroundWnd ctor:

                    m\_bitmap\_background.LoadBitmap(IDB\_BACKGROUND); // change IDB\_BACKGROUND to whatever your resource-located bitmap is called.
                    ::GetObject(m\_bitmap\_background,sizeof(BITMAP),&m\_bmInfo\_background);
                    
                  3. Add a handler for WM_ERASEBKGND in CBackgroundWnd and plug this code (which draws the bitmap in tesellation mode)

                    BOOL CBackgroundWnd::OnEraseBkgnd(CDC* pDC)
                    {
                    CRect rect;
                    GetClientRect(rect);

                    CDC dcMem;
                    dcMem.CreateCompatibleDC(pDC);
                    
                    HBITMAP\* pBmpOld=(HBITMAP\*)::SelectObject(dcMem.m\_hDC,m\_bitmap\_background);
                    
                    for(int y=rect.top;y<rect.bottom;y+=m\_bmInfo\_background.bmHeight){
                        for(int x=rect.left;x<=rect.right;x+=m\_bmInfo\_background.bmWidth){
                            pDC->BitBlt(x,y,m\_bmInfo\_background.bmWidth,m\_bmInfo\_background.bmHeight,
                                        &dcMem,0,0,SRCCOPY);
                        }
                    }
                    
                    ::SelectObject(dcMem.m\_hDC, pBmpOld);
                    
                    return TRUE;
                    

                    }

                  4. Add a member of type CBackgroundWnd to your CMainFrame class, say m_wndClient.

                  5. Override CMainFrame::OnCreateClient with this:

                    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
                    {
                    if(!CMDIFrameWnd::OnCreateClient(lpcs, pContext))return FALSE;
                    m_wndClient.SubclassWindow(m_hWndMDIClient);
                    return TRUE;
                    }

                  That's it, I think. Good luck. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo --end repost Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                  D Offline
                  D Offline
                  Dean Michaud
                  wrote on last edited by
                  #8

                  Man, beautiful! I'm glad I asked, I was taking a different approach and it was causing undeserved headache! Thanks again Joaquín : Dean 'Karnatos' Michaud

                  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