]> source.dussan.org Git - tigervnc.git/commitdiff
Place the rfbplayer window to the center of the screen.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sat, 19 Feb 2005 17:05:24 +0000 (17:05 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sat, 19 Feb 2005 17:05:24 +0000 (17:05 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@198 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfbplayer/rfbplayer.cxx

index fd70d74819b6413cec2508a4d2ad33eb231986a8..59d340202339c1f86e69e5bac15bf86bb9939e2e 100644 (file)
@@ -227,8 +227,10 @@ RfbPlayer::RfbPlayer(char *_fileName, long _initTime = 0, double _playbackSpeed
 
   // Create the main window
   const TCHAR* name = _T("RfbPlayer");
+  int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - DEFAULT_PLAYER_WIDTH) / 2);
+  int y = max(0, (GetSystemMetrics(SM_CYSCREEN) - DEFAULT_PLAYER_HEIGHT) / 2);
   mainHwnd = CreateWindow((const TCHAR*)baseClass.classAtom, name, WS_OVERLAPPEDWINDOW,
-    0, 0, DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT, 0, 0, baseClass.instance, this);
+    x, y, DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT, 0, 0, baseClass.instance, this);
   if (!mainHwnd) {
     throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
   }
@@ -690,7 +692,9 @@ void RfbPlayer::setFrameSize(int width, int height) {
     GetWindowLong(getFrameHandle(), GWL_EXSTYLE));
   r.bottom += CTRL_BAR_HEIGHT; // Include RfbPlayr's controls area
   AdjustWindowRect(&r, GetWindowLong(getMainHandle(), GWL_STYLE), FALSE);
-  SetWindowPos(getMainHandle(), 0, 0, 0, r.right-r.left, r.bottom-r.top,
+  int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) / 2);
+  int y = max(0, (GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) / 2);
+  SetWindowPos(getMainHandle(), 0, x, y, r.right-r.left, r.bottom-r.top,
     SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
 
   // Enable/disable scrollbars as appropriate
@@ -972,9 +976,11 @@ void RfbPlayer::closeSessionFile() {
     dwStyle &= ~WS_MAXIMIZE;
     SetWindowLong(getMainHandle(), GWL_STYLE, dwStyle);
   }
-  SetWindowPos(getMainHandle(), 0, 0, 0, 
+  int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - DEFAULT_PLAYER_WIDTH) / 2);
+  int y = max(0, (GetSystemMetrics(SM_CYSCREEN) - DEFAULT_PLAYER_HEIGHT) / 2);
+  SetWindowPos(getMainHandle(), 0, x, y, 
     DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT, 
-    SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
+    SWP_NOZORDER | SWP_FRAMECHANGED);
   buffer->setSize(32, 32);
   calculateScrollBars();