views:

47

answers:

1

I am developing the smart device application in C#. I am new to the windows mobile. I have added the background image to the form in my application by using the following code. I want to make label & other controls on this form transparent so that my windows form will be displayed properly.

protected override void OnPaint(PaintEventArgs e)
                {
                    base.OnPaint(e);
                    Bitmap CreateCustomerImage = new Bitmap(@"/Storage Card/background.png");
                    e.Graphics.DrawImage(CreateCustomerImage, 0, 0);
                }

how to do this ? How to solve this problem? Can you provide me any code or link through which I can solve the above issue?

A: 

Windows CE doesn't inherently support transparent controls, which tends to be a huge pain. You have to use something like ColorKey transparency, so in your OnPaint, you need to fill the background with a color (magenta is a popular one) and use SetColorKey to make that color transparent.

There are several tutorials online for colorkey transparency. Here is one that I just found with a search engine that looks reasonable but feel free to search for others as well.

The place this falls down is when you have controls in a container control, which is then on the Form. To get that to work right you have to cascade calls to clipping regions from the Form all the way down. I don't have a ready sample of this that isn't inside a shipping project, so I can't easily post it. If you run into this, though, update the question and I'll see if I can extract something.

ctacke