Hi,

I am having a few problems with using the TopMost property for dialogs.
The problem centers around the fact that I have a main dialog which as
a central map and at certain positions on this map I need to display
small message boxs to represent information regarding this point. These
message boxs are simple forms with a ew text fields and labels.
The problem I am having is that I need to set the TopMost property of
the forms to true if I want to see more than one message at a time.

I am creating these message forms dynamically when the user clicks the
correct positon on the main map. What happens is that after the first
message form, the second one makes the first one disappear under the
main form.
If I set the TopMost property then they all appear but when I minimise
the main form, the message dialogs remain on the desktop.

if (e.Button == MouseButtons.Left)
{
Point pt = new Point(e.X, e.Y);
foreach(IconDetails icon in icons)
{
Point pt1 = icon.GetLocation();
Rectangle rect = new Rectangle( pt1.X, pt1.Y, 30, 30);
if (rect.Contains(pt))
{
VMSSiteObject vmsObj =
vmsSiteObjects.GetBySCN(icon.GetDescription());
if (vmsObj != null)
{
ArrayList listOfDisp = (ArrayList)vmsObj.VMSDisplayObjects;
ArrayList disp = (ArrayList)listOfDisp[0];
int mods = disp.Count;
site = new siteDlg(vmsObj);
sz.Width = site.Size.Width - 8;
if (mods > 1)
sz.Height = site.Size.Height + ((mods-1) * 8);
else
sz.Height = site.Size.Height;
}
break;

if (site != null)
{
site.Tag = icon.GetDescription();
siteDlgs.Add(site);
site.Show();
site.Size = sz;
}
}
}
}


Is there another way I could show these forms without having to set the
TopMost property.

Re: Problem with using TopMost property by Stoitcho

Stoitcho
Mon Mar 13 12:36:32 CST 2006

TheJediMessiah,

Don't use the parameterless overload of the Show method.
Rather call

form.Show(mainForm);

This way the main form will be the owner of the small forms and they will
stay infront of it and minimize along.



--
HTH
Stoitcho Goutsev (100)

"TheJediMessiah" <wakthar@gmail.com> wrote in message
news:1142267128.183110.9150@i39g2000cwa.googlegroups.com...
> Hi,
>
> I am having a few problems with using the TopMost property for dialogs.
> The problem centers around the fact that I have a main dialog which as
> a central map and at certain positions on this map I need to display
> small message boxs to represent information regarding this point. These
> message boxs are simple forms with a ew text fields and labels.
> The problem I am having is that I need to set the TopMost property of
> the forms to true if I want to see more than one message at a time.
>
> I am creating these message forms dynamically when the user clicks the
> correct positon on the main map. What happens is that after the first
> message form, the second one makes the first one disappear under the
> main form.
> If I set the TopMost property then they all appear but when I minimise
> the main form, the message dialogs remain on the desktop.
>
> if (e.Button == MouseButtons.Left)
> {
> Point pt = new Point(e.X, e.Y);
> foreach(IconDetails icon in icons)
> {
> Point pt1 = icon.GetLocation();
> Rectangle rect = new Rectangle( pt1.X, pt1.Y, 30, 30);
> if (rect.Contains(pt))
> {
> VMSSiteObject vmsObj =
> vmsSiteObjects.GetBySCN(icon.GetDescription());
> if (vmsObj != null)
> {
> ArrayList listOfDisp = (ArrayList)vmsObj.VMSDisplayObjects;
> ArrayList disp = (ArrayList)listOfDisp[0];
> int mods = disp.Count;
> site = new siteDlg(vmsObj);
> sz.Width = site.Size.Width - 8;
> if (mods > 1)
> sz.Height = site.Size.Height + ((mods-1) * 8);
> else
> sz.Height = site.Size.Height;
> }
> break;
>
> if (site != null)
> {
> site.Tag = icon.GetDescription();
> siteDlgs.Add(site);
> site.Show();
> site.Size = sz;
> }
> }
> }
> }
>
>
> Is there another way I could show these forms without having to set the
> TopMost property.
>



Re: Problem with using TopMost property by TheJediMessiah

TheJediMessiah
Tue Mar 14 11:02:19 CST 2006

Is there an overloaded show method?


Re: Problem with using TopMost property by Stoitcho

Stoitcho
Tue Mar 14 11:57:39 CST 2006

Yes, there are two overloads of the Form's Show method.
This is for .NET 2.0 only thought.
For .NET 1.x you need to set the form's owner property to be the main form


--
HTH
Stoitcho Goutsev (100)

"TheJediMessiah" <wakthar@gmail.com> wrote in message
news:1142355739.703274.117260@j52g2000cwj.googlegroups.com...
> Is there an overloaded show method?
>