X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=sizetip.c;h=2e82c18179028bff9712e33a8a9537adf3e60a60;hb=7b444de332620e3c59e0feee8d06c014582b704e;hp=20ab423c079ba6d078dc42df27c2124ffb7553bb;hpb=5e76cd7a17e070402fe1c0a14ee887f548236c94;p=PuTTY.git diff --git a/sizetip.c b/sizetip.c index 20ab423c..2e82c181 100644 --- a/sizetip.c +++ b/sizetip.c @@ -1,25 +1,33 @@ - #include +#ifndef AUTO_WINSOCK +#ifdef WINSOCK_TWO +#include +#else +#include +#endif +#endif #include #include #include +#include #include "putty.h" -ATOM tip_class = 0; +static ATOM tip_class = 0; -HFONT tip_font; -COLORREF tip_bg; -COLORREF tip_text; +static HFONT tip_font; +static COLORREF tip_bg; +static COLORREF tip_text; -LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, + WPARAM wParam, LPARAM lParam) { switch (nMsg) { - case WM_ERASEBKGND: + case WM_ERASEBKGND: return TRUE; - case WM_PAINT: + case WM_PAINT: { HBRUSH hbr; HGDIOBJ holdbr; @@ -58,15 +66,15 @@ LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPar } return 0; - case WM_NCHITTEST: + case WM_NCHITTEST: return HTTRANSPARENT; - case WM_DESTROY: + case WM_DESTROY: DeleteObject(tip_font); tip_font = NULL; break; - case WM_SETTEXT: + case WM_SETTEXT: { LPCTSTR str = (LPCTSTR)lParam; SIZE sz; @@ -86,19 +94,19 @@ LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPar return DefWindowProc(hWnd, nMsg, wParam, lParam); } -HWND tip_wnd = NULL; -int tip_enabled = 0; +static HWND tip_wnd = NULL; +static int tip_enabled = 0; void UpdateSizeTip(HWND src, int cx, int cy) { - TCHAR str[16]; + TCHAR str[32]; if (!tip_enabled) return; if (!tip_wnd) { NONCLIENTMETRICS nci; - // First make sure the window class is registered + /* First make sure the window class is registered */ if (!tip_class) { WNDCLASS wc; @@ -116,27 +124,28 @@ void UpdateSizeTip(HWND src, int cx, int cy) tip_class = RegisterClass(&wc); } -// // Default values based on Windows Standard color scheme -// -// tip_font = GetStockObject(SYSTEM_FONT); -// tip_bg = RGB(255, 255, 225); -// tip_text = RGB(0, 0, 0); +#if 0 + /* Default values based on Windows Standard color scheme */ + + tip_font = GetStockObject(SYSTEM_FONT); + tip_bg = RGB(255, 255, 225); + tip_text = RGB(0, 0, 0); +#endif - // Prepare other GDI objects and drawing info + /* Prepare other GDI objects and drawing info */ tip_bg = GetSysColor(COLOR_INFOBK); tip_text = GetSysColor(COLOR_INFOTEXT); - + memset(&nci, 0, sizeof(NONCLIENTMETRICS)); nci.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &nci, 0); tip_font = CreateFontIndirect(&nci.lfStatusFont); } - // Generate the tip text - - _sntprintf(str, 16, "%dx%d", cx, cy); + /* Generate the tip text */ + sprintf(str, "%dx%d", cx, cy); if (!tip_wnd) { HDC hdc; @@ -144,7 +153,7 @@ void UpdateSizeTip(HWND src, int cx, int cy) RECT wr; int ix, iy; - // calculate the tip's size + /* calculate the tip's size */ hdc = CreateCompatibleDC(NULL); GetTextExtentPoint32(hdc, str, _tcslen(str), &sz); @@ -158,17 +167,17 @@ void UpdateSizeTip(HWND src, int cx, int cy) iy = wr.top - sz.cy; if (iy<16) iy = 16; - // Create the tip window + /* Create the tip window */ tip_wnd = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST, MAKEINTRESOURCE(tip_class), str, WS_POPUP, - ix, iy, sz.cx, sz.cy, - NULL, NULL, putty_inst, NULL); + ix, iy, sz.cx, sz.cy, + NULL, NULL, putty_inst, NULL); ShowWindow(tip_wnd, SW_SHOWNOACTIVATE); } else { - // Tip already exists, just set the text + /* Tip already exists, just set the text */ SetWindowText(tip_wnd, str); } @@ -180,6 +189,6 @@ void EnableSizeTip(int bEnable) DestroyWindow(tip_wnd); tip_wnd = NULL; } - + tip_enabled = bEnable; }