Hi all,
Need a little help!!!

I want to create an windows application such that there are 2 forms:
form1 and form2

i want the form2 to be in background of form1 and form2 should be never seen(even when form1 is minimised,maximised,resized and if some other application is opened).

code i have used is:

   Form2 obj = new Form2();
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        obj.Show();
    }

    private void Form1_Move(object sender, EventArgs e)
    {
        obj.Location = this.Location;
    }

    private void Form1_Resize(object sender, EventArgs e)
    {
        obj.Size = this.Size;
        if (this.WindowState == FormWindowState.Minimized)
        {
            obj.Hide();
        }
        if (this.WindowState == FormWindowState.Normal)
        {
           obj.Show();
        }

    }

all the forms should be modeless dialogs(using show() function)

Using this, sometimes, i get the form2 loaded before loading form1, can this situation be avoided.? because i want the form2 always in background.

Thanks in advance.

Recommended Answers

All 9 Replies

What is the purpose of form2?

I don't understand why you would do this, but here's the dig. Form 1's "load" event fires before it is shown, if you want to show form 2 after form 1, then put the obj.show() code in the form's "shown" event, not its "load" event.

But first, evaluate why you are doing this, and be sure you are really benefiting from 2 forms.

Thanks for the reply..
but this is a trial project i am doing ,in which form1 should always be in the foreground and form2 shouldn't overlap it.This may sound silly but this is wat i need to do !!!

the Real scenario is :

i had form1 with 100% opacity. A 3d object (cuboid) will be rotating continously in a part of form1[every 100 ms it'll be changing the angle for rotation].For certain input conditions , i need to load "form3" above form1 .form3 is grey color and has 65% opacity [such that the object rotation can be seen through this grey transparent form].
But when i loaded the form3 , flickering happened in the grey screen due to object rotation in form1[due to redraw of object in openGL control].

i changed the form1's opacity to 99% and the flickering vanished in form3.But form1 was little transparent and all items in the desktop was seen. To avoid this , i loaded the form2 behind form1.

Can u help me in this scenario? is there any way to stop the flickering effect in form3?

Sorry. I couldn't begin to understand why you would want to do such a thing, but I'm not sure how to help, and I don't think that could possibly be the best way to handle the situation.

hello diamondrake,

I know its not the best way to handle.But i need to stop the flickering effect in
form3.
:-(

Instead of trying to fix something that's being done in a slightly odd (and definitely inconvenient) way, why not explain to us what it is that you ultimately want to achieve? Maybe we could offer some advice on how to do it more efficiently. You should never have to use 3 forms for 1 window.

I think that he is trying to get the 3d cuboid rotating behind a translucent screen of some sort to give the impression of a dirty window or smoke or ???

I have no experience with openGL, but is it not possible to use another openGL object in front of the cuboid to achieve this effect instead of using another form?

@nick.crane:
"I think that he is trying to get the 3d cuboid rotating behind a translucent screen of some sort to give the impression of a dirty window or smoke or ???'"

------it is exactly what i wanted to do!

" is it not possible to use another openGL object in front of the cuboid to achieve this effect instead of using another form?"

---- it is need to use another form rather than using another openGL(couldn't avoid it!!!)

You can just draw a plane on top of the cube. It's very simple to do with OpenGL. Remember, you're not restricted to drawing just 1 object. Question: How are you rotating the cube? Are you using a transform matrix on the object itself, or on the view matrix?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.