PC Review


Reply
Thread Tools Rate Thread

How to create an Always On Top window?

 
 
Anderson Takemitsu Kubota
Guest
Posts: n/a
 
      15th Sep 2003
Hi,

Does anybody know how to create an Always on top window?
I have a form that will call a non maximized modeless window, and when I set
the focus for the first one, I don't want that it was hidden.
Any help?

Thanks,
Anderson


 
Reply With Quote
 
 
 
 
Dan Elliott [MSFT]
Guest
Posts: n/a
 
      17th Sep 2003
Anderson,

If I understand you correctly, you want a child window that will be
displayed on top of the main window when the main window is active. This
can be accomplished by setting the Parent property of the child window to
the form of the main window. For instance, if Form1 represents the main
window and Form2 the child window:

class public Form1
{
Form2 form2;

private void Form1_Load(object sender, System.EventArgs e)
{
this.form2 = new Form2();
this.form2.Parent = this;
this.form2.Show();
}

...
}

class public Form2
{
...
}


That said, here are some caveats:
* If you want the child form's border to be something besides
FormBorderStyle.None, you will need to set the FormBorderStyle property
twice during Form_Load. There is a bug that causes the child form to be
drawn without a border (FormBorderStyle.None) initially no matter what the
FormBorderStyle is set to. I've been able to work around this with the
following code:
private void Form2_Load(object sender, System.EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}

* The child form's size will be set to the width of the parent form and
nearly the height of the parent form unless you explicitly set it in the
Form_Load method. For example:
private void Form2_Load(object sender, System.EventArgs e)
{
this.Size = new Size(124, 162);
}
* The title bar is not drawn in the active title bar color scheme when the
window has focus. I haven't found a workaround for this.
* Set the ControlBox property to false to get rid of the Ok button in the
title bar of the child form. It doesn't close the window or fire an event.

Hope this is helpful. If you have any questions, please let me know.
Dan

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a new pop-up window =?Utf-8?B?TWlrZQ==?= Microsoft Frontpage 3 19th Jan 2006 10:14 PM
Create an About window =?Utf-8?B?R3JhbmRwYUI=?= Microsoft VB .NET 2 23rd Oct 2005 02:46 PM
Can you create window tabs within MS Access window? =?Utf-8?B?U2Vhbg==?= Microsoft Access 0 22nd Jun 2005 08:12 PM
Forms in Modal IE Window create a new window on postback! =?Utf-8?B?TmljayBQb3VsaXM=?= Microsoft ASP .NET 5 3rd Jun 2005 03:46 PM
How to use an asp:button to create a new browser window and output contents to new window =?Utf-8?B?Tm92aWNl?= Microsoft ASP .NET 2 9th Jun 2004 11:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:02 PM.