public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
* Patch for centering exit/mode change dialogs on multiscreen
@ 2004-01-27  4:04 Earle F. Philhower III
  0 siblings, 0 replies; only message in thread
From: Earle F. Philhower III @ 2004-01-27  4:04 UTC (permalink / raw)
  To: cygwin-xfree

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

It seems that the DS_CENTER property only centers a dialog onto the 1st
detected monitor, and not the primary monitor (selected in Desktop props).
At my office the two are the same, but on my home setup my center DVI
monitor is detected as #3...

I'm attaching a minor patchfile which programmatically centers the dialog
during the WM_INITDIALOG stage using a pretty standard center() function
for the exit and mode change dialogs.

-Earle F. Philhower, III
  earle@ziplabel.com
  cdrlabel - ZipLabel - FlpLabel
  http://www.cdrlabel.com

[-- Attachment #2: centermultiscreen.patch --]
[-- Type: application/octet-stream, Size: 1321 bytes --]

--- xwin.cvs/windialogs.c	2004-01-25 19:04:11.265625000 -0800
+++ xwin/windialogs.c	2004-01-26 18:29:04.734375000 -0800
@@ -43,6 +43,36 @@
 
 
 /*
+ * Center a dialog window in the desktop window
+ */
+static void
+winCenterDialog (HWND hwndDlg)
+{
+  HWND hwndDesk; 
+  RECT rc, rcDlg, rcDesk; 
+ 
+  hwndDesk = GetParent (hwndDlg);
+  if (!hwndDesk)
+    hwndDesk = GetDesktopWindow (); 
+  
+  GetWindowRect (hwndDesk, &rcDesk); 
+  GetWindowRect (hwndDlg, &rcDlg); 
+  CopyRect (&rc, &rcDesk); 
+  
+  OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top); 
+  OffsetRect (&rc, -rc.left, -rc.top); 
+  OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom); 
+  
+  SetWindowPos (hwndDlg, 
+		HWND_TOP, 
+		rcDesk.left + (rc.right / 2), 
+		rcDesk.top + (rc.bottom / 2), 
+		0, 0,
+		SWP_NOSIZE | SWP_NOZORDER); 
+}
+
+
+/*
  * Display the Exit dialog box
  */
 
@@ -110,6 +140,8 @@
       s_pScreenInfo = s_pScreenPriv->pScreenInfo;
       s_pScreen = s_pScreenInfo->pScreen;
 
+      winCenterDialog( hDialog );
+
       /* Set icon to standard app icon */
       PostMessage (hDialog,
 		   WM_SETICON,
@@ -258,6 +290,8 @@
 	      s_pScreenInfo->dwBPP,
 	      s_pScreenPriv->dwLastWindowsBitsPixel);
 #endif
+      
+      winCenterDialog( hwndDialog );
 
       /* Set icon to standard app icon */
       PostMessage (hwndDialog,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-01-27  4:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-27  4:04 Patch for centering exit/mode change dialogs on multiscreen Earle F. Philhower III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).