471,354 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Using a form purely programatically - by proxy.

Scenario:

Two System.Windows.Forms: Form1 and Form2.
Form1 is displayed, Form2 is hidden.

At this juncture, is it possible to take the graphics from Form2 and output
that to Form1's display and take all of the mouse and key events from Form1
and pass those on to Form2, thus changing the graphical output on Form2 and
then pasting those graphical changes back to Form1?
Is this some kind of P/Invoke job?

Regards

Jax
Feb 3 '06 #1
4 1378
Jax,

You can design this much better so that it is an easier operation.
Simply, have the contents of forms one and two contained in controls,
instead of forms, and then host both controls on the same form. Then, you
don't have to worry about all of the input switching and whatnot.

Also, one might ask, why not just hide form one and then show form two?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman {Uchiha Jax}"
<i_**********************************@NOSPAMhotmai l.com> wrote in message
news:Ff*******************@newsfe5-gui.ntli.net...
Scenario:

Two System.Windows.Forms: Form1 and Form2.
Form1 is displayed, Form2 is hidden.

At this juncture, is it possible to take the graphics from Form2 and
output
that to Form1's display and take all of the mouse and key events from
Form1
and pass those on to Form2, thus changing the graphical output on Form2
and
then pasting those graphical changes back to Form1?
Is this some kind of P/Invoke job?

Regards

Jax

Feb 4 '06 #2
I don't want the user of the program to directly see the windows controls, I
want to be able to capture the graphics of the controls of the hidden form,
and overlay those graphics on Form1 (on top of another bunch of stuff i'm
drawing).
Then translate the clicks on Form1 to Form2 so that the controls are
properly updated when the graphics are next captured from Form2 and
displayed on Form1.

This is essentially a simple hack of the GUI so I can implement dynamic
graphic arrangement and not have to worry about transparency issues or
implementing WinForm control functionality.
Does this make much sense to you?

Regs

Jax
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eA**************@TK2MSFTNGP09.phx.gbl...
Jax,

You can design this much better so that it is an easier operation.
Simply, have the contents of forms one and two contained in controls,
instead of forms, and then host both controls on the same form. Then, you
don't have to worry about all of the input switching and whatnot.

Also, one might ask, why not just hide form one and then show form two?
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman {Uchiha Jax}"
<i_**********************************@NOSPAMhotmai l.com> wrote in message
news:Ff*******************@newsfe5-gui.ntli.net...
Scenario:

Two System.Windows.Forms: Form1 and Form2.
Form1 is displayed, Form2 is hidden.

At this juncture, is it possible to take the graphics from Form2 and
output
that to Form1's display and take all of the mouse and key events from
Form1
and pass those on to Form2, thus changing the graphical output on Form2
and
then pasting those graphical changes back to Form1?
Is this some kind of P/Invoke job?

Regards

Jax


Feb 4 '06 #3
Simon,

Yes, it does, but I don't understand for the life of me WHY you would do
this, when you can just either show the original form, or create separate
controls. You are passing everything through to the form, as well as
displaying the form anyways.

If you REALLY want to do this, I really don't think that there is a good
way to do this.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman {Uchiha Jax}"
<i_**********************************@NOSPAMhotmai l.com> wrote in message
news:4%*****************@newsfe2-gui.ntli.net...
I don't want the user of the program to directly see the windows controls,
I
want to be able to capture the graphics of the controls of the hidden
form,
and overlay those graphics on Form1 (on top of another bunch of stuff i'm
drawing).
Then translate the clicks on Form1 to Form2 so that the controls are
properly updated when the graphics are next captured from Form2 and
displayed on Form1.

This is essentially a simple hack of the GUI so I can implement dynamic
graphic arrangement and not have to worry about transparency issues or
implementing WinForm control functionality.
Does this make much sense to you?

Regs

Jax
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:eA**************@TK2MSFTNGP09.phx.gbl...
Jax,

You can design this much better so that it is an easier operation.
Simply, have the contents of forms one and two contained in controls,
instead of forms, and then host both controls on the same form. Then,
you
don't have to worry about all of the input switching and whatnot.

Also, one might ask, why not just hide form one and then show form

two?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman {Uchiha Jax}"
<i_**********************************@NOSPAMhotmai l.com> wrote in message
news:Ff*******************@newsfe5-gui.ntli.net...
> Scenario:
>
> Two System.Windows.Forms: Form1 and Form2.
> Form1 is displayed, Form2 is hidden.
>
> At this juncture, is it possible to take the graphics from Form2 and
> output
> that to Form1's display and take all of the mouse and key events from
> Form1
> and pass those on to Form2, thus changing the graphical output on Form2
> and
> then pasting those graphical changes back to Form1?
> Is this some kind of P/Invoke job?
>
> Regards
>
> Jax
>
>



Feb 5 '06 #4
The purpose was a dynamic UI where the UI would be created via an image and
a mapping file (a black and white image specifying where the controls are,
for click events).
As this isn't a main element of the project i'm not prepared to build a
dynamic UI from the ground up as I don't want to re-invent the wheel (like a
textbox, button, listbox etc) as it will take too long.
This is the reason why the idea is odd, it's a simple hack.

So the idea was to get the graphics of the WinForm controls from elsewhere,
gather that up in a bitmap, paste the image (save the transparent coloured
parts) on top, then output to the display of the visible Form.
To to get around the issue of the click events, You could then specify
what is and what isn't a click by choosing to pass the click through only
when the click point matches that of a "white" pixel in the mapping file.
If that click could then update the "hidden" form (like, the selection of an
item in the listbox) and you could capture the graphics again and update the
selection to the UI. (Whoop!)

This would be a nice hack but I don't think it will be possible.
As our accesss to the WinForm GDI is very much a Control-Up system rather
than a Top-Down form of control it's a long job to implement this the
correct way.

I'm thinking that the best i'm going to get is creating customised controls
(for each control) to support transparency and using something like MyXAML
to enable the dynamic support.

Thanks for your help though and your time considering this concept.

Kind Regards
Jax

It's a suggestion
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
Simon,

Yes, it does, but I don't understand for the life of me WHY you would do this, when you can just either show the original form, or create separate
controls. You are passing everything through to the form, as well as
displaying the form anyways.

If you REALLY want to do this, I really don't think that there is a good way to do this.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman {Uchiha Jax}"
<i_**********************************@NOSPAMhotmai l.com> wrote in message
news:4%*****************@newsfe2-gui.ntli.net...
I don't want the user of the program to directly see the windows controls,I
want to be able to capture the graphics of the controls of the hidden
form,
and overlay those graphics on Form1 (on top of another bunch of stuff i'm drawing).
Then translate the clicks on Form1 to Form2 so that the controls are
properly updated when the graphics are next captured from Form2 and
displayed on Form1.

This is essentially a simple hack of the GUI so I can implement dynamic
graphic arrangement and not have to worry about transparency issues or
implementing WinForm control functionality.
Does this make much sense to you?

Regs

Jax
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:eA**************@TK2MSFTNGP09.phx.gbl...
Jax,

You can design this much better so that it is an easier operation.
Simply, have the contents of forms one and two contained in controls,
instead of forms, and then host both controls on the same form. Then,
you
don't have to worry about all of the input switching and whatnot.

Also, one might ask, why not just hide form one and then show form

two?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Simon Tamman {Uchiha Jax}"
<i_**********************************@NOSPAMhotmai l.com> wrote in message news:Ff*******************@newsfe5-gui.ntli.net...
> Scenario:
>
> Two System.Windows.Forms: Form1 and Form2.
> Form1 is displayed, Form2 is hidden.
>
> At this juncture, is it possible to take the graphics from Form2 and
> output
> that to Form1's display and take all of the mouse and key events from
> Form1
> and pass those on to Form2, thus changing the graphical output on Form2 > and
> then pasting those graphical changes back to Form1?
> Is this some kind of P/Invoke job?
>
> Regards
>
> Jax
>
>



Feb 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ben Crinion | last post: by
3 posts views Thread by =?Utf-8?B?YmJkb2J1ZGR5?= | last post: by
1 post views Thread by =?Utf-8?B?Z2FsbGFu?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.