Main window location

O

Ole Engvoll

Hi! After searching for one hour, I try you guys! In a MDI-based
winform, how can I get loaction for the main window regardless if I
click on a button in the main form or in a MDI-child? I only get the
MDI-child locations :-(. Thanx. Ole
 
J

Jason Keats

Ole said:
Hi! After searching for one hour, I try you guys! In a MDI-based
winform, how can I get loaction for the main window regardless if I
click on a button in the main form or in a MDI-child? I only get the
MDI-child locations :-(. Thanx. Ole

I'd have to agree with Peter, your question is unclear. I thought you
were trying to find your program's path. If so, I'd try one of the
following:

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)

Environment.CurrentDirectory

AppDomain.CurrentDomain.SetupInformation.ApplicationBase()

System.Reflection.Assembly.GetExecutingAssembly.Location
 
J

Jeff Johnson

Hi! After searching for one hour, I try you guys! In a MDI-based
winform, how can I get loaction for the main window regardless if I
click on a button in the main form or in a MDI-child? I only get the
MDI-child locations :-(. Thanx. Ole

Add a property to your MDI child forms that is of type Form (or of whatever
type you named your MDI parent). Then, when you open a child form, set that
property to the parent. Then every child form can reference that property
and get the parent form's information.
 
O

Ole Engvoll

All Control instances have a PointToClient() method and a
PointToScreen() method for converting between coordinate systems.  So if
you have a point in the coordinates for one control (e.g. an MDI child)
and you want that point in terms of the coordinate system for another
control (e.g. the MDI parent), all you have to do is first convert to
screen coordinates (i.e. use the first control's PointToScreen() method)
and then back to the client coordinate of the control you're interested
in (i.e. use the MDI parent's PointToClient() method).

If your question is not about converting points from one coordinate
system to another, then your question is unclear and you need to restate
it in a less ambiguous way.

Pete

Hi Pete!
My challenge is to get the coordinates from my application.exe so I
can position my dialog forms correctly (not only in the center). My
dialogs are running from child forms. I'll dig into the PointtoClient
and pointToScreen! Thanx! Ole
 
O

Ole Engvoll

Add a property to your MDI child forms that is of type Form (or of whatever
type you named your MDI parent). Then, when you open a child form, set that
property to the parent. Then every child form can reference that property
and get the parent form's information.

Hi! Splended! Work perfectly! Thanx!
 

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