locked
How to display an transparent PNG in webbrowser control? RRS feed

  • Question

  • I complie all my html, gif, png, css, js into win32 resource, and i access the resources with webbrowser through RES protocol.

    It worked fine except the alpha png picture. the webbrowser control didn't display alpha png properly( the background isn't tranparent ), and unfortunately, the

     DXImageTransform.Microsoft.AlphaImageLoader filter isn’t compatible with the RES protocol.

    any good idea to display the png.

    Thanks.
    • Moved by nobugz Saturday, April 4, 2009 2:58 PM not a wf q
    Saturday, April 4, 2009 7:52 AM

Answers

  • I think the easiest and simplest way to do it is simply lay a transparent form over top of your current form.  Here's a sample transparent form.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    
    namespace TransparentForm
    {
        public class SeeThroughForm : Form
        {
            public SeeThroughForm()
            {
                InitializeComponent();
            }
    
            private Label label1;
            private Button button1;
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.label1 = new System.Windows.Forms.Label();
                this.button1 = new System.Windows.Forms.Button();
                this.SuspendLayout();
                // 
                // label1
                // 
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(51, 46);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(35, 13);
                this.label1.TabIndex = 0;
                this.label1.Text = "label1";
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(54, 140);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 23);
                this.button1.TabIndex = 1;
                this.button1.Text = "button1";
                this.button1.UseVisualStyleBackColor = true;
                // 
                // SeeThroughForm
                // 
                this.BackColor = System.Drawing.Color.Blue;
                this.ClientSize = new System.Drawing.Size(220, 199);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.label1);
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                this.Name = "SeeThroughForm";
                this.Opacity = 0.5;
                this.TransparencyKey = System.Drawing.Color.Blue;
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
            #endregion
        }
    }
    

     

    Hope this helps.

     

    Rudedog  =8^D


    Mark the best replies as answers. "Fooling computers since 1971."
    Saturday, April 4, 2009 2:36 PM