Centering Dialog Form on Parent

P

Peter

I have a primary form named frmMain. During some extended data pulls
I launch another Dialog Form named frmUpdating. [A little progress
meter shows up and scrolls across the screen why the data is being
pulled.] How do I keep the frmUpdating centered on the frmMain if a
user moves the frmMain form?

-Peter
 
I

Imran Koradia

How is anyone going to be able to move frmMain if frmUpdating (your dialog
form) is being show modally? Or am I missing something ?

Imran.
 
J

Jay B. Harlow [MVP - Outlook]

Peter,
As Imran asks, is the UpdatingForm (frmUpdating) displayed with Form.Show or
Form.ShowDialog?

If you are using Form.Show, then you should be able to handle the Form.Move
& Form.Resize to manually move & resize your UpdatingForm.

If you are using Form.ShowDialog, then as Imran states, the user cannot move
your MainForm (frmMain).

FWIW: A "Dialog Form" implies to me that you are using Form.ShowDialog.

Hope this helps
Jay
 
H

Herfried K. Wagner [MVP]

Peter said:
I have a primary form named frmMain. During some extended
data pulls I launch another Dialog Form named frmUpdating.
[A little progress meter shows up and scrolls across the
screen why the data is being pulled.] How do I keep the
frmUpdating centered on the frmMain if a user moves the
frmMain form?

Are you showing the dialog form modally? Then the user will not be able to
move the main form at all. Otherwise add a handler to the main form's
'Move' event and place the code for positioning the dialog there.
 
C

Cor Ligthert

Peter,

Sorry, however in my opinion makes what you ask not so much sense.

I think that it is easier to use instead of a dialog form a panel what
starts invisible and when you need it make it visible. That panel has of
course to lay on top of the other controls.

Using the Dock property of the panel and setting that to dockstyle.fill
makes this even very easy.

The user does really not see it if you use a panel or a form.

I hope this gives an idea? (it really moves in the center of your form)

And when I see something wrong don't hesitate to reply.

Cor

"Peter" <
 
P

Peter

I've added for frmUpdating in the designer and then call on the
frmUpdating.showDialog using a new thread:

IE.

This is in the frmMain:
Shared Sub RunUpdate(ByVal stateinfo As Object)
Dim frm_Update As New frmUpdating
frm_Update.ShowDialog()

End Sub

Then when I want my updaing to launch I do this:

ThreadPool.QueueUserWorkItem(AddressOf RunUpdate) 'Opens up the
frmUpdating

that runs until a global named StopNow = False 'I place this code
after my main proceedures run.

So basically the updating bar is more to just let the user know that
the data process is still running. The problem though is that because
these two forms are running on different threads that if a user moves
the form then the updating display is off center.

-Peter
 
C

Cor Ligthert

Peter,

Because of all the other answers which are given in this thread, what is the
sense of a showdialogform with a multithreading operation. Your main
operation is freezen anyway.

Not everybody agrees this with me, however in my opinion when the user
cannot do anything in between and has to wait on the result of the
operation, than just let an avi or a animated gif go in your application in
the same way as microsoft does that.

The multithreading will only give you overhead.

Some of those AVI's you can find in
C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Graphics\videos

They are not supported for nothing.

However just my idea

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top