Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/ttcomtester/teraterm/teraterm/ttwinman.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10521 - (show annotations) (download) (as text)
Fri Jan 20 16:03:38 2023 UTC (13 months, 2 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 8283 byte(s)
add communication test tool
1 /*
2 * Copyright (C) 1994-1998 T. Teranishi
3 * (C) 2005- TeraTerm Project
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /* TERATERM.EXE, variables, flags related to VT win and TEK win */
31
32 #include "teraterm.h"
33 #include "tttypes.h"
34 #include <stdio.h>
35 #include <string.h>
36 #include <malloc.h>
37 #include "ttlib.h"
38 #include "helpid.h"
39 #include "i18n.h"
40 #include "commlib.h"
41 #include "codeconv.h"
42 #include "asprintf.h"
43
44 HWND HVTWin = NULL;
45 HWND HTEKWin = NULL;
46
47 int ActiveWin = IdVT; /* IdVT, IdTEK */
48 IdTalk TalkStatus = IdTalkKeyb; /* IdTalkKeyb, IdTalkCB, IdTalkTextFile */
49 BOOL KeybEnabled = TRUE; /* keyboard switch */
50 BOOL Connecting = FALSE;
51
52 /* 'help' button on dialog box */
53 WORD MsgDlgHelp;
54
55 TTTSet ts;
56 TComVar cv;
57
58 /* pointers to window objects */
59 void* pTEKWin = NULL;
60 /* instance handle */
61 HINSTANCE hInst;
62
63 int SerialNo;
64
65 void VTActivate()
66 {
67 ActiveWin = IdVT;
68 ShowWindow(HVTWin, SW_SHOWNORMAL);
69 SetFocus(HVTWin);
70 }
71
72 // �L���v�V���������X
73 //
74 // (2005.2.19 yutaka) format ID=13���V�K�����ACOM5�������\��������
75 // (2005.3.13 yutaka) �^�C�g����SJIS���������i���{���j������
76 // (2006.6.15 maya) ts.KanjiCode��EUC�����ASJIS����EUC������
77 // �������������������A������������������
78 // (2007.7.19 maya) TCP �|�[�g���� �� �V���A���|�[�g���{�[���[�g���\��������
79 /*
80 * TitleFormat
81 * 0 0 0 0 0 0 (2)
82 * | | | | | +----- displays TCP host/serial port
83 * | | | | +------- displays session no
84 * | | | +--------- displays VT/TEK
85 * | | +----------- displays TCP host/serial port first
86 * | +------------- displays TCP port number
87 * +--------------- displays speed of serial port
88 */
89 void ChangeTitle(void)
90 {
91 #define HostNameMaxLength 1024 // �z�X�g�������� TODO �������������� or ������������������
92 wchar_t TempTitle[HostNameMaxLength + TitleBuffSize * 2 + 1]; // �o�b�t�@�g��
93 wchar_t TempTitleWithRemote[TitleBuffSize * 2];
94
95 {
96 wchar_t *title = ToWcharA(ts.Title);
97 wchar_t *title_remote = ToWcharA(cv.TitleRemote);
98 if (title_remote == NULL) {
99 // TODO cv.TitleRemote �� strncpy_s() ���s���������������������� NULL ������
100 title_remote = _wcsdup(L"-");
101 }
102 if (Connecting || !cv.Ready || wcslen(title_remote) == 0) {
103 wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title, _TRUNCATE);
104 wcsncpy_s(TempTitle, _countof(TempTitle), title, _TRUNCATE);
105 }
106 else {
107 // �����[�g�������^�C�g������������ (2008.11.1 maya)
108 if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestOff) {
109 wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title, _TRUNCATE);
110 }
111 else if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestAhead) {
112 _snwprintf_s(TempTitleWithRemote, _countof(TempTitleWithRemote), _TRUNCATE,
113 L"%s %s", title_remote, title);
114 }
115 else if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestLast) {
116 _snwprintf_s(TempTitleWithRemote, _countof(TempTitleWithRemote), _TRUNCATE,
117 L"%s %s", title, title_remote);
118 }
119 else {
120 wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title_remote, _TRUNCATE);
121 }
122 wcsncpy_s(TempTitle, _countof(TempTitle), TempTitleWithRemote, _TRUNCATE);
123 }
124 free(title);
125 free(title_remote);
126 }
127
128 if ((ts.TitleFormat & 1)!=0)
129 { // host name
130 wchar_t UIMsg[MAX_UIMSG];
131 wcsncat_s(TempTitle,_countof(TempTitle), L" - ",_TRUNCATE);
132 if (Connecting) {
133 get_lang_msgW("DLG_MAIN_TITLE_CONNECTING", UIMsg, _countof(UIMsg), L"[connecting...]", ts.UILanguageFile);
134 wcsncat_s(TempTitle,_countof(TempTitle), UIMsg,_TRUNCATE);
135 }
136 else if (! cv.Ready) {
137 get_lang_msgW("DLG_MAIN_TITLE_DISCONNECTED", UIMsg, _countof(UIMsg), L"[disconnected]", ts.UILanguageFile);
138 wcsncat_s(TempTitle,_countof(TempTitle), UIMsg,_TRUNCATE);
139 }
140 else if (cv.PortType==IdSerial)
141 {
142 // COM5 over������
143 wchar_t str[24]; // COMxxxx:xxxxxxxxxxbps
144 if (ts.TitleFormat & 32) {
145 _snwprintf_s(str, _countof(str), _TRUNCATE, L"COM%d:%ubps", ts.ComPort, ts.Baud);
146 }
147 else {
148 _snwprintf_s(str, _countof(str), _TRUNCATE, L"COM%d", ts.ComPort);
149 }
150
151 if (ts.TitleFormat & 8) {
152 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
153 } else {
154 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
155 }
156 }
157 else if (cv.PortType == IdNamedPipe)
158 {
159 wchar_t str[_countof(TempTitle)];
160 wchar_t *host_name = ToWcharA(ts.HostName);
161 wcsncpy_s(str, _countof(str), host_name, _TRUNCATE);
162 free(host_name);
163
164 if (ts.TitleFormat & 8) {
165 // format ID = 13(8 + 5): <hots/port> - <title>
166 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
167 }
168 else {
169 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
170 }
171 }
172 else {
173 wchar_t str[_countof(TempTitle)];
174 wchar_t *host_name = ToWcharA(ts.HostName);
175 if (ts.TitleFormat & 16) {
176 _snwprintf_s(str, _countof(str), _TRUNCATE, L"%s:%d", host_name, ts.TCPPort);
177 }
178 else {
179 wcsncpy_s(str, _countof(str), host_name, _TRUNCATE);
180 }
181 free(host_name);
182
183 if (ts.TitleFormat & 8) {
184 // format ID = 13(8 + 5): <hots/port> - <title>
185 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
186 }
187 else {
188 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
189 }
190 }
191 }
192
193 if ((ts.TitleFormat & 2)!=0)
194 { // serial no.
195 wchar_t Num[11];
196 wcsncat_s(TempTitle,_countof(TempTitle),L" (",_TRUNCATE);
197 _snwprintf_s(Num,_countof(Num),_TRUNCATE,L"%u",SerialNo);
198 wcsncat_s(TempTitle,_countof(TempTitle),Num,_TRUNCATE);
199 wcsncat_s(TempTitle,_countof(TempTitle),L")",_TRUNCATE);
200 }
201
202 if ((ts.TitleFormat & 4)!=0) // VT
203 wcsncat_s(TempTitle,_countof(TempTitle),L" VT",_TRUNCATE);
204
205 SetWindowTextW(HVTWin,TempTitle);
206
207 if (HTEKWin!=0)
208 {
209 if ((ts.TitleFormat & 4)!=0) // TEK
210 {
211 wcsncat_s(TempTitle,_countof(TempTitle),L" TEK",_TRUNCATE);
212 }
213 SetWindowTextW(HTEKWin,TempTitle);
214 }
215 }
216
217 void SwitchMenu()
218 {
219 HWND H1, H2;
220
221 if (ActiveWin==IdVT)
222 {
223 H1 = HTEKWin;
224 H2 = HVTWin;
225 }
226 else {
227 H1 = HVTWin;
228 H2 = HTEKWin;
229 }
230
231 if (H1!=0)
232 PostMessage(H1,WM_USER_CHANGEMENU,0,0);
233 if (H2!=0)
234 PostMessage(H2,WM_USER_CHANGEMENU,0,0);
235 }
236
237 void SwitchTitleBar()
238 {
239 HWND H1, H2;
240
241 if (ActiveWin==IdVT)
242 {
243 H1 = HTEKWin;
244 H2 = HVTWin;
245 }
246 else {
247 H1 = HVTWin;
248 H2 = HTEKWin;
249 }
250
251 if (H1!=0)
252 PostMessage(H1,WM_USER_CHANGETBAR,0,0);
253 if (H2!=0)
254 PostMessage(H2,WM_USER_CHANGETBAR,0,0);
255 }
256
257 HMODULE LoadHomeDLL(const wchar_t *DLLname)
258 {
259 HMODULE handle;
260 wchar_t *DLLpath;
261 aswprintf(&DLLpath, L"%s\\%s", ts.ExeDirW, DLLname);
262 handle = LoadLibraryW(DLLpath);
263 free(DLLpath);
264 return handle;
265 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26