[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Nutty Custom-Shaped WinForm BG

Posted on 2006-11-10
3
Medium Priority
?
728 Views
Last Modified: 2010-05-18
I have a lovely WinForm that uses a custom shape.  The bitmap used in its BackgroundImage property has a transparent color, and the WinForm has that TransparencyKey property and I have all that set correctly.  Works great.

But what I really want my form to be able to do is to set its own BackgroundImage property dynamically, using an on-board ImageList control.

Problem is, when I dynamically have the form set its own background image, I lose that wonderful transparency.  Suddenly, the entire image that I use to create my custom-shaped form is visible, in all its ugliness.  The color that should be transparent (white) is suddenly opaque (black).  All because rather than setting my form's BackgroundImage property at design-time and compiling it in, I'm trying to dig it out of an ImageList.

Any ideas on how I can get dynamic background images to work here?  I don't want to load them from a subfolder on the fly or anything kooky like that.  The images need to be on-board.

Thanks.
0
Comment
Question by:bryker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
cybercrew earned 1000 total points
ID: 17920286
Have you tried embedding the images in a resource file?  One other thing you might try is calling this.Refresh() after changing the background.

1.  In your Solution Explorer expand the Properties folder.
2. Double click on  Resources.resx
3. In Resource Designer click on  Add Resource.
4. The select "Add Existing File"
5. Locate your image files and them.
6. For each image check the properties window to make sure they are embedded into the resource file and not linked.
7.  You can now access your images by typing <your project namespace>.Properties.Resources.<name of Image>

Example:  (Blue_Lace_16 and Feather_Texture are the names of image files embedded in my Resources.resx file)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ResourceFiles
{
    public partial class Form1 : Form
    {
        private bool toggle = false;
        public Form1()
        {
            InitializeComponent();
           
           
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.BackgroundImage = ResourceFiles.Properties.Resources.Blue_Lace_16;
           
        }


        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            if (toggle == false)
            {
                toggle = true;
                this.BackgroundImage = ResourceFiles.Properties.Resources.FeatherTexture;
            }
            else{
                toggle = false;
                this.BackgroundImage = ResourceFiles.Properties.Resources.Blue_Lace_16;}
            this.Refresh();
        }
    }
}
0
 

Author Comment

by:bryker
ID: 17961349
Sorry, Cyber.  I really am going to get to this in the next few days, then I'll be able to grade your suggestion.  Thanks for your patience.
0
 

Author Comment

by:bryker
ID: 18036946
Okay, Cyber, I haven't gotten around to testing this, but I can't leave you hanging any longer in good conscience.  I'm assuming it's going to work for me.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question