locked
Windows CE 7 - Transparent or opacity RRS feed

  • Question

  • Hi,

    How to make the Form or Window transparent in Windows CE 7.
    I need to create a panel size of 480 px width and 100 px height with 3 buttons. Which should get displayed at the bottom of the screen always on top of all the application.
    Does anyone know how to make the panel transparent or set the opacity level? 

    I haven't found a sample to achieve the above behaviour. Any sample or advice is very much appreciated.

    Thanks,
    Lourdhu

    Friday, January 3, 2014 6:06 PM

Answers

  • Hi,

    opacity can only work on top-level windows.  It uses a hardware feature of the video adapter, that doesn't support child windows, like Panel.  The only top-level Control derived class in Winforms is Form.

    Several of the 'pure' Winform controls, the ones that do their own painting instead of letting a native Windows control do the job, do however support a transparent BackColor.  Panel is one of them.  It uses a trick, it asks the Parent to draw itself to produce the background pixels.  One side-effect of this trick is that overlapping controls doesn't work, you only see the parent pixels, not the overlapped controls.

    This sample form shows it at work:

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            this.BackColor = Color.White;
            panel1.BackColor = Color.FromArgb(25, Color.Black);
        }
        protected override void OnPaint(PaintEventArgs e) {
            e.Graphics.DrawLine(Pens.Yellow, 0, 0, 100, 100);
        }
    }

    Thx.

    • Marked as answer by Eileen ni Wednesday, January 15, 2014 2:14 AM
    Wednesday, January 8, 2014 2:03 AM