From 31d464fc0f1de8577fd198a180ba26f8cd884ac2 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 10 Feb 2010 14:42:49 +0100 Subject: [PATCH] Allow ICS context menu to pop up a Chat Box on clicking handle A command "chat" defined in the WinBoard icsMenu string will cause ChatPopUp() to be called when it is clicked, with the clicked handle (name) in the ChatPartner field, and focus on the input field. ChatPopUp() had to get a parameter (the handle) to make this possible. If that parameter is NULL (as when it is called from the Mode menu), focus will still start on the (empty) ChatPartner field of the box. --- winboard/wchat.c | 21 ++++++++++++++++----- winboard/winboard.c | 5 +++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/winboard/wchat.c b/winboard/wchat.c index d6dc502..e762b19 100644 --- a/winboard/wchat.c +++ b/winboard/wchat.c @@ -45,7 +45,7 @@ extern char chatPartner[MAX_CHAT][MSG_SIZ]; HANDLE chatHandle[MAX_CHAT]; void SendToICS P((char *s)); -void ChatPopUp(); +void ChatPopUp P((char *s)); void ChatPopDown(); /* Imports from backend.c */ @@ -150,9 +150,14 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam sprintf(buf, "Chat Window %s", first.tidy); SetWindowText(hDlg, buf); } - chatPartner[partner][0] = 0; - filterHasFocus[partner] = FALSE; - +// chatPartner[partner][0] = 0; + SendMessage( GetDlgItem(hDlg, IDC_ChatPartner), // [HGM] clickbox: initialize with requested handle + WM_SETTEXT, 0, (LPARAM) chatPartner[partner] ); + filterHasFocus[partner] = TRUE; + if(chatPartner[partner][0]) { + filterHasFocus[partner] = FALSE; + SetFocus( GetDlgItem(hDlg, OPT_ChatInput) ); + } return FALSE; case WM_COMMAND: @@ -246,13 +251,19 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam } // front end -void ChatPopUp() +void ChatPopUp(char *icsHandle) { FARPROC lpProc; + int i, partner = -1; if(chatCount >= MAX_CHAT) return; CheckMenuItem(GetMenu(hwndMain), IDM_NewChat, MF_CHECKED); + for(i=0; i