• Post Reply Bookmark Topic Watch Topic
  • New Topic

Centering dialogs in a multi-monitor environment?  RSS feed

 
Timothy Frey
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently, all of our dialogs seem to center themselves in the primary display. This is bad because the button that triggers the dialog may be 4 monitors away. I'm trying to get the dialog box to center on the screen where the action occured.

My current solution involves passing a Point object that represents the location of the action into the method that eventually shows the dialog. From this Point, I'm trying get the object (GraphicsConfiguration?) that represents the screen that contains this Point. My current code looks something like this:



As you can see, it's pretty much a mess. It works in some cases, but is unpredictable in others. If the main window is resized so that it takes up less than 1 screen, then everything seems OK. If I drag this window between monitors and try to show the dialog, it seems to center correctly on the proper display. There is a problem when the window is stretched to take up more than one screen, however. The dialog does not always appear on the correct display.

I can't possibly be the only person having this problem, but any information on how to properly support multi-monitor environments is pretty hard to come by. Is my understanding of the GraphicsConfiguration object correct? Does it represent the current display? Any one have any ideas? Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!