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. Semi-transparent drawing

Semi-transparent drawing

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicshelpquestion
4 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.
  • N Offline
    N Offline
    Nuri Ismail
    wrote on last edited by
    #1

    I am using Microsoft visual c++ 6, and I want to draw shapes on a view. What i want is a displayed shape with a semi-transparent color i.e. we should still be able to see whatever is beneath the shape. Can anyone help me? Thanks.

    M V 2 Replies Last reply
    0
    • N Nuri Ismail

      I am using Microsoft visual c++ 6, and I want to draw shapes on a view. What i want is a displayed shape with a semi-transparent color i.e. we should still be able to see whatever is beneath the shape. Can anyone help me? Thanks.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You could use GDI+[^]

      // (GDI+ initialization omitted)

      // Draw a red line from 0,0 to 400,400 with 25% opacity
      Gdiplus::Graphics g(hwnd, 0);
      Gdiplus::Pen p(Color(64, 255, 0, 0), 10); // alpha value 64
      g.DrawLine(&p, 0, 0, 400, 400);

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      N 1 Reply Last reply
      0
      • M Mark Salsbery

        You could use GDI+[^]

        // (GDI+ initialization omitted)

        // Draw a red line from 0,0 to 400,400 with 25% opacity
        Gdiplus::Graphics g(hwnd, 0);
        Gdiplus::Pen p(Color(64, 255, 0, 0), 10); // alpha value 64
        g.DrawLine(&p, 0, 0, 400, 400);

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        N Offline
        N Offline
        Nuri Ismail
        wrote on last edited by
        #3

        Thank you very much for your answer! :) It works fine, thanks again!

        1 Reply Last reply
        0
        • N Nuri Ismail

          I am using Microsoft visual c++ 6, and I want to draw shapes on a view. What i want is a displayed shape with a semi-transparent color i.e. we should still be able to see whatever is beneath the shape. Can anyone help me? Thanks.

          V Offline
          V Offline
          vikas amin
          wrote on last edited by
          #4

          you need to understand and use Alpha Blend http://www.codeproject.com/KB/winsdk/quaker1.aspx[^] this is a .net application does exactly what you need http://www.codeproject.com/KB/GDI-plus/alphafx.aspx#TOC3[^]

          Vikas Amin

          My First Article on CP" Virtual Serial Port "[^]

          modified on Thursday, July 24, 2008 5:33 PM

          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