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. Painting bad issues (GDI)

Painting bad issues (GDI)

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiocomgraphicshelp
2 Posts 1 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.
  • R Offline
    R Offline
    Rafael Fernandez Lopez
    wrote on last edited by
    #1

    Hi, If you can download the project, and help me in some way... is only a class and its goal es mainly: * To have an image at the back (alphablended with AlphaBlend function), and if the window receive ScrollWindow() messages, to don't move. It work all right, but if I've some controls on it, they will be drawn on the alphablended image, so if you move the window, later it will be visible. Just open the zip, compile it (I've Visual Studio .NET 2003), and press "ACCEPT" to load the alphablended image, and you must press "CANCEL" several times to make the window scroll. I'm new to GDI, and maybe there are lots of things very bad. I will appreciate a lot your comments, to learn more. Here you can download the file !! THANK YOU VERY MUCH !!!


    Written by: Rafael Fernández López.

    Visit: http://www.maestroprogramador.com

    R 1 Reply Last reply
    0
    • R Rafael Fernandez Lopez

      Hi, If you can download the project, and help me in some way... is only a class and its goal es mainly: * To have an image at the back (alphablended with AlphaBlend function), and if the window receive ScrollWindow() messages, to don't move. It work all right, but if I've some controls on it, they will be drawn on the alphablended image, so if you move the window, later it will be visible. Just open the zip, compile it (I've Visual Studio .NET 2003), and press "ACCEPT" to load the alphablended image, and you must press "CANCEL" several times to make the window scroll. I'm new to GDI, and maybe there are lots of things very bad. I will appreciate a lot your comments, to learn more. Here you can download the file !! THANK YOU VERY MUCH !!!


      Written by: Rafael Fernández López.

      Visit: http://www.maestroprogramador.com

      R Offline
      R Offline
      Rafael Fernandez Lopez
      wrote on last edited by
      #2

      Well if you're curious, here you are: ImagenTransparente.cpp // ImagenTransparente.cpp: archivo de implementación // #include "stdafx.h" #include "Transparencia.h" #include "ImagenTransparente.h" #include ".\imagentransparente.h" // ImagenTransparente IMPLEMENT_DYNAMIC(ImagenTransparente, CStatic) ImagenTransparente::ImagenTransparente(int nID, BYTE transparencia /* = 0x7f (50%) */) { bm.LoadBitmap(nID); bm.GetBitmap(&BitMap); m_nWidth = BitMap.bmWidth; m_nHeight = BitMap.bmHeight; bf.AlphaFormat = 0; bf.BlendFlags = 0; bf.BlendOp = AC_SRC_OVER; bf.SourceConstantAlpha = transparencia; this->nID = nID; } ImagenTransparente::~ImagenTransparente() { } BEGIN_MESSAGE_MAP(ImagenTransparente, CStatic) ON_WM_CREATE() ON_WM_PAINT() ON_WM_ERASEBKGND() ON_WM_MOVE() END_MESSAGE_MAP() // Controladores de mensajes de ImagenTransparente int ImagenTransparente::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CStatic::OnCreate(lpCreateStruct) == -1) return -1; CRect rect; GetWindowRect(&rect); GetParent()->ScreenToClient(&rect); miPosicion.left = rect.left; miPosicion.right = rect.right; miPosicion.top = rect.top; miPosicion.bottom = rect.bottom; this->izquierda = rect.left; this->arriba = rect.top; CClientDC dc(this); CDC MemDC; MemDC.CreateCompatibleDC(&dc); CBitmap MemBmp; MemBmp.CreateCompatibleBitmap(&dc, m_nWidth, m_nHeight); CBitmap *pOldMemBmp = MemDC.SelectObject(&MemBmp); CDC MemDC2; MemDC2.CreateCompatibleDC(&dc); CBitmap *pOldbmp = MemDC2.SelectObject(&bm); MemDC.BitBlt(0, 0, m_nWidth, m_nHeight, &MemDC2, 0, 0, SRCCOPY); MemDC2.SelectObject(pOldbmp); dc.AlphaBlend(0, 0, m_nWidth, m_nHeight, &MemDC, 0, 0, m_nWidth, m_nHeight, bf); MemDC.SelectObject(pOldMemBmp); return 0; } void ImagenTransparente::OnPaint() { CPaintDC dc(this); // device context for painting CDC MemDC; MemDC.CreateCompatibleDC(&dc); CBitmap MemBmp; MemBmp.CreateCompatibleBitmap(&dc, m_nWidth, m_nHeight); CBitmap *pOldMemBmp = MemDC.SelectObject(&MemBmp); CDC MemDC2; MemDC2.CreateCompatibleDC(&dc); CBitmap *pOldbmp = MemDC2.SelectObject(&bm); MemDC.BitBlt(0, 0, m_nWidth, m_nHeight, &MemDC2, 0, 0, SRCCOPY); MemDC2.SelectObject(pOldbmp); //dc.BitBlt(0, 0, m_nWidth, m_nHeight, &MemDC, 0, 0, SRCCOPY); dc.AlphaBlend(0, 0, m_nWidth, m_nHeight, &MemDC, 0, 0, m_nWidth, m_nHeight, bf); MemDC.SelectObject(pOldMemBmp); } BOOL ImagenTransparente::OnEraseBkgnd(CDC* p

      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