21730

Windows Forms Glass Effect, Make ImageBox transparent

Question:

I have a windows form application, and I have extended the window's frame into the client area using DwmExtendFrameIntoClientArea to get the glass effect.

Now I'm trying to show a transparent PNG image in a picture box, however the background shows up as white instead of the glass effect. How can i make the image show as transparent so that i only see the rounded gray rectangle and not the white background.

My screenshot is below. Thanks.

<img alt="alt text" class="b-lazy" data-src="https://i.stack.imgur.com/Ra6o8.png" data-original="https://i.stack.imgur.com/Ra6o8.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

<img alt="alt text" class="b-lazy" data-src="https://i.stack.imgur.com/xkeyH.png" data-original="https://i.stack.imgur.com/xkeyH.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

Ok, this is a kind of easy to fix problem with winforms.....what you have to do, like blam said is set the transparency key to something like: R:1, G:2, B:3...this makes everything inside your form drawn in that color transparent...all you need to do then is set the background color of your imagebox to that color...and it should draw the image's background transparently (as long as your image has transparency)

Answer2:

Make it whatever the colour key for the glass is: Black iirc.

Recommend

  • How to define matching axis notches from existing “step list”
  • different results with and without SSE ( float arrays multiplication)
  • removing the default blue color on focus
  • write text on image and show it to a imageview
  • Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
  • How to change placeholder text in an autocomplete activity of android google place?
  • How to split circle in to the sectors in google maps?
  • Why does it draw lines in the wrong place?
  • Floated image with variable width and heading with background image
  • Django model inheritance, filtering models
  • AndEngine Applying Transparancy to AndEngine View
  • Z3: Convert between FP and BitVector?
  • ViewController With Transparent Background Entering Current ViewController With Push Transition
  • How can I speed up CURL tasks?
  • Ajax calls do not work in IE unless you fiddle with security settings
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Keep this build forever option - Jenkins
  • How to have background script and something similar to a default popup?
  • Python urlparse: small issue
  • Google Custom Search with transparent background
  • Android fill_parent issue
  • FileReader+canvas image loading problem
  • Repeat a vertical line on every page in Report Builder / SSRS
  • CSS Linear-gradient formatting issue accross different browsers
  • Problems to linebreak with an int in JLabel
  • How to draw moving and Running sine wave chart using JFree chart in java?
  • Controls, properties, events and timers running in design time
  • Sending data from AppleScript to FileMaker records
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Updated Ionic CLI but shows previous version (Windows)
  • How to show dropdown in excel using jrxml (jasper api)?
  • GridView Sorting works once only
  • How to format a variable of double type
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Load html files in TinyMce
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • python draw pie shapes with colour filled