X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/5e1a8e278f3210fd6f37af7867bbb42cf160fb92..676c055670214ebd4ef78460f1f9d9f63e1e8ce8:/window.c diff --git a/window.c b/window.c index 98809aa3..8c82af9a 100644 --- a/window.c +++ b/window.c @@ -7,6 +7,7 @@ #define PUTTY_DO_GLOBALS /* actually _define_ globals */ #include "putty.h" #include "win_res.h" +#include "sizetip.h" #define IDM_SHOWLOG 0x0010 #define IDM_NEWSESS 0x0020 @@ -82,6 +83,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { MSG msg; int guess_width, guess_height; + putty_inst = inst; + winsock_ver = MAKEWORD(1, 1); if (WSAStartup(winsock_ver, &wsadata)) { MessageBox(NULL, "Unable to initialise WinSock", "WinSock Error", @@ -627,6 +630,7 @@ static int WINAPI WndProc (HWND hwnd, UINT message, { char b[2048]; char c[30], *cl; + int freecl = FALSE; STARTUPINFO si; PROCESS_INFORMATION pi; HANDLE filemap = NULL; @@ -660,9 +664,12 @@ static int WINAPI WndProc (HWND hwnd, UINT message, sprintf(c, "putty &%08x", filemap); cl = c; } else if (wParam == IDM_SAVEDSESS) { - sprintf(c, "putty @%s", - sessions[(lParam - IDM_SAVED_MIN) / 16]); - cl = c; + char *session = sessions[(lParam - IDM_SAVED_MIN) / 16]; + cl = malloc(16 + strlen(session)); /* 8, but play safe */ + if (!cl) + cl = NULL; /* not a very important failure mode */ + sprintf(cl, "putty @%s", session); + freecl = TRUE; } else cl = NULL; @@ -679,6 +686,8 @@ static int WINAPI WndProc (HWND hwnd, UINT message, if (filemap) CloseHandle(filemap); + if (freecl) + free(cl); } break; case IDM_RECONF: @@ -865,6 +874,12 @@ static int WINAPI WndProc (HWND hwnd, UINT message, case WM_IGNORE_SIZE: ignore_size = TRUE; /* don't panic on next WM_SIZE msg */ break; + case WM_ENTERSIZEMOVE: + EnableSizeTip(1); + break; + case WM_EXITSIZEMOVE: + EnableSizeTip(0); + break; case WM_SIZING: { int width, height, w, h, ew, eh; @@ -874,6 +889,7 @@ static int WINAPI WndProc (HWND hwnd, UINT message, height = r->bottom - r->top - extra_height; w = (width + font_width/2) / font_width; if (w < 1) w = 1; h = (height + font_height/2) / font_height; if (h < 1) h = 1; + UpdateSizeTip(hwnd, w, h); ew = width - w * font_width; eh = height - h * font_height; if (ew != 0) {