Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / January 2005

Tip: Looking for answers? Try searching our database.

MessageBox.Show() - KeepOnTop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 17 Jan 2005 21:21 GMT
Hi;

How do I set a message box to KeepOnTop so it is above all other windows?
Signature

thanks - dave

"Peter Huang" [MSFT] - 18 Jan 2005 07:50 GMT
Hi

I think you may try to use the SetWindowPos API.
SetWindowPos Function
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui
/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setw
indowpos.asp

Here is a link you may take a look.
C# Tip: Making Windows Forms Pop Under
http://www.developer.com/net/csharp/article.php/3347251

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

David Thielen - 18 Jan 2005 08:47 GMT
For a Form it's a piece of cake - there is a KeepOnTop property. But is there
any way to do this for a MessageBox? There is I believe for the underlying
Windows API MessageBox.

thanks - dave

> Hi
>
[quoted text clipped - 15 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 19 Jan 2005 01:36 GMT
Hi

I think the .NET code will call the win32 API underlying. For the
MessageBox, it is a method while not a type in the .NET, so we do not have
property to do that.
But I think another alternative is to call the form's showdialog method,
which is modal as the messagebox do you may have a try to see if that works
for you.

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

David Thielen - 19 Jan 2005 02:37 GMT
Hi;

Asking again - does anyone out there know of a way to do this other than
creating a Form and sizing it, hiding/showing buttons, etc. to make my own
MessageBox?

thanks - dave

> Hi
>
[quoted text clipped - 12 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 20 Jan 2005 04:09 GMT
Hi

If so, I think you may try to call the MessageBox API directly which
provide more options than the .NET version.

public class MBSpecial
{
    public const UInt32 MB_SETFOREGROUND =               0x00010000;
    public const UInt32 MB_DEFAULT_DESKTOP_ONLY =        0x00020000;
    public const UInt32 MB_SERVICE_NOTIFICATION_NT3X =   0x00040000;
    public const UInt32 MB_TOPMOST =                     0x00040000;
    public const UInt32 MB_RIGHT =                       0x00080000;
    public const UInt32 MB_RTLREADING =                  0x00100000;
    public const UInt32 MB_SERVICE_NOTIFICATION =        0x00200000;
}

[DllImport("user32", EntryPoint="MessageBox")]
public static extern int MessageBoxA(IntPtr hwnd, string lpText, string
lpCaption, UInt32 wType);
private void button2_Click(object sender, System.EventArgs e)
{
    MessageBoxA(this.Handle,"test","test",MBSpecial.MB_TOPMOST);
}

MessageBox Function
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui
/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunc
tions/messagebox.asp

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

David Thielen - 20 Jan 2005 06:39 GMT
Thank you - that works. I hope with .NET 2.0 I won't have to make so many
calls to the unmanaged Win32 API.

thanks - dave

> Hi
>
[quoted text clipped - 32 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 20 Jan 2005 09:50 GMT
Hi

I am glad that works for you!
We will keep improving our product.
Also you may try to submit the feedback to our mswish website.
http://register.microsoft.com/mswish/suggestion.asp

Thanks!

Best regards,

Perter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.