Let Chat Boxes pop up above console, rather than on top of it
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 26 Mar 2010 17:32:36 +0000 (18:32 +0100)
committerArun Persaud <arun@nubati.net>
Sat, 27 Mar 2010 18:37:08 +0000 (11:37 -0700)
Use EnsureOnScreen() to have them overlap if there was no room.

winboard/wchat.c

index a387466..30b6aa5 100644 (file)
@@ -180,7 +180,7 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
 {\r
     static SnapData sd;\r
     char buf[MSG_SIZ], mess[MSG_SIZ];\r
-    int partner = -1, i;\r
+    int partner = -1, i, x, y;\r
     static BOOL filterHasFocus[MAX_CHAT];\r
     WORD wMask;\r
     HWND hMemo;\r
@@ -195,7 +195,7 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
                sprintf(buf, "Chat Window %s", first.tidy);\r
                SetWindowText(hDlg, buf);\r
         }\r
-       for(i=0; i<MAX_CHAT; i++) if(chatHandle[i]) {
+       for(i=0; i<MAX_CHAT; i++) if(chatHandle[i]) {\r
            if(i == partner) continue;\r
            // set our button in other open chats\r
            SetDlgItemText(chatHandle[i], IDC_Focus1+partner-(i<partner), chatPartner[partner]);\r
@@ -204,7 +204,8 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
            SetDlgItemText(hDlg, IDC_Focus1+i-(i>partner), chatPartner[i]);\r
        } else EnableWindow( GetDlgItem(hDlg, IDC_Focus1+i-(i>partner)), 0 );\r
        for(i=0; i<MAX_CHAT-1; i++) { Button_SetStyle(GetDlgItem(hDlg, IDC_Focus1+i), BS_PUSHBUTTON|BS_LEFT, TRUE); }\r
-        SetWindowPos(hDlg, NULL, wpConsole.x, wpConsole.y, 0, 0, SWP_NOZORDER|SWP_NOSIZE);\r
+        x = wpConsole.x; y = wpConsole.y; EnsureOnScreen(&x, &y, 0, 0);\r
+        SetWindowPos(hDlg, NULL, x, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE);\r
        SendMessage( GetDlgItem(hDlg, IDC_ChatPartner), // [HGM] clickbox: initialize with requested handle\r
                        WM_SETTEXT, 0, (LPARAM) chatPartner[partner] );\r
        filterHasFocus[partner] = TRUE;\r