| 1 |
/* |
/* |
| 2 |
* Copyright (C) 1994-1998 T. Teranishi |
* Copyright (C) 1994-1998 T. Teranishi |
| 3 |
* (C) 2004-2017 TeraTerm Project |
* (C) 2004-2019 TeraTerm Project |
| 4 |
* All rights reserved. |
* All rights reserved. |
| 5 |
* |
* |
| 6 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
| 48 |
|
|
| 49 |
#include "compat_w95.h" |
#include "compat_w95.h" |
| 50 |
#include "tt_res.h" |
#include "tt_res.h" |
| 51 |
|
#include "codeconv.h" |
| 52 |
|
|
| 53 |
// TMap を格納するファイルマッピングオブジェクト(共有メモリ)の名前 |
// TMap を格納するファイルマッピングオブジェクト(共有メモリ)の名前 |
| 54 |
// TMap(とそのメンバ)の更新時は旧バージョンとの同時起動の為に変える必要があるが |
// TMap(とそのメンバ)の更新時は旧バージョンとの同時起動の為に変える必要があるが |
| 63 |
static PMap pm; |
static PMap pm; |
| 64 |
|
|
| 65 |
static HANDLE HMap = NULL; |
static HANDLE HMap = NULL; |
| 66 |
#define VTCLASSNAME "VTWin32" |
#define VTCLASSNAME _T("VTWin32") |
| 67 |
#define TEKCLASSNAME "TEKWin32" |
#define TEKCLASSNAME _T("TEKWin32") |
| 68 |
|
|
| 69 |
|
#ifdef UNICODE |
| 70 |
|
static HWND(WINAPI *pHtmlHelp)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); |
| 71 |
|
#define HTMLHELP_API_NAME "HtmlHelpW" |
| 72 |
|
#else |
| 73 |
|
static HWND(WINAPI *pHtmlHelp)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); |
| 74 |
|
#define HTMLHELP_API_NAME "HtmlHelpA" |
| 75 |
|
#endif |
| 76 |
|
|
| 77 |
enum window_style { |
enum window_style { |
| 78 |
WIN_CASCADE, |
WIN_CASCADE, |
| 1166 |
char HomeDir[MAX_PATH]; |
char HomeDir[MAX_PATH]; |
| 1167 |
char Temp[MAX_PATH]; |
char Temp[MAX_PATH]; |
| 1168 |
HWND HWin; |
HWND HWin; |
| 1169 |
char HelpFN[MAX_PATH]; |
TCHAR HelpFN[MAX_PATH]; |
| 1170 |
// char UILanguageFile[MAX_PATH]; |
TCHAR uimsg[MAX_UIMSG]; |
| 1171 |
char uimsg[MAX_UIMSG]; |
TCHAR dllName[MAX_PATH]; |
| 1172 |
|
const TCHAR *HomeDirT; |
| 1173 |
|
const TCHAR *errorFile; |
| 1174 |
|
TCHAR buf[MAX_PATH]; |
| 1175 |
|
|
| 1176 |
/* Get home directory */ |
/* Get home directory */ |
| 1177 |
if (GetModuleFileName(NULL,Temp,sizeof(Temp)) == 0) { |
if (GetModuleFileNameA(NULL,Temp,_countof(Temp)) == 0) { |
| 1178 |
return; |
return; |
| 1179 |
} |
} |
| 1180 |
ExtractDirName(Temp, HomeDir); |
ExtractDirName(Temp, HomeDir); |
| 1181 |
|
HomeDirT = ToTcharA(HomeDir); |
| 1182 |
|
|
| 1183 |
// GetUILanguageFile(UILanguageFile, sizeof(UILanguageFile)); |
get_lang_msgT("HELPFILE", uimsg, _countof(uimsg), |
| 1184 |
get_lang_msg("HELPFILE", uimsg, sizeof(uimsg), "teraterm.chm", UILanguageFile); |
_T("teraterm.chm"), UILanguageFile); |
| 1185 |
|
|
| 1186 |
|
if (pHtmlHelp == NULL) { |
| 1187 |
|
HINSTANCE hDll; |
| 1188 |
|
GetSystemDirectory(dllName, _countof(dllName)); |
| 1189 |
|
_tcscat_s(dllName, _countof(dllName), _T("\\hhctrl.ocx")); |
| 1190 |
|
hDll = LoadLibrary(dllName); |
| 1191 |
|
if (hDll == NULL) { |
| 1192 |
|
errorFile = dllName; |
| 1193 |
|
goto error; |
| 1194 |
|
} |
| 1195 |
|
pHtmlHelp = (void *)GetProcAddress(hDll, HTMLHELP_API_NAME); |
| 1196 |
|
if (pHtmlHelp == NULL) { |
| 1197 |
|
errorFile = dllName; |
| 1198 |
|
goto error; |
| 1199 |
|
} |
| 1200 |
|
} |
| 1201 |
// ヘルプのオーナーは常にデスクトップになる (2007.5.12 maya) |
// ヘルプのオーナーは常にデスクトップになる (2007.5.12 maya) |
| 1202 |
HWin = GetDesktopWindow(); |
HWin = GetDesktopWindow(); |
| 1203 |
_snprintf_s(HelpFN, sizeof(HelpFN), _TRUNCATE, "%s\\%s", HomeDir, uimsg); |
_sntprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, _T("%s\\%s"), (TCHAR *)HomeDirT, uimsg); |
| 1204 |
if (HtmlHelp(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) { |
if (pHtmlHelp != NULL && pHtmlHelp(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) { |
| 1205 |
char buf[MAX_PATH]; |
errorFile = HelpFN; |
| 1206 |
get_lang_msg("MSG_OPENHELP_ERROR", uimsg, sizeof(uimsg), "Can't open HTML help file(%s).", UILanguageFile); |
goto error; |
| 1207 |
_snprintf_s(buf, sizeof(buf), _TRUNCATE, uimsg, HelpFN); |
} |
| 1208 |
MessageBox(HWin, buf, "Tera Term: HTML help", MB_OK | MB_ICONERROR); |
goto finish; |
| 1209 |
} |
|
| 1210 |
|
error: |
| 1211 |
|
get_lang_msgT("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg), |
| 1212 |
|
_T("Can't open HTML help file(%s)."), UILanguageFile); |
| 1213 |
|
_sntprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN); |
| 1214 |
|
MessageBox(HWin, buf, _T("Tera Term: HTML help"), MB_OK | MB_ICONERROR); |
| 1215 |
|
|
| 1216 |
|
finish: |
| 1217 |
|
free((void *)HomeDirT); |
| 1218 |
} |
} |
| 1219 |
|
|
| 1220 |
HWND WINAPI GetNthWin(int n) |
HWND WINAPI GetNthWin(int n) |