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. CBitmap

CBitmap

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • F Offline
    F Offline
    fjlv2005
    wrote on last edited by
    #1

    I have a CBitmap derrived class, and have my own Draw function. However, When it is displayed, it its overlapped by other controls. Is there a way to make a CBitmap on top of all controls? thanks..

    P 1 Reply Last reply
    0
    • F fjlv2005

      I have a CBitmap derrived class, and have my own Draw function. However, When it is displayed, it its overlapped by other controls. Is there a way to make a CBitmap on top of all controls? thanks..

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      Set the z-order of the button properly in the dialog design window


      -prakash

      F 1 Reply Last reply
      0
      • P Prakash Nadar

        Set the z-order of the button properly in the dialog design window


        -prakash

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

        Hello Prakash, I have declared CBitmap in this, CMyBitmap mybitmap; mybitmap.LoadBitmap(IDB_MYBMP); mybitmap.DrawTransparent(GetDC(),20,50,RGB(255,0,255)); Sorry I was not clear enough in the first place. CMyBitmap is derrived from CBitmap, I have to subclass because i need to make the bitmap transparent. Please help me How I could bring this on top of other controls. Anyway here is the detail of DrawTransparentFunction.(Just research this detail from other articles but it didnt bring the bitmap on top. Its weakness is when there are other control because it is overlapped.) void CMyBitmap::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); // // Create a memory DC (dcImage) and select the bitmap into it. // CDC dcImage; dcImage.CreateCompatibleDC (pDC); CBitmap* pOldBitmapImage = dcImage.SelectObject (this); //dcImage.SetMapMode (pDC->GetMapMode ()); // // Create a second memory DC (dcAnd) and in it create an AND mask. // CDC dcAnd; dcAnd.CreateCompatibleDC (pDC); //dcAnd.SetMapMode (pDC->GetMapMode ()); 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); // // Create a third memory DC (dcXor) and in it create an XOR mask. // CDC dcXor; dcXor.CreateCompatibleDC (pDC); //dcXor.SetMapMode (pDC->GetMapMode ()); 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); // // Copy the pixels in the destination rectangle to a temporary // memory DC (dcTemp). // CDC dcTemp; dcTemp.CreateCompatibleDC (pDC); //dcTemp.SetMapMode (pDC->GetMapMode ()); 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); // // Genera

        P 1 Reply Last reply
        0
        • F fjlv2005

          Hello Prakash, I have declared CBitmap in this, CMyBitmap mybitmap; mybitmap.LoadBitmap(IDB_MYBMP); mybitmap.DrawTransparent(GetDC(),20,50,RGB(255,0,255)); Sorry I was not clear enough in the first place. CMyBitmap is derrived from CBitmap, I have to subclass because i need to make the bitmap transparent. Please help me How I could bring this on top of other controls. Anyway here is the detail of DrawTransparentFunction.(Just research this detail from other articles but it didnt bring the bitmap on top. Its weakness is when there are other control because it is overlapped.) void CMyBitmap::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); // // Create a memory DC (dcImage) and select the bitmap into it. // CDC dcImage; dcImage.CreateCompatibleDC (pDC); CBitmap* pOldBitmapImage = dcImage.SelectObject (this); //dcImage.SetMapMode (pDC->GetMapMode ()); // // Create a second memory DC (dcAnd) and in it create an AND mask. // CDC dcAnd; dcAnd.CreateCompatibleDC (pDC); //dcAnd.SetMapMode (pDC->GetMapMode ()); 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); // // Create a third memory DC (dcXor) and in it create an XOR mask. // CDC dcXor; dcXor.CreateCompatibleDC (pDC); //dcXor.SetMapMode (pDC->GetMapMode ()); 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); // // Copy the pixels in the destination rectangle to a temporary // memory DC (dcTemp). // CDC dcTemp; dcTemp.CreateCompatibleDC (pDC); //dcTemp.SetMapMode (pDC->GetMapMode ()); 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); // // Genera

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          I dont think it is a problem with your drawing, The problem is probably with the placement of the controls. If the controls are overlaping that means, you have placed them like that. or is the bitmap drawing beyond your required place. or if you want the bitmap to be drawn over other contorls, consider making thouse contorls invisible.


          -prakash

          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