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. Bring CBitmap to top windows

Bring CBitmap to top windows

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 1 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
    fjlv2005
    wrote on last edited by
    #1

    Hello, I have a CBitmap and load it. CBitmap mybmp; mybmp.Load(IDB_TEST); However, my listbox overlaps the CBitmap. How can i make CBitmap on top of other controls? Thanks a lot.

    R 1 Reply Last reply
    0
    • F fjlv2005

      Hello, I have a CBitmap and load it. CBitmap mybmp; mybmp.Load(IDB_TEST); However, my listbox overlaps the CBitmap. How can i make CBitmap on top of other controls? Thanks a lot.

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      NewVCbie wrote: How can i make CBitmap on top of other controls? What are you doing after mybmp.Load(IDB_TEST); with your bitmap ? Can you post some code ? Which listbox are you talking about ? ~RaGE();

      F 1 Reply Last reply
      0
      • R Rage

        NewVCbie wrote: How can i make CBitmap on top of other controls? What are you doing after mybmp.Load(IDB_TEST); with your bitmap ? Can you post some code ? Which listbox are you talking about ? ~RaGE();

        F Offline
        F Offline
        fjlv2005
        wrote on last edited by
        #3

        actually i create a class CMyBitmap derived from CBitmap, void DrawTransparent (CDC* pDC, int x, int y, COLORREF clrTransparency); void Draw (CDC* pDC, int x, int y); The actual call is CMyBitmap bmpheader; bmpheader.LoadBitmap(IDB_LISTHHISTORY); bmpheader.DrawTransparent(GetDC(),24,85,RGB(255,0,255)); My bitmap is long and it hit some area where listbox is, but what happens is that the hit area appears that my bitmap is behind the listbox, i wanted the opposite. I wanted my bitmap to be on top of whatever control it encounter on its area.. Thanks... Below is the Code: void CDTGBitmap::Draw(CDC *pDC, int x, int y) { BITMAP bm; GetBitmap (&bm); CPoint size (bm.bmWidth, bm.bmHeight); pDC->DPtoLP (&size); CPoint org (0, 0); pDC->DPtoLP (&org); CDC dcMem; dcMem.CreateCompatibleDC (pDC); CBitmap* pOldBitmap = dcMem.SelectObject (this); pDC->BitBlt (x, y, size.x, size.y, &dcMem, org.x, org.y, SRCCOPY); dcMem.SelectObject (pOldBitmap); } void CDTGBitmap::DrawTransparent(CDC *pDC, int x, int y, COLORREF clrTransparency) { BITMAP bm; GetBitmap (&bm); CPoint size (bm.bmWidth, bm.bmHeight); pDC->DPtoLP (&size); CPoint org (0, 0); pDC->DPtoLP (&org); CDC dcImage; dcImage.CreateCompatibleDC (pDC); CBitmap* pOldBitmapImage = dcImage.SelectObject (this); CDC dcAnd; dcAnd.CreateCompatibleDC (pDC); CBitmap bitmapAnd; bitmapAnd.CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL); CBitmap* pOldBitmapAnd = dcAnd.SelectObject (&bitmapAnd); dcImage.SetBkColor (clrTransparency); dcAnd.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY); CDC dcXor; dcXor.CreateCompatibleDC (pDC); CBitmap bitmapXor; bitmapXor.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight); CBitmap* pOldBitmapXor = dcXor.SelectObject (&bitmapXor); dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY); dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y, 0x220326); CDC dcTemp; dcTemp.CreateCompatibleDC (pDC); CBitmap bitmapTemp; bitmapTemp.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight); CBitmap* pOldBitmapTemp = dcTemp.SelectObject (&bitmapTemp); dcTemp.BitBlt (org.x, org.y, size.x, size.y, pDC, x, y, SRCCOPY); dcTemp.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y,SRCAND); dcTemp.BitBlt (org.x, org.y, size.x, size.

        J 1 Reply Last reply
        0
        • F fjlv2005

          actually i create a class CMyBitmap derived from CBitmap, void DrawTransparent (CDC* pDC, int x, int y, COLORREF clrTransparency); void Draw (CDC* pDC, int x, int y); The actual call is CMyBitmap bmpheader; bmpheader.LoadBitmap(IDB_LISTHHISTORY); bmpheader.DrawTransparent(GetDC(),24,85,RGB(255,0,255)); My bitmap is long and it hit some area where listbox is, but what happens is that the hit area appears that my bitmap is behind the listbox, i wanted the opposite. I wanted my bitmap to be on top of whatever control it encounter on its area.. Thanks... Below is the Code: void CDTGBitmap::Draw(CDC *pDC, int x, int y) { BITMAP bm; GetBitmap (&bm); CPoint size (bm.bmWidth, bm.bmHeight); pDC->DPtoLP (&size); CPoint org (0, 0); pDC->DPtoLP (&org); CDC dcMem; dcMem.CreateCompatibleDC (pDC); CBitmap* pOldBitmap = dcMem.SelectObject (this); pDC->BitBlt (x, y, size.x, size.y, &dcMem, org.x, org.y, SRCCOPY); dcMem.SelectObject (pOldBitmap); } void CDTGBitmap::DrawTransparent(CDC *pDC, int x, int y, COLORREF clrTransparency) { BITMAP bm; GetBitmap (&bm); CPoint size (bm.bmWidth, bm.bmHeight); pDC->DPtoLP (&size); CPoint org (0, 0); pDC->DPtoLP (&org); CDC dcImage; dcImage.CreateCompatibleDC (pDC); CBitmap* pOldBitmapImage = dcImage.SelectObject (this); CDC dcAnd; dcAnd.CreateCompatibleDC (pDC); CBitmap bitmapAnd; bitmapAnd.CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL); CBitmap* pOldBitmapAnd = dcAnd.SelectObject (&bitmapAnd); dcImage.SetBkColor (clrTransparency); dcAnd.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY); CDC dcXor; dcXor.CreateCompatibleDC (pDC); CBitmap bitmapXor; bitmapXor.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight); CBitmap* pOldBitmapXor = dcXor.SelectObject (&bitmapXor); dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcImage, org.x, org.y, SRCCOPY); dcXor.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y, 0x220326); CDC dcTemp; dcTemp.CreateCompatibleDC (pDC); CBitmap bitmapTemp; bitmapTemp.CreateCompatibleBitmap (&dcImage, bm.bmWidth, bm.bmHeight); CBitmap* pOldBitmapTemp = dcTemp.SelectObject (&bitmapTemp); dcTemp.BitBlt (org.x, org.y, size.x, size.y, pDC, x, y, SRCCOPY); dcTemp.BitBlt (org.x, org.y, size.x, size.y, &dcAnd, org.x, org.y,SRCAND); dcTemp.BitBlt (org.x, org.y, size.x, size.

          J Offline
          J Offline
          Jose Lamas Rios
          wrote on last edited by
          #4

          It seems like you are just drawing the bitmap in the parent window, so any child control (e.g., the listbox) will be drawn on top of it. I suggest creating a static control with the SS_OWNERDRAW style. Put this control at the top of the children z-order and use CDTGBitmap to do the drawing in the parent's handler for the WM_DRAWITEM message. -- jlr http://jlamas.blogspot.com/[^]

          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