Skip to content

Updating translucent forms, very slow

chris jones

Asked Jan 9, 2007, 6:37 AM EST6 answers
Share
LinkedInX
I have a Windows form, I call the method DrawToBitmap on the form. I altered the bitmap with some drawing objects.


I now want to overlay this bitmap with transparent parts over my form. Unfortunately my form contains some controls, which do not seem to want to get overlaid. the axbouser.


unFortunately, the only way I can do this is to have a semitransparent second form and place my bitmap as a background image. This method works very well with the exception It is incredibly slow.

Does anyone know how to draw my image over my form without the need to use resource intensive translucent forms?

6 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Aww man - typed out a massive reply to this post, and it got lost! :o( Here goes again then...

    Ok, 2 main ways of doing this, depending on where you're declaring your child form. I'll use the local scope version, which is probably not the best way to do it, but easier for me to explain!

    class ParentForm
    {
          string m_UserName;

          private void OnButton1Click()
          {
              // declare new attack form
              AttackForm myChildForm = new AttackForm();
              if (myChildForm.ShowDialog() == DialogResult.OK)
              {
                   // retrieve variables from Attack Form instance
                   m_UserName = myChildForm.myName;
              }
          }
    }

    In the AttackForm you'll need to introduce a property to return the variable (not certain 'Property' is the correct terminology), e.g.

    public string myName
    {
         get
         {
              return tbxUserName.Text;
         }
    }

    Hope this helps. I do need to mention I'm new to C#, so any mistakes above, please forgive me. I've built a simple app to demonstrate what I'm doing and it worked for me!

    Cheers,
    Greg

    0
  • 0

    Aww man - typed out a massive reply to this post, and it got lost! :o( Here goes again then...

    Ok, 2 main ways of doing this, depending on where you're declaring your child form. I'll use the local scope version, which is probably not the best way to do it, but easier for me to explain!

    class ParentForm
    {
          string m_UserName;

          private void OnButton1Click()
          {
              // declare new attack form
              AttackForm myChildForm = new AttackForm();
              if (myChildForm.ShowDialog() == DialogResult.OK)
              {
                   // retrieve variables from Attack Form instance
                   m_UserName = myChildForm.myName;
              }
          }
    }

    In the AttackForm you'll need to introduce a property to return the variable (not certain 'Property' is the correct terminology), e.g.

    public string myName
    {
         get
         {
              return tbxUserName.Text;
         }
    }

    Hope this helps. I do need to mention I'm new to C#, so any mistakes above, please forgive me. I've built a simple app to demonstrate what I'm doing and it worked for me!

    Cheers,
    Greg

    0
  • 0
    That works, but the only issue is that I am not spawning the form from the parent form, lol. Here is what I am doing- I have a register form named PromptBox that is required for you to go through, it is a child form to GameForm. Now when you properly register and the PromptForm closes it spawns AttackForm and assigns its parent as GameForm using the syntax below-
    Code
    AttackForm newForm = new AttackForm();
    newForm.MdiParent = this.ParentForm;
    newForm.Show();
    this.close();
    That way I can keep the parent of all of my forms the same. So since the child form is not called by its parent form, GameForm, I cant use that code, lol. Its kind of a pain in the butt the way Im doing it but there has to be a way it can be fixed to where I spawn AttackForm from PromptForm, assign GameForm as AttackForm's parent, and then pass variables from AttackForm to GameForm. This is the most difficult thing Ive come across so far, but Im almost a C# newbie so I thank you for all the help.
    0
  • 0
    That works, but the only issue is that I am not spawning the form from the parent form, lol. Here is what I am doing- I have a register form named PromptBox that is required for you to go through, it is a child form to GameForm. Now when you properly register and the PromptForm closes it spawns AttackForm and assigns its parent as GameForm using the syntax below-
    Code
    AttackForm newForm = new AttackForm();
    newForm.MdiParent = this.ParentForm;
    newForm.Show();
    this.close();
    That way I can keep the parent of all of my forms the same. So since the child form is not called by its parent form, GameForm, I cant use that code, lol. Its kind of a pain in the butt the way Im doing it but there has to be a way it can be fixed to where I spawn AttackForm from PromptForm, assign GameForm as AttackForm's parent, and then pass variables from AttackForm to GameForm. This is the most difficult thing Ive come across so far, but Im almost a C# newbie so I thank you for all the help.
    0
  • 0
    on the parent for add the following

    protected Form myChild;

    public Form MyChild{
    get{return myChild;}
    set{myChild = value;}
    }

    the add the following to the child form

    parent.MyChild = me;

    this has to be called after you've canged the this.ParentForm
    0
  • 0
    on the parent for add the following

    protected Form myChild;

    public Form MyChild{
    get{return myChild;}
    set{myChild = value;}
    }

    the add the following to the child form

    parent.MyChild = me;

    this has to be called after you've canged the this.ParentForm
    0