From: Eric Mullins Date: Sat, 10 Oct 2009 17:15:50 +0000 (-0600) Subject: Cleaned up ConsoleWndProc (not complete, see below) X-Git-Tag: v4.4.1.20091019~38 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2249ff4080c7a199089e97b80539ad794ca6ba7c;p=xboard.git Cleaned up ConsoleWndProc (not complete, see below) Using static variables this way is not appropriate. I only addressed hInput and hText in this commit though. But imagine the WndProc being used by multiple windows instead of just one, and you can see why using static variables in this way is wrong. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index 6c5d0ee..5fda158 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -8099,14 +8099,16 @@ LRESULT CALLBACK ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static SnapData sd; - static HWND hText, hInput /*, hFocus*/; -// InputSource *is = consoleInputSource; + HWND hText, hInput; RECT rect; static int sizeX, sizeY; int newSizeX, newSizeY; MINMAXINFO *mmi; WORD wMask; + hText = GetDlgItem(hDlg, OPT_ConsoleText); + hInput = GetDlgItem(hDlg, OPT_ConsoleInput); + switch (message) { case WM_NOTIFY: if (((NMHDR*)lParam)->code == EN_LINK) @@ -8126,8 +8128,6 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_INITDIALOG: /* message: initialize dialog box */ hwndConsole = hDlg; - hText = GetDlgItem(hDlg, OPT_ConsoleText); - hInput = GetDlgItem(hDlg, OPT_ConsoleInput); SetFocus(hInput); consoleTextWindowProc = (WNDPROC) SetWindowLong(hText, GWL_WNDPROC, (LONG) ConsoleTextSubclass);