Re: Sending message to another window



"Jeff Williams" <jeff.williams_NO_SPAM@xxxxxxxxxxxxxxx> wrote in message news:132ve7feebdn61e@xxxxxxxxxxxxxxxxxxxxx
I have an application using dial monitors which is used in an aution room.

The auctioneer has a form showing details of the current lot number. As he changes to the next lot number I need to send a message to a form on the other monitor to change to picture to this new lot.

Shat is the best way to have a form send a message to another form.

ie Monitor one is showing lot 10 details and the monitor two is showing the picture of lot 10. The auction moves to the next lot on his screen (lot 11) and the form on the second monitor now updates with the details of lot 11.

Are the monitors attached to the same computer? With a single .NET application showing one .NET form on each monitor?

If so, then the answer is as simple as referencing one form from the other. For example:

class Form1
{
private Form2 _form2;

public Form1()
{
_form2 = new Form2();
_form2.Show();
}

private void _UpdateText(string strNewText)
{
labelDetails.Text = strNewText;
_form2.labelDetails.Text = strNewText;
}
}

Unless you've done something whacky, both forms should be owned by the same thread. But if not, you will have to use Invoke() or BeginInvoke() in the _UpdateText() method shown above. Still, not very hard.

The controls on the form are likely going to be "private" by default. So you'll need to change the access in the property browser to maket them public so that the first form can access them. Alternatively, provide a public method on the second form's class that the first form can call, which then accesses the private control.

For images, just change the example as necessary to set whatever data you want on whatever property of the form you want. The primary form could just figure out what image the slave form needs to show, and set it explicitly, or the slave form could maintain it's own list of images with the primary form just calling a method on the slave form that takes some kind of index as a parameter. The specifics don't matter much; the important thing to understand is that you can maintain a reference in the primary form to the slave form and do whatever it is you need to do like that.

If the two monitors are on two different computers, and/or the display for each monitor is handled by two different processes, then it gets more complicated. You'll need to use some sort of inter-process communications, such as remoting or sockets to pass the updates from the primary display to the slave display.

Pete

.



Relevant Pages

  • Re: Reddish grayscale result
    ... one showing in Photoshop looks like a 16 bit image -- but I see how ... your monitor is much higher than the press can, ... just greyscale, without tints. ... create and use another color profile for windows. ...
    (alt.graphics.photoshop)
  • Re: Monitor a Particular Process
    ... which under the tasklist /svc is showing up as the ... Conversation: Monitor a Particular Process ... the PID column to the view and the order by CPU usage. ... which I can set up that will trace which particular process is causing ...
    (microsoft.public.windows.server.sbs)
  • Re: Every magic show on tv is not exciting anymore!
    ... At card tricks or his wife/gf? ... He has a big monitor showing close ups of the cards to the ... the magician, ...
    (rec.arts.tv)
  • Re: Extra users!
    ... Sharon Kimble wrote: ... > monitor is showing four users, except that this is a stand-alone and not ... I would regularly see two processes related to bonobo showing ... users on my GKrellm monitor! ...
    (Fedora)