4 Replies - 1091 Views - Last Post: 30 July 2012 - 09:05 PM Rate Topic: -----

#1 Alyssa Saila  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 07-January 12

A Simple Class To Paint (Create) New Form

Posted 29 July 2012 - 09:33 PM

I'm trying to paint a form behind a form with the following call..

Form newFormWithBkgd1 = Create_Form_Background.Paint(this);
Form newFormWithBkgd2 = Create_Form_Background.Paint(form2);
Form newFormWithBkgd3 = Create_Form_Background.Paint(form3Etc);

newFormWithBkgd1.Show();
newFormWithBkgd2.Show();
newFormWithBkgd3.Show();



My Objective: Simply to make an opaque form (which I can adjust) without
causing all of the child controls to be made opaque as well.

I "thought" I could create a new transparent form beneath it.
I figured if it was the same size, and moved as it moved all would be well.

This is a very simple idea I've made way too complicated.

Can anyone please point me in the right direction, even if it means
scrapping the code beneath. I'm willing to get to the bottom of this anyway
possible.

I just need a way to make the form opaque,
without changing the appearance of it's controls.

Note:

// this does help me for what I'm trying to do, the opacity is always 100%
this.TransparencyKey = ...
// also.. this does not help because parent "this" control doesn't support background colors
this.BackColor = Color.FromArgb(20, 0, 70, 173);




Anyway, here is my code.

using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public class Create_Form_Background
    {
        private static Form Foreground    { get; set; }
        private static Form Background    { get; set; }
        private static int BorderWidth    { get; set; }
        private static int BorderHeight   { get; set; }
        private static Color PaintedColor { get; set; }
        private static double Opaqueness  { get; set; }

        public Form Paint(Form paintForeground,
						  string backgroundColor = "Black",
						  double opacity         = 0.25,
						  int borderWidth        = 25,
						  int borderHeight       = 25)
        {
            Foreground   = paintForeground;
            PaintedColor = Color.FromName(backgroundColor);
            Opaqueness   = opacity;
            BorderWidth  = borderWidth;
            BorderHeight = borderHeight;

            Background = new Form();
            CreateForm();

            return Background;
        }

        private void CreateForm()
        {
            SetSize();
			// I was going to use a simple EventHanlder for the location
            SetLocation(); // Background.Location = Foreground.Location
            SetBackColor();
            SetOpaqueness();
            SetFormBorderStyle();
            SetWindowAttributes();
        }

    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: A Simple Class To Paint (Create) New Form

#2 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4928
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: A Simple Class To Paint (Create) New Form

Posted 30 July 2012 - 04:25 AM

we've talked before about learning before doing... But you keep coming up with this weird stuff from scratch anyway...

What is it you are trying to do and don't say paint a form behind a form as you've said that and there is no logic to this. what is the purpose of the form behind a form? You have to ask yourself if what you a doing is not done by anyone else, not used in any other program, not in any way normal... Then are you way off track in solving an problem?
Was This Post Helpful? 0
  • +
  • -

#3 Alyssa Saila  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 07-January 12

Re: A Simple Class To Paint (Create) New Form

Posted 30 July 2012 - 05:31 AM

Damn it tlhIn'toq can't you see I'm writing revolutionary code that will change the world! :)

Kidding. Anyway,..

I am simply trying to make an opaque form which I can adjust the opacity of.
I'm trying to accomplish this without changing the child controls of the form (because if I adjust the opacity of a form as of now it sets the opacity for all of the forms child controls as well).

There is no revolutionary logic here, I just like the way it would look! That's it.
An opaque form with non-opaque controls.

I always research & try before posting, even at risk of getting called weird & crazy.

*Note, I am admittedly weird & slightly crazy I suppose. :)

But if you can help me with this I would be super appreciative thln'toq.

Was This Post Helpful? 0
  • +
  • -

#4 Alyssa Saila  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 07-January 12

Re: A Simple Class To Paint (Create) New Form

Posted 30 July 2012 - 08:53 PM

I found what I was looking for...

Only problem is now I don't know how to load the source code they've provided on the page.

This exceeds my knowledge of C# a bit -which doesn't take much, but I was hoping someone could help me throw this together. I was hoping to see a solution file I could click on and run. I didn't see one, I saw a bunch of a classes and other things, but I'm not sure how to compile it all together running.

Please Click Resource Link Here


Posted Image


Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1939
  • View blog
  • Posts: 5,774
  • Joined: 05-May 12

Re: A Simple Class To Paint (Create) New Form

Posted 30 July 2012 - 09:05 PM

Are you sure that is what you want? Look at button3 and how transparent it is. I thought you didn't want any of the controls to be affected.

Nevermind. I see in that is supposed to be controllable whether child controls are affected or not.

This post has been edited by Skydiver: 30 July 2012 - 09:06 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1