How to close a form that is open in ShowDialog, from another form (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 02:50
Joined
Aug 15, 2010
Messages
954
In response to a telephone call, I use the following code to open a form at the lower right corner of the screen to display the users who have this telephone number. When a call is received, the telephone system does something very simple, it executes a batch file and passes the telephone number as a parameter and the batch file creates a file, whose contents are this telephone number. To simplify matters, when a call is made, I can receive a string with the telephone number of the caller and I can pass the telephone number to a form (frmCallerIn) which looks up this telephone number and displays all the users that have this telephone number.

I use the following code to position the form on the lower bottom right of the screen.

Me.Location = New Point(scr.WorkingArea.Right - Me.Width, scr.WorkingArea.Bottom - Me.Height)

I can open the form with
Dim frm2 = New frmCallerIn(sbuf)
frm2.ShowDialog()

I created a Timer programmatically to close the form after say 10 seconds and the Timer is disabled if I click on the form.
When the Timer is disabled, the form will remain on the screen until I exit from the form, even if a new call comes in.

Is there a way to be able to close the form, once a new call comes in. Would opening the form in a separate thread help?
 

Ranman256

Well-known member
Local time
Yesterday, 19:50
Joined
Apr 9, 2015
Messages
4,337
you cannot shut a dialog from another form BECAUSE its in dialog.
Just close it from the dialog.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:50
Joined
Oct 29, 2018
Messages
21,474
Perhaps consider just opening the form as Modal, instead of Dialog.
 

Users who are viewing this thread

Top Bottom