Revision: 7916 https://osdn.net/projects/ttssh2/scm/svn/commits/7916 Author: zmatsuo Date: 2019-08-06 00:35:47 +0900 (Tue, 06 Aug 2019) Log Message: ----------- tekwin.cpp と vtwin.cpp でグローバル変数hInstの参照をなくした Modified Paths: -------------- trunk/teraterm/teraterm/tekwin.cpp trunk/teraterm/teraterm/tekwin.h trunk/teraterm/teraterm/teraterm.cpp trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/teraterm/vtwin.h -------------- next part -------------- Modified: trunk/teraterm/teraterm/tekwin.cpp =================================================================== --- trunk/teraterm/teraterm/tekwin.cpp 2019-08-05 15:35:36 UTC (rev 7915) +++ trunk/teraterm/teraterm/tekwin.cpp 2019-08-05 15:35:47 UTC (rev 7916) @@ -49,20 +49,16 @@ #define TEKClassName _T("TEKWin32") -static HINSTANCE AfxGetInstanceHandle() -{ - return hInst; -} - ///////////////////////////////////////////////////////////////////////////// // CTEKWindow -CTEKWindow::CTEKWindow() +CTEKWindow::CTEKWindow(HINSTANCE hInstance) { WNDCLASS wc; RECT rect; DWORD Style; int fuLoad = LR_DEFAULTCOLOR; + m_hInst = hInstance; if (! LoadTTTEK()) { return; @@ -81,7 +77,7 @@ wc.lpfnWndProc = (WNDPROC)ProcStub; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = AfxGetInstanceHandle(); + wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = NULL; @@ -99,7 +95,7 @@ rect.right = rect.left + 640; //temporary width rect.bottom = rect.top + 400; //temporary height } - Create(hInst, TEKClassName, _T("Tera Term"), Style, rect, ::GetDesktopWindow(), NULL); + Create(hInstance, TEKClassName, _T("Tera Term"), Style, rect, ::GetDesktopWindow(), NULL); //-------------------------------------------------------- HTEKWin = GetSafeHwnd(); if (HTEKWin == NULL) { @@ -113,11 +109,11 @@ fuLoad = LR_VGACOLOR; } ::PostMessage(HTEKWin,WM_SETICON,ICON_SMALL, - (LPARAM)LoadImage(AfxGetInstanceHandle(), + (LPARAM)LoadImage(hInstance, MAKEINTRESOURCE((ts.TEKIcon!=IdIconDefault)?ts.TEKIcon:IDI_TEK), IMAGE_ICON,16,16,fuLoad)); ::PostMessage(HTEKWin,WM_SETICON,ICON_BIG, - (LPARAM)LoadImage(AfxGetInstanceHandle(), + (LPARAM)LoadImage(hInstance, MAKEINTRESOURCE((ts.TEKIcon!=IdIconDefault)?ts.TEKIcon:IDI_TEK), IMAGE_ICON, 0, 0, fuLoad)); @@ -180,7 +176,7 @@ { ID_TEKHELP_ABOUT, "TEKMENU_HELP_ABOUT" }, }; - *Menu = ::LoadMenu(AfxGetInstanceHandle(), + *Menu = ::LoadMenu(m_hInst, MAKEINTRESOURCE(IDR_TEKMENU)); FileMenu = GetSubMenu(*Menu,0); EditMenu = GetSubMenu(*Menu,1); Modified: trunk/teraterm/teraterm/tekwin.h =================================================================== --- trunk/teraterm/teraterm/tekwin.h 2019-08-05 15:35:36 UTC (rev 7915) +++ trunk/teraterm/teraterm/tekwin.h 2019-08-05 15:35:47 UTC (rev 7916) @@ -40,7 +40,7 @@ FileMenu, SetupMenu, HelpMenu; public: - CTEKWindow(); + CTEKWindow(HINSTANCE hInstance); int Parse(); void RestoreSetup(); void InitMenu(HMENU *Menu); Modified: trunk/teraterm/teraterm/teraterm.cpp =================================================================== --- trunk/teraterm/teraterm/teraterm.cpp 2019-08-05 15:35:36 UTC (rev 7915) +++ trunk/teraterm/teraterm/teraterm.cpp 2019-08-05 15:35:47 UTC (rev 7916) @@ -238,11 +238,6 @@ return OnIdle(lCount); } -HINSTANCE GetInstance() -{ - return hInst; -} - static HWND main_window; HWND GetHWND() { @@ -305,7 +300,7 @@ #endif init(); hInst = hInstance; - CVTWindow *m_pMainWnd = new CVTWindow(); + CVTWindow *m_pMainWnd = new CVTWindow(hInstance); pVTWin = m_pMainWnd; main_window = m_pMainWnd->m_hWnd; // [Tera Term]\x83Z\x83N\x83V\x83\x87\x83\x93\x82\xCCDLG_SYSTEM_FONT\x82\xF0\x82Ƃ肠\x82\xA6\x82\xB8\x83Z\x83b\x83g\x82\xB7\x82\xE9 Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2019-08-05 15:35:36 UTC (rev 7915) +++ trunk/teraterm/teraterm/vtwin.cpp 2019-08-05 15:35:47 UTC (rev 7916) @@ -147,11 +147,6 @@ ///////////////////////////////////////////////////////////////////////////// // CVTWindow -static HINSTANCE AfxGetInstanceHandle() -{ - return hInst; -} - // Tera Term\x8BN\x93\xAE\x8E\x9E\x82\xC6URL\x95\xB6\x8E\x9A\x97\xF1mouse over\x8E\x9E\x82ɌĂ\xEA\x82\xE9 (2005.4.2 yutaka) static void SetMouseCursor(const char *cursor) { @@ -532,7 +527,7 @@ ///////////////////////////////////////////////////////////////////////////// // CVTWindow constructor -CVTWindow::CVTWindow() +CVTWindow::CVTWindow(HINSTANCE hInstance) { WNDCLASS wc; RECT rect; @@ -548,6 +543,7 @@ #endif int fuLoad = LR_DEFAULTCOLOR; BOOL isFirstInstance; + m_hInst = hInstance; // \x97\xE1\x8AO\x83n\x83\x93\x83h\x83\x89\x82̃t\x83b\x83N (2007.9.30 yutaka) #if !defined(_M_X64) @@ -691,7 +687,7 @@ wc.lpfnWndProc = (WNDPROC)ProcStub; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = AfxGetInstanceHandle(); + wc.hInstance = hInstance; wc.hIcon = NULL; //wc.hCursor = LoadCursor(NULL,IDC_IBEAM); wc.hCursor = NULL; // \x83}\x83E\x83X\x83J\x81[\x83\\x83\x8B\x82͓\xAE\x93I\x82ɕύX\x82\xB7\x82\xE9 (2005.4.2 yutaka) @@ -700,7 +696,7 @@ wc.lpszClassName = VTClassName; RegisterClass(&wc); - m_hAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_ACC)); + m_hAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACC)); if (ts.VTPos.x==CW_USEDEFAULT) { rect = rectDefault; @@ -711,7 +707,7 @@ rect.right = rect.left + 100; rect.bottom = rect.top + 100; } - Create(hInst, VTClassName, _T("Tera Term"), Style, rect, NULL, NULL); + Create(hInstance, VTClassName, _T("Tera Term"), Style, rect, NULL, NULL); /*--------- Init2 -----------------*/ HVTWin = GetSafeHwnd(); @@ -742,7 +738,7 @@ fuLoad = LR_VGACOLOR; } ::PostMessage(HVTWin,WM_SETICON,ICON_SMALL, - (LPARAM)LoadImage(AfxGetInstanceHandle(), + (LPARAM)LoadImage(hInstance, MAKEINTRESOURCE((ts.VTIcon!=IdIconDefault)?ts.VTIcon:IDI_VT), IMAGE_ICON,16,16,fuLoad)); // Vista \x82\xCC Aero \x82ɂ\xA8\x82\xA2\x82\xC4 Alt+Tab \x90\xE8\x91ւ\xA6\x82ŕ\\x8E\xA6\x82\xB3\x82\xEA\x82\xE9\x83A\x83C\x83R\x83\x93\x82\xAA @@ -749,13 +745,13 @@ // 16x16 \x83A\x83C\x83R\x83\x93\x82̊g\x91\xE5\x82ɂȂ\xC1\x82Ă\xB5\x82܂\xA4\x82̂ŁA\x91傫\x82\xA2\x83A\x83C\x83R\x83\x93\x82\xE0 // \x83Z\x83b\x83g\x82\xB7\x82\xE9 (2008.9.3 maya) ::PostMessage(HVTWin,WM_SETICON,ICON_BIG, - (LPARAM)LoadImage(AfxGetInstanceHandle(), + (LPARAM)LoadImage(hInstance, MAKEINTRESOURCE((ts.VTIcon!=IdIconDefault)?ts.VTIcon:IDI_VT), IMAGE_ICON, 0, 0, fuLoad)); SetCustomNotifyIcon( (HICON)LoadImage( - AfxGetInstanceHandle(), + hInstance, MAKEINTRESOURCE((ts.VTIcon!=IdIconDefault)?ts.VTIcon:IDI_VT), IMAGE_ICON, 16, 16, LR_VGACOLOR|LR_SHARED)); @@ -1051,7 +1047,7 @@ void CVTWindow::InitMenu(HMENU *Menu) { - *Menu = LoadMenu(AfxGetInstanceHandle(), + *Menu = LoadMenu(m_hInst, MAKEINTRESOURCE(IDR_MENU)); char uimsg[MAX_UIMSG]; int ret; @@ -1481,7 +1477,7 @@ { char uimsg[MAX_UIMSG]; - *Menu = LoadMenu(AfxGetInstanceHandle(), + *Menu = LoadMenu(m_hInst, MAKEINTRESOURCE(IDR_PASTEMENU)); GetMenuString(*Menu, ID_EDIT_PASTE2, uimsg, sizeof(uimsg), MF_BYCOMMAND); @@ -1626,7 +1622,7 @@ { ActiveWin = IdTEK; if (HTEKWin==NULL) { - pTEKWin = new CTEKWindow(); + pTEKWin = new CTEKWindow(m_hInst); } else { ::ShowWindow(HTEKWin,SW_SHOWNORMAL); @@ -2073,7 +2069,7 @@ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); DropType = - ShowDropDialogBox(hInst, HVTWin, + ShowDropDialogBox(m_hInst, HVTWin, FileName, DropType, DropListCount - i, (DirectoryCount == 0 && isSSH) ? true : false, @@ -4123,7 +4119,7 @@ void CVTWindow::OnCommentToLog() { // \x83\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82փR\x83\x81\x83\x93\x83g\x82\xF0\x92lj\xC1\x82\xB7\x82\xE9 (2004.8.6 yutaka) - TTDialogBox(hInst, MAKEINTRESOURCE(IDD_COMMENT_DIALOG), + TTDialogBox(m_hInst, MAKEINTRESOURCE(IDD_COMMENT_DIALOG), HVTWin, (DLGPROC)OnCommentDlgProc); } @@ -4454,7 +4450,7 @@ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT"); - CAddSettingPropSheetDlg CAddSetting(hInst, _T("Tera Term: Additional settings"), HVTWin); + CAddSettingPropSheetDlg CAddSetting(m_hInst, _T("Tera Term: Additional settings"), HVTWin); ret = CAddSetting.DoModal(); switch (ret) { case (DWORD)-1: @@ -4603,7 +4599,7 @@ } cf.lpfnHook = (LPCFHOOKPROC)(&TFontHook); cf.nFontType = REGULAR_FONTTYPE; - cf.hInstance = hInst; + cf.hInstance = m_hInst; HelpId = HlpSetupFont; result = ChooseFontA(&cf); @@ -5252,7 +5248,7 @@ // void CVTWindow::OnOpenSetupDirectory() { - TTDialogBox(hInst, MAKEINTRESOURCE(IDD_SETUP_DIR_DIALOG), + TTDialogBox(m_hInst, MAKEINTRESOURCE(IDD_SETUP_DIR_DIALOG), HVTWin, (DLGPROC)OnSetupDirectoryDlgProc); } @@ -5957,7 +5953,7 @@ goto activate; } - hDlgWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG), + hDlgWnd = CreateDialog(m_hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG), HVTWin, (DLGPROC)BroadcastCommandDlgProc); if (hDlgWnd == NULL) { Modified: trunk/teraterm/teraterm/vtwin.h =================================================================== --- trunk/teraterm/teraterm/vtwin.h 2019-08-05 15:35:36 UTC (rev 7915) +++ trunk/teraterm/teraterm/vtwin.h 2019-08-05 15:35:47 UTC (rev 7916) @@ -65,7 +65,7 @@ BOOL IgnoreSizeMessage; public: - CVTWindow(); + CVTWindow(HINSTANCE hInstance); int Parse(); void ButtonUp(BOOL Paste); void ButtonDown(POINT p, int LMR);