开发者

How to make label & other controls transparent with background image on windows mobile?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜