473,394 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Determine if a form is displayed?

In VB 6, you can query the forms collection to see if a form is loaded and
then check that form's window state to find out if it's displayed or not.
How can a VB.Net program tell if a form is displayed? Finding out it's load
state would be nice, but I really need to know if a form is on the screen.

Thanks,
Mike Ober.
Nov 20 '05 #1
6 5715
Michael,

What kind of form?

MDI, dialog, normal

Cor
Nov 20 '05 #2
* "Michael D. Ober" <mdo.@.wakeassoc..com> scripsit:
In VB 6, you can query the forms collection to see if a form is loaded and
then check that form's window state to find out if it's displayed or not.
How can a VB.Net program tell if a form is displayed? Finding out it's load
state would be nice, but I really need to know if a form is on the screen.


Your form could implement the Singleton design pattern (see Google for
more info).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Usually a Dialog, but it could also be normal.

Mike.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
Michael,

What kind of form?

MDI, dialog, normal

Cor

Nov 20 '05 #4
Hi Michael,

When a dialog is open, it loses only the focus when it is closed, so when
you are in another form you are sure that it is closed.

A form is not "loaded" anymore as in VB6, the form handling in that was a
little bit strange to make things easy I have readed here.

So try first why you need it and check than if it still is your problem.
(The approaches for all three forms are different)
Usually a Dialog, but it could also be normal.


I hope that I understand your question well, otherwise reply, however please
with a concrete problem.

Cor
Nov 20 '05 #5
We have ~150,000 lines of VB 6 code that will need to eventually ported to
VB.Net. Littered throughout this code is a variant of the conditional

if isLoaded("someform") then
do something with someform
else
do something else with someform
end if
....
someform.hide (or unload someform)

"someform" is usually, but not always a status message form. In some cases
it's a keyboard handling form. In others, it's simply been hidden to allow
access to it's current state and/or application specific public methods and
properties. There are even a few cases where someform is a "form" variable
that gets loaded and dumped with the scope of the referencing code, but I'm
not worried about these right now as these will be the last to be ported.

I'm aware that many of these programs will require serious rework - to the
extent of dumping the old code entirely in a couple of cases, but if there
is some way to identify when a form is in memory, that would be great.

Mike.
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
Hi Michael,

When a dialog is open, it loses only the focus when it is closed, so when
you are in another form you are sure that it is closed.

A form is not "loaded" anymore as in VB6, the form handling in that was a
little bit strange to make things easy I have readed here.

So try first why you need it and check than if it still is your problem.
(The approaches for all three forms are different)
Usually a Dialog, but it could also be normal.

I hope that I understand your question well, otherwise reply, however

please with a concrete problem.

Cor

Nov 20 '05 #6
Hi Michael,

And you are sure it is not a MDI, because that is really totaly different
from the rest.

With a normal form it is more difficult, when you do not hide it.
I can give you this sample however I doubt that it helps you.

Cor

\\\form1
Private WithEvents frm3 As New Form3
Private WithEvents frm2 As New Form2
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged
If frm2.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm2.inputfield
frm2.Dispose()
End If
End Sub
Private Sub frm3_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm3.VisibleChanged
If frm3.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm3.inputfield
frm3.Dispose()
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
frm3.Show()
frm3.TopLevel = True
frm2.Show()
frm2.TopLevel = True
End Sub
///
\\\form2 and 3 the same
Public inputfield As String
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

inputfield = "sometext"
Me.Hide()
End Sub
///


Nov 20 '05 #7

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

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
2
by: bart plessers | last post by:
Hello, I have a form with some checkboxes, i.e. The default value of this checkbox is determined in a global file (config.asp), that is included in first line of the form, i.e. ShowFilenames...
1
by: joe | last post by:
If I had a webpage that displayed a database in tabular form, it would be nice to know how many lines of text the browser could display without scrolling, then have the cgi script output the...
2
by: Rob | last post by:
Is there a faster/cheaper way to determine the number of records being displayed in a continuous form? I always did: dim rs as dao.recordset set rs = me.recordsetclone if rs.recordcount = 0...
13
by: Gittyup | last post by:
Help please, We have a form, based on a query, that contains a listbox. The contents of the listbox are based on the results of the query. When the form is opened, the user selects an item...
0
by: Frederic L. | last post by:
Hi, I have a treeview on a form, with several nodes, on several level. Every node has a text associated to it. That text can be quite long,and sometimes, is longer than the width of the...
5
by: mantrid | last post by:
Hello Im trying to find the correct syntax to use to determine whether which form element is visible on changing the value in a dropdown list I need something in the onChange of the dropdown...
10
by: John Brown | last post by:
Hi there, Does anyone know how to (generically) determine the currently active form for an application using a "static" function (so I can call it from anywhere). There is no offiical way I've...
0
by: Henning | last post by:
This time I agree with Bill replying to a .Net related Q, even if it hurts :)) No need to kick on Bill everytime he is posting in this group. Fair is fair. /Henning "Kevin Provance"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.