*\r
* Author: H.G.Muller (August 2009)\r
*\r
- * Copyright 2009, 2010 Free Software Foundation, Inc. \r
+ * Copyright 2009, 2010, 2011 Free Software Foundation, Inc.\r
*\r
* ------------------------------------------------------------------------\r
*\r
\r
extern HINSTANCE hInst;\r
extern HWND hwndConsole;\r
+extern char ics_handle[];\r
\r
extern WindowPlacement wpChat[MAX_CHAT];\r
extern WindowPlacement wpConsole;\r
{\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
\r
switch (message) {\r
case WM_INITDIALOG:\r
+ Translate(hDlg, DLG_Chat);\r
if(partner<0) {\r
for(i=0; i<MAX_CHAT; i++) if(chatHandle[i] == NULL) { partner = i; break; }\r
chatHandle[partner] = hDlg;\r
- sprintf(buf, "Chat Window %s", first.tidy);\r
+ snprintf(buf, MSG_SIZ, T_("Chat Window %s"), ics_handle[0] ? ics_handle : 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
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
SendMessage(hMemo, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
SendMessage(hMemo, EM_AUTOURLDETECT, TRUE, 0L);\r
chatInputWindowProc = (WNDPROC) // cloned from ConsoleWndProc(). Assume they all share same proc.\r
- SetWindowLong(GetDlgItem(hDlg, OPT_ChatInput), GWL_WNDPROC, (LONG) InterceptArrowKeys);\r
+ SetWindowLongPtr(GetDlgItem(hDlg, OPT_ChatInput), GWLP_WNDPROC, (LONG_PTR) InterceptArrowKeys);\r
return FALSE;\r
\r
case WM_NOTIFY:\r
break;\r
\r
case WM_COMMAND:\r
- /* \r
+ /*\r
[AS]\r
If <Enter> is pressed while editing the filter, it's better to apply\r
the filter rather than selecting the current game.\r
// from here on it could be back-end\r
SaveInHistory(mess);\r
if(!strcmp("whispers", chatPartner[partner]))\r
- sprintf(buf, "whisper %s\n", mess); // WHISPER box uses "whisper" to send\r
+ snprintf(buf, MSG_SIZ, "whisper %s\n", mess); // WHISPER box uses "whisper" to send\r
else if(!strcmp("shouts", chatPartner[partner]))\r
- sprintf(buf, "shout %s\n", mess); // SHOUT box uses "shout" to send\r
+ snprintf(buf, MSG_SIZ, "shout %s\n", mess); // SHOUT box uses "shout" to send\r
else {\r
if(!atoi(chatPartner[partner])) {\r
- sprintf(buf, "> %s\r\n", mess); // echo only tells to handle, not channel\r
+ snprintf(buf, MSG_SIZ, "> %s\r\n", mess); // echo only tells to handle, not channel\r
InsertIntoMemo(hDlg, buf);\r
- sprintf(buf, "xtell %s %s\n", chatPartner[partner], mess);\r
+ snprintf(buf, MSG_SIZ, "xtell %s %s\n", chatPartner[partner], mess);\r
} else\r
- sprintf(buf, "tell %s %s\n", chatPartner[partner], mess);\r
+ snprintf(buf, MSG_SIZ, "tell %s %s\n", chatPartner[partner], mess);\r
}\r
SendToICS(buf);\r
break;\r
{\r
FARPROC lpProc;\r
int i, partner = -1;\r
- \r
+\r
CheckMenuItem(GetMenu(hwndMain), IDM_NewChat, MF_CHECKED);\r
for(i=0; i<MAX_CHAT; i++) if(chatHandle[i] == NULL) { partner = i; break; }\r
if(partner == -1) { DisplayError("You first have to close a Chat Box\nbefore you can open a new one", 0); return; }\r
if(icsHandle) // [HGM] clickbox set handle in advance\r
- strcpy(chatPartner[partner], icsHandle);\r
+ safeStrCpy(chatPartner[partner], icsHandle,\r
+ sizeof(chatPartner[partner])/sizeof(chatPartner[partner][0]) );\r
else chatPartner[partner][0] = NULLCHAR;\r
chatCount++;\r
\r
\r
void OutputChatMessage(int partner, char *text)\r
{\r
- int j;\r
- if(!chatHandle[partner]) return;\r
+ int j, n = strlen(text);\r
\r
- int n = strlen(text);\r
+ if(!chatHandle[partner]) return;\r
text[n+1] = 0; text[n] = '\n'; text[n-1] = '\r'; // Needs CR to not lose line breaks on copy-paste\r
InsertIntoMemo(chatHandle[partner], text);\r
if(partner != onTop) for(j=0; j<MAX_CHAT; j++) if(j != partner && chatHandle[j])\r