473,769 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TopMost Form And A Dialog Box Created From A Static Method

Hi,

I have a dialog box that must behave as MessageBox does
with regard to the TopMost property. It must be TopMost if
and only if the calling form is TopMost. A static method
creates the dialog box. Is there a way of determining if the
application is TopMost from a static method?

There are some inelegant workarounds but I would prefer to
do whatever MessageBox does.

Thanks,
Gary
Aug 23 '07 #1
1 2044
On Aug 23, 9:58 am, "Gary Brown" <garyjbr...@cha rter.netwrote:
Hi,

I have a dialog box that must behave as MessageBox does
with regard to the TopMost property. It must be TopMost if
and only if the calling form is TopMost. A static method
creates the dialog box. Is there a way of determining if the
application is TopMost from a static method?

There are some inelegant workarounds but I would prefer to
do whatever MessageBox does.
One way you could do this is to stash your main form in a static
property, and retrieve that property from your static method:

return MyMainForm.Inst ance.TopMost;

You could also cycle through all open forms, looking for your main
form:

foreach (Form f in Application.Ope nForms)
{
if (f is MyMainForm)
{
return f.TopMost;
}

Michael

Aug 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
3011
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() ' This method shows the form used to get the info If sWhereInt = "" Then DoCmd.OpenForm sFormNameInt, acNormal, , , acFormAdd, _
4
1447
by: Dave Guenthner | last post by:
I have a csharp form1.cs created with VS. I have added a menu bar with one option called help. I then created another form in VS called help.cs. How can I launch the help form from the main form called form1. Seems simple. private void menuItem5_Click(object sender, System.EventArgs e) { // Menuitem5_Click is the help menu item user sees
4
1538
by: Typpo | last post by:
Hi, This question is somewhat basic. Is it possible to call a method in frmMain, using another class? Here's a snippet: partial class frmMain : Form { private void MessageThis(String text) { MessageBox.Show(text);
12
7537
by: E Goforth | last post by:
Hello, I have a VB6 app that calls a VB.NET app via named pipes and a third party component. Inside the VB.NET app I'm trying to force a form to the top, at least temporarily. Inside a form's public sub I'm doing: Public Sub ThisIsMySub(TheseAreMyArguments) Me.Show Me.WindowState = FormWindowState.Normal Me.TopMost = True
6
4752
by: Strahimir Antoljak | last post by:
I'm running VS.NET 2002 and keep having problems with form keeping on top with its TopMost property. Sometimes my program places the invoked form on top sometimes not. Sometimes when I click on the form it stays on top as it should, but sometimes TopMost property does not pick up so if I click to some other program it covers the form which supposed to remain on the top. Has anyone experienced similar problems? is there a fix? or I am...
0
1788
by: hzgt9b | last post by:
Using VB .NET 2003, I am having problems with a windows application that I have written: Here's the situation. The application I created has a main form that has its TopMost property set to True (so that the form is always on top). During the execution of the application, a new process is created using "Process.Start(<some app>)". The problem is that after I start a new process, my main form no longer has focus, so all keyboard events are...
3
2904
by: Don | last post by:
I've got a form which (in a roundabout manner) calls a second form into existence which has its TopMost property set (the first form is not the parent of this second form because of the roundabout manner in which the second form is created and displayed). The user can then still work on the first form while the second form floats around above it. If the first form displays a messagebox via the MsgBox method, the messagebox appears...
3
3942
by: Jon | last post by:
My main form opens up another form, and from this other form, I'd like to access things in the main form. The problem is that although I know the name of the class of the main form (FormMain) I don't know the name of the instance of it since it was generated by the VS C# Express 2005 designer. In program.cs, I notice that there is the line: Application.Run(new FormMain()); I guess I could replace this with: FormMain fMain = new FormMain()...
1
1721
by: mpathfinder | last post by:
hi everybody i have a MDI form that it shows child forms with the "Show()" method . in one of that child forms i show another form that owned by this form again with the "Show()" method . this cause this second form become TopMost . means that all another forms are shown behind this second form . why this happen ? code is like this : /// within MDI form frmChild1 frm = new frmChild1(); frm.MdiParent = this;
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.