Commit 0099a0bd71c17e280163952bf0266d49b7e9b563

Authored by xiemeng
1 parent c02556d4

更新UI

... ... @@ -109,7 +109,7 @@ void ErrorReporter(char * szMessage)
109 109
110 110 OutputDebugString(szFinal);
111 111
112   - if (TTYInfo.fDisplayErrors)
  112 + if (g_appdata.fDisplayErrors)
113 113 MessageBox(ghwndMain, szFinal, NULL, MB_OK);
114 114
115 115 LocalFree(szFinal); // free final buffer
... ...
... ... @@ -64,16 +64,12 @@ void GlobalInitialize()
64 64 {
65 65 int cyMenuHeight, cyCaptionHeight, cyFrameHeight;
66 66
67   - //
68 67 // critical sections in status reporting & node management
69 68 // 初始化互斥对象
70 69 InitializeCriticalSection(&gStatusCritical);
71 70 InitializeCriticalSection(&gcsWriterHeap);
72 71 InitializeCriticalSection(&gcsDataHeap);
73   -
74   - //
75 72 // 状态消息事件
76   - //
77 73 ghStatusMessageEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
78 74 if (ghStatusMessageEvent == NULL)
79 75 ErrorReporter("CreateEvent (Status message event)");
... ... @@ -149,7 +145,7 @@ HISTORY: Date: Author: Comment:
149 145 -----------------------------------------------------------------------------*/
150 146 BOOL ClearTTYContents()
151 147 {
152   - FillMemory(TTYInfo.Screen, MAXCOLS*MAXROWS, ' ');
  148 + FillMemory(g_appdata.Screen, MAXCOLS*MAXROWS, ' ');
153 149 return TRUE;
154 150 }
155 151
... ... @@ -178,27 +174,27 @@ void InitNewFont(LOGFONT LogFont, COLORREF rgbColor)
178 174 //
179 175 //如果旧字体存在,那么我应该删除它
180 176 //
181   - if (TTYInfo.hTTYFont)
182   - DeleteObject(TTYInfo.hTTYFont);
  177 + if (g_appdata.hTTYFont)
  178 + DeleteObject(g_appdata.hTTYFont);
183 179
184   - TTYInfo.lfTTYFont = LogFont;
185   - TTYInfo.hTTYFont = CreateFontIndirect(&(TTYInfo.lfTTYFont));
186   - TTYInfo.rgbFGColor = rgbColor;
187   - TTYInfo.rgbBGColor = RGB(255,255,255);
  180 + g_appdata.lfTTYFont = LogFont;
  181 + g_appdata.hTTYFont = CreateFontIndirect(&(g_appdata.lfTTYFont));
  182 + g_appdata.rgbFGColor = rgbColor;
  183 + g_appdata.rgbBGColor = RGB(255,255,255);
188 184
189 185 hDC = GetDC( ghwndMain ) ;
190   - SelectObject( hDC, TTYInfo.hTTYFont ) ;
  186 + SelectObject( hDC, g_appdata.hTTYFont ) ;
191 187 GetTextMetrics( hDC, &tm ) ;
192 188 ReleaseDC( ghwndMain, hDC ) ;
193 189
194 190 //
195 191 //字符的宽度和高度
196 192 //
197   - TTYInfo.xChar = tm.tmAveCharWidth ;
198   - TTYInfo.yChar = tm.tmHeight + tm.tmExternalLeading ;
  193 + g_appdata.xChar = tm.tmAveCharWidth ;
  194 + g_appdata.yChar = tm.tmHeight + tm.tmExternalLeading ;
199 195
200   - TTYInfo.xOffset = 0 ;
201   - TTYInfo.yOffset = TTYInfo.yChar * TTYInfo.nRow;
  196 + g_appdata.xOffset = 0 ;
  197 + g_appdata.yOffset = g_appdata.yChar * g_appdata.nRow;
202 198 }
203 199
204 200 /*-----------------------------------------------------------------------------
... ... @@ -217,79 +213,79 @@ HISTORY: Date: Author: Comment:
217 213 BOOL InitTTYInfo()
218 214 {
219 215
220   - TTYInfo.hCommPort = NULL ;
221   - TTYInfo.fConnected = FALSE ;
222   - TTYInfo.fLocalEcho = FALSE ;
223   - TTYInfo.wCursorState = CS_HIDE ;
224   - TTYInfo.bPort = 1 ;
225   - TTYInfo.dwBaudRate = 921600 ;
226   - TTYInfo.bByteSize = 8 ;
227   - TTYInfo.bParity = NOPARITY ;
228   - TTYInfo.bStopBits = ONESTOPBIT ;
229   - TTYInfo.fAutowrap = TRUE;
230   - TTYInfo.fNewLine = FALSE;
231   - TTYInfo.xSize = 0 ;
232   - TTYInfo.ySize = 0 ;
233   - TTYInfo.xScroll = 0 ;
234   - TTYInfo.yScroll = 0 ;
235   - TTYInfo.nColumn = 0 ;
236   - TTYInfo.nRow = MAXROWS - 1 ;
237   - TTYInfo.fDisplayErrors = TRUE ;
  216 + g_appdata.hCommPort = NULL ;
  217 + g_appdata.fConnected = FALSE ;
  218 + g_appdata.fLocalEcho = FALSE ;
  219 + g_appdata.wCursorState = CS_HIDE ;
  220 + g_appdata.bPort = 1 ;
  221 + g_appdata.dwBaudRate = 921600 ;
  222 + g_appdata.bByteSize = 8 ;
  223 + g_appdata.bParity = NOPARITY ;
  224 + g_appdata.bStopBits = ONESTOPBIT ;
  225 + g_appdata.fAutowrap = TRUE;
  226 + g_appdata.fNewLine = FALSE;
  227 + g_appdata.xSize = 0 ;
  228 + g_appdata.ySize = 0 ;
  229 + g_appdata.xScroll = 0 ;
  230 + g_appdata.yScroll = 0 ;
  231 + g_appdata.nColumn = 0 ;
  232 + g_appdata.nRow = MAXROWS - 1 ;
  233 + g_appdata.fDisplayErrors = TRUE ;
238 234
239 235 //
240 236 // 超时
241 237 //
242   - TTYInfo.timeoutsnew = gTimeoutsDefault;
  238 + g_appdata.timeoutsnew = gTimeoutsDefault;
243 239
244 240 //
245 241 // read state and status events
246 242 //
247 243 gdwReceiveState = RECEIVE_TTY;
248   - TTYInfo.dwEventFlags = EVENTFLAGS_DEFAULT;
249   - TTYInfo.chFlag = FLAGCHAR_DEFAULT;
  244 + g_appdata.dwEventFlags = EVENTFLAGS_DEFAULT;
  245 + g_appdata.chFlag = FLAGCHAR_DEFAULT;
250 246
251 247 //
252 248 // Flow Control Settings
253 249 //
254   - TTYInfo.fDtrControl = DTR_CONTROL_ENABLE;
255   - TTYInfo.fRtsControl = RTS_CONTROL_ENABLE;
256   - TTYInfo.chXON = ASCII_XON;
257   - TTYInfo.chXOFF = ASCII_XOFF;
258   - TTYInfo.wXONLimit = 0;
259   - TTYInfo.wXOFFLimit = 0;
260   - TTYInfo.fCTSOutFlow = FALSE;
261   - TTYInfo.fDSROutFlow = FALSE;
262   - TTYInfo.fDSRInFlow = FALSE;
263   - TTYInfo.fXonXoffOutFlow = FALSE;
264   - TTYInfo.fXonXoffInFlow = FALSE;
265   - TTYInfo.fTXafterXoffSent = FALSE;
266   -
267   - TTYInfo.fNoReading = FALSE;
268   - TTYInfo.fNoWriting = FALSE;
269   - TTYInfo.fNoEvents = FALSE;
270   - TTYInfo.fNoStatus = FALSE;
271   - TTYInfo.fDisplayTimeouts = FALSE;
  250 + g_appdata.fDtrControl = DTR_CONTROL_ENABLE;
  251 + g_appdata.fRtsControl = RTS_CONTROL_ENABLE;
  252 + g_appdata.chXON = ASCII_XON;
  253 + g_appdata.chXOFF = ASCII_XOFF;
  254 + g_appdata.wXONLimit = 0;
  255 + g_appdata.wXOFFLimit = 0;
  256 + g_appdata.fCTSOutFlow = FALSE;
  257 + g_appdata.fDSROutFlow = FALSE;
  258 + g_appdata.fDSRInFlow = FALSE;
  259 + g_appdata.fXonXoffOutFlow = FALSE;
  260 + g_appdata.fXonXoffInFlow = FALSE;
  261 + g_appdata.fTXafterXoffSent = FALSE;
  262 +
  263 + g_appdata.fNoReading = FALSE;
  264 + g_appdata.fNoWriting = FALSE;
  265 + g_appdata.fNoEvents = FALSE;
  266 + g_appdata.fNoStatus = FALSE;
  267 + g_appdata.fDisplayTimeouts = FALSE;
272 268
273 269 //
274 270 // setup default font information
275 271 //
276   - TTYInfo.lfTTYFont.lfHeight = 20 ;
277   - TTYInfo.lfTTYFont.lfWidth = 0 ;
278   - TTYInfo.lfTTYFont.lfEscapement = 0 ;
279   - TTYInfo.lfTTYFont.lfOrientation = 0 ;
280   - TTYInfo.lfTTYFont.lfWeight = 0 ;
281   - TTYInfo.lfTTYFont.lfItalic = 0 ;
282   - TTYInfo.lfTTYFont.lfUnderline = 0 ;
283   - TTYInfo.lfTTYFont.lfStrikeOut = 0 ;
284   - TTYInfo.lfTTYFont.lfCharSet = OEM_CHARSET ;
285   - TTYInfo.lfTTYFont.lfOutPrecision = OUT_DEFAULT_PRECIS ;
286   - TTYInfo.lfTTYFont.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
287   - TTYInfo.lfTTYFont.lfQuality = DEFAULT_QUALITY ;
288   - TTYInfo.lfTTYFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN ;
289   - strcpy( TTYInfo.lfTTYFont.lfFaceName, "宋体" ) ;
290   - TTYInfo.DownloadReday = FALSE;
291   -
292   - InitNewFont( TTYInfo.lfTTYFont, RGB(0,0,0));
  272 + g_appdata.lfTTYFont.lfHeight = 20 ;
  273 + g_appdata.lfTTYFont.lfWidth = 0 ;
  274 + g_appdata.lfTTYFont.lfEscapement = 0 ;
  275 + g_appdata.lfTTYFont.lfOrientation = 0 ;
  276 + g_appdata.lfTTYFont.lfWeight = 0 ;
  277 + g_appdata.lfTTYFont.lfItalic = 0 ;
  278 + g_appdata.lfTTYFont.lfUnderline = 0 ;
  279 + g_appdata.lfTTYFont.lfStrikeOut = 0 ;
  280 + g_appdata.lfTTYFont.lfCharSet = OEM_CHARSET ;
  281 + g_appdata.lfTTYFont.lfOutPrecision = OUT_DEFAULT_PRECIS ;
  282 + g_appdata.lfTTYFont.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
  283 + g_appdata.lfTTYFont.lfQuality = DEFAULT_QUALITY ;
  284 + g_appdata.lfTTYFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN ;
  285 + strcpy( g_appdata.lfTTYFont.lfFaceName, "宋体" ) ;
  286 + g_appdata.DownloadReday = FALSE;
  287 +
  288 + InitNewFont( g_appdata.lfTTYFont, RGB(0,0,0));
293 289
294 290 ClearTTYContents();
295 291
... ... @@ -309,7 +305,7 @@ HISTORY: Date: Author: Comment:
309 305 -----------------------------------------------------------------------------*/
310 306 void DestroyTTYInfo()
311 307 {
312   - DeleteObject(TTYInfo.hTTYFont);
  308 + DeleteObject(g_appdata.hTTYFont);
313 309 }
314 310
315 311 /*-----------------------------------------------------------------------------
... ... @@ -326,11 +322,11 @@ void StartThreads(void)
326 322 {
327 323 DWORD dwReadStatId;
328 324 DWORD dwWriterId;
329   - TTYInfo.hReaderStatus = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) ReaderAndStatusProc, (LPVOID) ghWndTTY, 0, &dwReadStatId);
330   - if (TTYInfo.hReaderStatus == NULL)
  325 + g_appdata.hReaderStatus = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) ReaderAndStatusProc, (LPVOID) ghWndTTY, 0, &dwReadStatId);
  326 + if (g_appdata.hReaderStatus == NULL)
331 327 ErrorInComm("CreateThread(Reader/Status)");
332   - TTYInfo.hWriter = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) WriterProc, (LPVOID) NULL, 0, &dwWriterId);
333   - if (TTYInfo.hWriter == NULL)
  328 + g_appdata.hWriter = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) WriterProc, (LPVOID) NULL, 0, &dwWriterId);
  329 + if (g_appdata.hWriter == NULL)
334 330 ErrorInComm("CreateThread (Writer)");
335 331 return;
336 332 }
... ... @@ -363,7 +359,7 @@ HANDLE SetupCommPort()
363 359 //打开通信端口句柄
364 360 //
365 361 sprintf(gszPort, "\\\\.\\COM%d", myintPort);///可以显示COM10以上端口//add by itas109 2014-01-09
366   - TTYInfo.hCommPort = CreateFile( gszPort,
  362 + g_appdata.hCommPort = CreateFile( gszPort,
367 363 GENERIC_READ | GENERIC_WRITE,
368 364 0,
369 365 0,
... ... @@ -371,13 +367,13 @@ HANDLE SetupCommPort()
371 367 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
372 368 0);
373 369
374   - if (TTYInfo.hCommPort == INVALID_HANDLE_VALUE) {
  370 + if (g_appdata.hCommPort == INVALID_HANDLE_VALUE) {
375 371 ErrorReporter("CreateFile");
376 372 return NULL;
377 373 }
378 374
379 375 //设置新的超时参数
380   - if (!GetCommTimeouts( TTYInfo.hCommPort, &(TTYInfo.timeoutsorig)))
  376 + if (!GetCommTimeouts( g_appdata.hCommPort, &(g_appdata.timeoutsorig)))
381 377 ErrorReporter("GetCommTimeouts");
382 378
383 379 //
... ... @@ -388,12 +384,12 @@ HANDLE SetupCommPort()
388 384 //
389 385 // 设置通信缓冲区大小
390 386 //
391   - SetupComm(TTYInfo.hCommPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER);
  387 + SetupComm(g_appdata.hCommPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER);
392 388
393 389 //
394 390 // 将DT&线路升成高电位。
395 391 // 参考后面注释
396   - if (!EscapeCommFunction(TTYInfo.hCommPort, SETDTR))
  392 + if (!EscapeCommFunction(g_appdata.hCommPort, SETDTR))
397 393 ErrorReporter("EscapeCommFunction (SETDTR)");
398 394
399 395 //
... ... @@ -402,9 +398,9 @@ HANDLE SetupCommPort()
402 398 StartThreads();
403 399
404 400 //设置连接标志
405   - TTYInfo.fConnected = TRUE ;
  401 + g_appdata.fConnected = TRUE ;
406 402
407   - return TTYInfo.hCommPort;
  403 + return g_appdata.hCommPort;
408 404 }
409 405
410 406 /*-----------------------------------------------------------------------------
... ... @@ -430,8 +426,8 @@ DWORD WaitForThreads(DWORD dwTimeout)
430 426 HANDLE hThreads[2];
431 427 DWORD dwRes;
432 428
433   - hThreads[0] = TTYInfo.hReaderStatus;
434   - hThreads[1] = TTYInfo.hWriter;
  429 + hThreads[0] = g_appdata.hReaderStatus;
  430 + hThreads[1] = g_appdata.hWriter;
435 431
436 432 //
437 433 // 设置线程终止句柄
... ... @@ -447,10 +443,10 @@ DWORD WaitForThreads(DWORD dwTimeout)
447 443
448 444 case WAIT_TIMEOUT:
449 445 //读线程
450   - if (WaitForSingleObject(TTYInfo.hReaderStatus, 0) == WAIT_TIMEOUT)
  446 + if (WaitForSingleObject(g_appdata.hReaderStatus, 0) == WAIT_TIMEOUT)
451 447 OutputDebugString("Reader/Status Thread didn't exit.\n\r");
452 448 //写线程
453   - if (WaitForSingleObject(TTYInfo.hWriter, 0) == WAIT_TIMEOUT)
  449 + if (WaitForSingleObject(g_appdata.hWriter, 0) == WAIT_TIMEOUT)
454 450 OutputDebugString("Writer Thread didn't exit.\n\r");
455 451 break;
456 452
... ... @@ -485,10 +481,10 @@ HISTORY: Date: Author: Comment:
485 481 -----------------------------------------------------------------------------*/
486 482 BOOL BreakDownCommPort()
487 483 {
488   - if (!TTYInfo.fConnected)
  484 + if (!g_appdata.fConnected)
489 485 return FALSE;
490 486
491   - TTYInfo.fConnected = FALSE;
  487 + g_appdata.fConnected = FALSE;
492 488
493 489 //
494 490 // 等待线程一小段时间
... ... @@ -497,17 +493,17 @@ BOOL BreakDownCommPort()
497 493 //如果线程还没有退出,那么它们将退出 干扰一个新的连接。 必须中止 整个程序。
498 494 ErrorHandler("Error closing port.");
499 495 // 将DTR线路降成低电位。
500   - if (!EscapeCommFunction(TTYInfo.hCommPort, CLRDTR))
  496 + if (!EscapeCommFunction(g_appdata.hCommPort, CLRDTR))
501 497 ErrorReporter("EscapeCommFunction(CLRDTR)");
502 498 // restore original comm timeouts
503   - if (!SetCommTimeouts(TTYInfo.hCommPort, &(TTYInfo.timeoutsorig)))
  499 + if (!SetCommTimeouts(g_appdata.hCommPort, &(g_appdata.timeoutsorig)))
504 500 ErrorReporter("SetCommTimeouts (Restoration to original)");
505 501 // 清除读取/写入,输入缓冲区和输出缓冲区
506   - if (!PurgeComm(TTYInfo.hCommPort, PURGE_FLAGS))
  502 + if (!PurgeComm(g_appdata.hCommPort, PURGE_FLAGS))
507 503 ErrorReporter("PurgeComm");
508   - CloseHandle(TTYInfo.hCommPort);
509   - CloseHandle(TTYInfo.hReaderStatus);
510   - CloseHandle(TTYInfo.hWriter);
  504 + CloseHandle(g_appdata.hCommPort);
  505 + CloseHandle(g_appdata.hReaderStatus);
  506 + CloseHandle(g_appdata.hWriter);
511 507
512 508 return TRUE;
513 509 }
... ... @@ -528,7 +524,7 @@ HISTORY: Date: Author: Comment:
528 524 -----------------------------------------------------------------------------*/
529 525 BOOL DisconnectOK()
530 526 {
531   - if (!TTYInfo.fConnected) return TRUE;
  527 + if (!g_appdata.fConnected) return TRUE;
532 528 return ((MessageBox(ghwndMain, "OK to Disconnect?", gszPort, MB_YESNO)) == IDYES);
533 529 }
534 530
... ...
... ... @@ -153,7 +153,7 @@ BOOL InitializeApp(HINSTANCE hInst, int nShowCmd)
153 153 GlobalCleanup();
154 154 return FALSE;
155 155 }
156   - QuerySerialPortStatusEx(TTYInfo.unOpenedPortAry,2,255);
  156 + QuerySerialPortStatusEx(g_appdata.unOpenedPortAry,2,255);
157 157 //设置程序的tty子窗口类
158 158 wc.lpfnWndProc = (WNDPROC) TTYChildProc;
159 159 wc.hInstance = hInst;
... ... @@ -220,7 +220,7 @@ int WINAPI MTTTYWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
220 220 OpenTTYChildWindow(hwnd);
221 221 OpenSettingsToolbar(hwnd);
222 222 OpenStatusToolbar(hwnd);
223   - ChangeConnection(hwnd, TTYInfo.fConnected);
  223 + ChangeConnection(hwnd, g_appdata.fConnected);
224 224 break;
225 225
226 226 case WM_DESTROY:
... ... @@ -251,22 +251,7 @@ int WINAPI MTTTYWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
251 251 case WM_SIZE:
252 252 {
253 253 //主窗口大小已经改变,,所以我需要改变子窗口的位置
254   - WORD wTop;
255   - WORD wHeight;
256   - WORD wWidth = LOWORD(lParam);
257   - // 把设置窗口放在顶部
258   - wHeight = SETTINGSFACTOR*gwBaseY;
259   - wTop = 0;
260   - MoveWindow(ghWndToolbarDlg, 0,wTop, wWidth, wHeight, TRUE);
261   - // 把状态窗口放在底部
262   - wHeight = STATUSFACTOR*gwBaseY;
263   - wTop = HIWORD(lParam) - wHeight;
264   - MoveWindow(ghWndStatusDlg, 0, wTop, wWidth, wHeight, TRUE);
265   - // 把TTTY window放在中间
266   - // height = whole window - height of two previous windows
267   - wHeight = HIWORD(lParam) - ((STATUSFACTOR + SETTINGSFACTOR)*gwBaseY);
268   - wTop = SETTINGSFACTOR*gwBaseY;
269   - MoveWindow(ghWndTTY, 0, wTop, wWidth, wHeight, TRUE);
  254 + ResizeAllWindow(LOWORD(lParam),HIWORD(lParam));
270 255 }
271 256 break;
272 257 case WM_COMMAND:
... ... @@ -281,9 +266,9 @@ int WINAPI MTTTYWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
281 266 case WM_CLOSE:
282 267 if (DisconnectOK())
283 268 {
284   - if (TTYInfo.fConnected)
  269 + if (g_appdata.fConnected)
285 270 {
286   - if (TTYInfo.fTransferring)
  271 + if (g_appdata.fTransferring)
287 272 TransferFileTextEnd();
288 273 BreakDownCommPort();
289 274 }
... ... @@ -321,7 +306,7 @@ void CmdDispatch(int iMenuChoice, HWND hwnd, LPARAM lParam)
321 306 break;
322 307 case ID_TRANSFER_SENDFILETEXT:
323 308 {// 发送文件
324   - if (strlen(TTYInfo.szFileName) == 0)
  309 + if (strlen(g_appdata.szFileName) == 0)
325 310 {
326 311 char * szFilter = "Text Files\0*.*\0";
327 312 OPENFILENAME ofn = { 0 };
... ... @@ -334,17 +319,16 @@ void CmdDispatch(int iMenuChoice, HWND hwnd, LPARAM lParam)
334 319 ofn.Flags = OFN_FILEMUSTEXIST;
335 320 if (!GetOpenFileName(&ofn))
336 321 break;
337   - strcpy(TTYInfo.szFileName, szFileName);
  322 + strcpy(g_appdata.szFileName, szFileName);
338 323 }
339 324 if (TRUE)
340   - TransferFileTextStart(TTYInfo.szFileName);
  325 + TransferFileTextStart(g_appdata.szFileName);
341 326 }
342 327 break;
343 328 case ID_TRANSFER_RECEIVEFILETEXT:
344 329 {// 接收文件
345 330 char * szFilter = "Text Files\0*.TXT\0";
346 331 OPENFILENAME ofn = {0};
347   -
348 332 ofn.lStructSize = sizeof(OPENFILENAME);
349 333 ofn.hwndOwner = hwnd;
350 334 ofn.lpstrFilter = szFilter;
... ... @@ -352,32 +336,10 @@ void CmdDispatch(int iMenuChoice, HWND hwnd, LPARAM lParam)
352 336 ofn.nMaxFile = MAX_PATH;
353 337 ofn.lpstrTitle = "Receive File";
354 338 ofn.Flags = OFN_OVERWRITEPROMPT;
355   -
356   - if (!GetSaveFileName(&ofn))
357   - break;
358   -
  339 + if (!GetSaveFileName(&ofn)) break;
359 340 ReceiveFileText(szFileName);
360 341 }
361 342 break;
362   -
363   - case ID_TRANSFER_ABORTSENDING:
364   - // 是否从中止按钮发出中止?
365   - if (LOWORD(lParam) == IDC_ABORTBTN) {
366   - // am I in a transfer repeat?
367   - if (TTYInfo.fRepeating)
368   - TransferRepeatDestroy();
369   - // am I in a normal recieve state, then stop sending
370   - else if (gdwReceiveState == RECEIVE_TTY)
371   - TransferFileTextEnd();
372   - // if I am not in a normal receive state, then stop capturing
373   - else
374   - gfAbortTransfer = TRUE;
375   - }
376   - else
377   - //传输中止
378   - TransferFileTextEnd();
379   - break;
380   -
381 343 case ID_TRANSFER_SENDREPEATEDLY:
382 344 {// 重复发送
383 345 DWORD dwFreq;
... ... @@ -391,9 +353,7 @@ void CmdDispatch(int iMenuChoice, HWND hwnd, LPARAM lParam)
391 353 ofn.nMaxFile = MAX_PATH;
392 354 ofn.lpstrTitle = "Send File Repeatedly";
393 355 ofn.Flags = OFN_FILEMUSTEXIST;
394   -
395   - if (!GetOpenFileName(&ofn))
396   - break;
  356 + if (!GetOpenFileName(&ofn)) break;
397 357 TransferRepeatCreate(szFileName, 3000);
398 358 }
399 359 break;
... ... @@ -417,12 +377,12 @@ void CmdDispatch(int iMenuChoice, HWND hwnd, LPARAM lParam)
417 377
418 378 case ID_FILE_CONNECT:
419 379 if (SetupCommPort() != NULL)
420   - ChangeConnection(hwnd, TTYInfo.fConnected);
  380 + ChangeConnection(hwnd, g_appdata.fConnected);
421 381 break;
422 382
423 383 case ID_FILE_DISCONNECT:
424 384 if (BreakDownCommPort())
425   - ChangeConnection(hwnd, TTYInfo.fConnected);
  385 + ChangeConnection(hwnd, g_appdata.fConnected);
426 386 break;
427 387
428 388 case ID_FILE_EXIT:
... ... @@ -484,48 +444,48 @@ BOOL NEAR ScrollTTYVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
484 444 switch (wScrollCmd)
485 445 {
486 446 case SB_TOP:
487   - nScrollAmt = -TTYInfo.yOffset ;
  447 + nScrollAmt = -g_appdata.yOffset ;
488 448 break ;
489 449
490 450 case SB_BOTTOM:
491   - nScrollAmt = TTYInfo.yScroll - TTYInfo.yOffset ;
  451 + nScrollAmt = g_appdata.yScroll - g_appdata.yOffset ;
492 452 break ;
493 453
494 454 case SB_PAGEUP:
495   - nScrollAmt = -TTYInfo.ySize ;
  455 + nScrollAmt = -g_appdata.ySize ;
496 456 break ;
497 457
498 458 case SB_PAGEDOWN:
499   - nScrollAmt = TTYInfo.ySize ;
  459 + nScrollAmt = g_appdata.ySize ;
500 460 break ;
501 461
502 462 case SB_LINEUP:
503   - nScrollAmt = -TTYInfo.yChar ;
  463 + nScrollAmt = -g_appdata.yChar ;
504 464 break ;
505 465
506 466 case SB_LINEDOWN:
507   - nScrollAmt = TTYInfo.yChar ;
  467 + nScrollAmt = g_appdata.yChar ;
508 468 break ;
509 469
510 470 case SB_THUMBPOSITION:
511   - nScrollAmt = wScrollPos - TTYInfo.yOffset ;
  471 + nScrollAmt = wScrollPos - g_appdata.yOffset ;
512 472 break ;
513 473
514 474 default:
515 475 return ( FALSE ) ;
516 476 }
517 477
518   - if ((TTYInfo.yOffset + nScrollAmt) > TTYInfo.yScroll)
519   - nScrollAmt = TTYInfo.yScroll - TTYInfo.yOffset ;
  478 + if ((g_appdata.yOffset + nScrollAmt) > g_appdata.yScroll)
  479 + nScrollAmt = g_appdata.yScroll - g_appdata.yOffset ;
520 480
521   - if ((TTYInfo.yOffset + nScrollAmt) < 0)
522   - nScrollAmt = -TTYInfo.yOffset ;
  481 + if ((g_appdata.yOffset + nScrollAmt) < 0)
  482 + nScrollAmt = -g_appdata.yOffset ;
523 483
524 484 ScrollWindowEx( hWnd, 0, -nScrollAmt, NULL, NULL, NULL, NULL, SW_INVALIDATE | SW_ERASE) ;
525 485
526   - TTYInfo.yOffset = TTYInfo.yOffset + nScrollAmt ;
  486 + g_appdata.yOffset = g_appdata.yOffset + nScrollAmt ;
527 487
528   - SetScrollPos( hWnd, SB_VERT, TTYInfo.yOffset, TRUE ) ;
  488 + SetScrollPos( hWnd, SB_VERT, g_appdata.yOffset, TRUE ) ;
529 489
530 490 return ( TRUE ) ;
531 491
... ... @@ -559,43 +519,43 @@ BOOL NEAR ScrollTTYHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
559 519 switch (wScrollCmd)
560 520 {
561 521 case SB_TOP:
562   - nScrollAmt = -TTYInfo.xOffset ;
  522 + nScrollAmt = -g_appdata.xOffset ;
563 523 break ;
564 524
565 525 case SB_BOTTOM:
566   - nScrollAmt = TTYInfo.xScroll - TTYInfo.xOffset ;
  526 + nScrollAmt = g_appdata.xScroll - g_appdata.xOffset ;
567 527 break ;
568 528
569 529 case SB_PAGEUP:
570   - nScrollAmt = -TTYInfo.xSize ;
  530 + nScrollAmt = -g_appdata.xSize ;
571 531 break ;
572 532
573 533 case SB_PAGEDOWN:
574   - nScrollAmt = TTYInfo.xSize ;
  534 + nScrollAmt = g_appdata.xSize ;
575 535 break ;
576 536
577 537 case SB_LINEUP:
578   - nScrollAmt = -TTYInfo.xChar ;
  538 + nScrollAmt = -g_appdata.xChar ;
579 539 break ;
580 540
581 541 case SB_LINEDOWN:
582   - nScrollAmt = TTYInfo.xChar ;
  542 + nScrollAmt = g_appdata.xChar ;
583 543 break ;
584 544
585 545 case SB_THUMBPOSITION:
586   - nScrollAmt = wScrollPos - TTYInfo.xOffset ;
  546 + nScrollAmt = wScrollPos - g_appdata.xOffset ;
587 547 break ;
588 548
589 549 default:
590 550 return ( FALSE ) ;
591 551 }
592   - if ((TTYInfo.xOffset + nScrollAmt) > TTYInfo.xScroll)
593   - nScrollAmt = TTYInfo.xScroll - TTYInfo.xOffset ;
594   - if ((TTYInfo.xOffset + nScrollAmt) < 0)
595   - nScrollAmt = -TTYInfo.xOffset ;
  552 + if ((g_appdata.xOffset + nScrollAmt) > g_appdata.xScroll)
  553 + nScrollAmt = g_appdata.xScroll - g_appdata.xOffset ;
  554 + if ((g_appdata.xOffset + nScrollAmt) < 0)
  555 + nScrollAmt = -g_appdata.xOffset ;
596 556 ScrollWindowEx( hWnd, -nScrollAmt, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE | SW_ERASE) ;
597   - TTYInfo.xOffset = TTYInfo.xOffset + nScrollAmt ;
598   - SetScrollPos( hWnd, SB_HORZ, TTYInfo.xOffset, TRUE ) ;
  557 + g_appdata.xOffset = g_appdata.xOffset + nScrollAmt ;
  558 + SetScrollPos( hWnd, SB_HORZ, g_appdata.xOffset, TRUE ) ;
599 559
600 560 return ( TRUE ) ;
601 561
... ... @@ -635,34 +595,34 @@ BOOL NEAR PaintTTY( HWND hWnd )
635 595 int nCount, nHorzPos, nVertPos ;
636 596
637 597 hDC = BeginPaint( hWnd, &ps ) ;
638   - hOldFont = SelectObject( hDC, TTYInfo.hTTYFont ) ;
639   - SetTextColor( hDC, TTYInfo.rgbFGColor ) ;
640   - SetBkColor( hDC, TTYInfo.rgbBGColor ) ;
  598 + hOldFont = SelectObject( hDC, g_appdata.hTTYFont ) ;
  599 + SetTextColor( hDC, g_appdata.rgbFGColor ) ;
  600 + SetBkColor( hDC, g_appdata.rgbBGColor ) ;
641 601 rect = ps.rcPaint ;
642 602 nRow =
643 603 min( MAXROWS - 1,
644   - max( 0, (rect.top + TTYInfo.yOffset) / TTYInfo.yChar ) ) ;
  604 + max( 0, (rect.top + g_appdata.yOffset) / g_appdata.yChar ) ) ;
645 605 nEndRow =
646 606 min( MAXROWS - 1,
647   - ((rect.bottom + TTYInfo.yOffset - 1) / TTYInfo.yChar ) ) ;
  607 + ((rect.bottom + g_appdata.yOffset - 1) / g_appdata.yChar ) ) ;
648 608 nCol =
649 609 min( MAXCOLS - 1,
650   - max( 0, (rect.left + TTYInfo.xOffset) / TTYInfo.xChar ) ) ;
  610 + max( 0, (rect.left + g_appdata.xOffset) / g_appdata.xChar ) ) ;
651 611 nEndCol =
652 612 min( MAXCOLS - 1,
653   - ((rect.right + TTYInfo.xOffset - 1) / TTYInfo.xChar ) ) ;
  613 + ((rect.right + g_appdata.xOffset - 1) / g_appdata.xChar ) ) ;
654 614 nCount = nEndCol - nCol + 1 ;
655 615 for (; nRow <= nEndRow; nRow++)
656 616 {
657   - nVertPos = (nRow * TTYInfo.yChar) - TTYInfo.yOffset ;
658   - nHorzPos = (nCol * TTYInfo.xChar) - TTYInfo.xOffset ;
  617 + nVertPos = (nRow * g_appdata.yChar) - g_appdata.yOffset ;
  618 + nHorzPos = (nCol * g_appdata.xChar) - g_appdata.xOffset ;
659 619 rect.top = nVertPos ;
660   - rect.bottom = nVertPos + TTYInfo.yChar ;
  620 + rect.bottom = nVertPos + g_appdata.yChar ;
661 621 rect.left = nHorzPos ;
662   - rect.right = nHorzPos + TTYInfo.xChar * nCount ;
  622 + rect.right = nHorzPos + g_appdata.xChar * nCount ;
663 623 SetBkMode( hDC, TRANSPARENT ) ;
664 624 ExtTextOut( hDC, nHorzPos, nVertPos, ETO_OPAQUE | ETO_CLIPPED, &rect,
665   - (LPSTR)( TTYInfo.Screen + nRow * MAXCOLS + nCol ),
  625 + (LPSTR)( g_appdata.Screen + nRow * MAXCOLS + nCol ),
666 626 nCount, NULL ) ;
667 627 }
668 628 SelectObject( hDC, hOldFont ) ;
... ... @@ -689,11 +649,11 @@ BOOL NEAR PaintTTY( HWND hWnd )
689 649 //---------------------------------------------------------------------------
690 650 BOOL NEAR MoveTTYCursor( HWND hWnd )
691 651 {
692   - if (TTYInfo.fConnected && (TTYInfo.wCursorState& CS_SHOW))
693   - SetCaretPos( (TTYInfo.nColumn * TTYInfo.xChar) -
694   - TTYInfo.xOffset,
695   - (TTYInfo.nRow * TTYInfo.yChar) -
696   - TTYInfo.yOffset ) ;
  652 + if (g_appdata.fConnected && (g_appdata.wCursorState& CS_SHOW))
  653 + SetCaretPos( (g_appdata.nColumn * g_appdata.xChar) -
  654 + g_appdata.xOffset,
  655 + (g_appdata.nRow * g_appdata.yChar) -
  656 + g_appdata.yOffset ) ;
697 657
698 658 return ( TRUE ) ;
699 659
... ... @@ -716,11 +676,11 @@ BOOL NEAR MoveTTYCursor( HWND hWnd )
716 676 //---------------------------------------------------------------------------
717 677 BOOL NEAR SetTTYFocus( HWND hWnd )
718 678 {
719   - if (TTYInfo.fConnected && (TTYInfo.wCursorState!= CS_SHOW) )
  679 + if (g_appdata.fConnected && (g_appdata.wCursorState!= CS_SHOW) )
720 680 {
721   - CreateCaret( hWnd, NULL, TTYInfo.xChar, TTYInfo.yChar ) ;
  681 + CreateCaret( hWnd, NULL, g_appdata.xChar, g_appdata.yChar ) ;
722 682 ShowCaret( hWnd ) ;
723   - TTYInfo.wCursorState= CS_SHOW ;
  683 + g_appdata.wCursorState= CS_SHOW ;
724 684 }
725 685
726 686 MoveTTYCursor( hWnd ) ;
... ... @@ -745,11 +705,11 @@ BOOL NEAR SetTTYFocus( HWND hWnd )
745 705 //---------------------------------------------------------------------------
746 706 BOOL NEAR KillTTYFocus( HWND hWnd )
747 707 {
748   - if (TTYInfo.wCursorState!= CS_HIDE)
  708 + if (g_appdata.wCursorState!= CS_HIDE)
749 709 {
750 710 HideCaret( hWnd ) ;
751 711 DestroyCaret() ;
752   - TTYInfo.wCursorState= CS_HIDE ;
  712 + g_appdata.wCursorState= CS_HIDE ;
753 713 }
754 714 return ( TRUE ) ;
755 715
... ... @@ -784,29 +744,29 @@ BOOL NEAR SizeTTY( HWND hWnd, WORD wWidth, WORD wHeight )
784 744 //
785 745 // adjust vert settings
786 746 //
787   - TTYInfo.ySize = (int) wHeight ;
788   - TTYInfo.yScroll = max( 0, (MAXROWS * TTYInfo.yChar) -
789   - TTYInfo.ySize ) ;
790   - nScrollAmt = min( TTYInfo.yScroll, TTYInfo.yOffset ) -
791   - TTYInfo.yOffset ;
  747 + g_appdata.ySize = (int) wHeight ;
  748 + g_appdata.yScroll = max( 0, (MAXROWS * g_appdata.yChar) -
  749 + g_appdata.ySize ) ;
  750 + nScrollAmt = min( g_appdata.yScroll, g_appdata.yOffset ) -
  751 + g_appdata.yOffset ;
792 752 ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ;
793 753
794   - TTYInfo.yOffset = TTYInfo.yOffset + nScrollAmt ;
795   - SetScrollPos( hWnd, SB_VERT, TTYInfo.yOffset, FALSE ) ;
796   - SetScrollRange( hWnd, SB_VERT, 0, TTYInfo.yScroll, TRUE ) ;
  754 + g_appdata.yOffset = g_appdata.yOffset + nScrollAmt ;
  755 + SetScrollPos( hWnd, SB_VERT, g_appdata.yOffset, FALSE ) ;
  756 + SetScrollRange( hWnd, SB_VERT, 0, g_appdata.yScroll, TRUE ) ;
797 757
798 758 //
799 759 // adjust horz settings
800 760 //
801   - TTYInfo.xSize = (int) wHeight ;
802   - TTYInfo.xScroll = max( 0, (MAXCOLS * TTYInfo.xChar) -
803   - TTYInfo.xSize ) ;
804   - nScrollAmt = min( TTYInfo.xScroll, TTYInfo.xOffset) -
805   - TTYInfo.xOffset ;
  761 + g_appdata.xSize = (int) wHeight ;
  762 + g_appdata.xScroll = max( 0, (MAXCOLS * g_appdata.xChar) -
  763 + g_appdata.xSize ) ;
  764 + nScrollAmt = min( g_appdata.xScroll, g_appdata.xOffset) -
  765 + g_appdata.xOffset ;
806 766 ScrollWindow( hWnd, nScrollAmt, 0, NULL, NULL );
807   - TTYInfo.xOffset = TTYInfo.xOffset + nScrollAmt ;
808   - SetScrollRange( hWnd, SB_HORZ, 0, TTYInfo.xScroll, FALSE ) ;
809   - SetScrollPos( hWnd, SB_HORZ, TTYInfo.xOffset, TRUE ) ;
  767 + g_appdata.xOffset = g_appdata.xOffset + nScrollAmt ;
  768 + SetScrollRange( hWnd, SB_HORZ, 0, g_appdata.xScroll, FALSE ) ;
  769 + SetScrollPos( hWnd, SB_HORZ, g_appdata.xOffset, TRUE ) ;
810 770
811 771 InvalidateRect( hWnd, NULL, FALSE ) ; // redraw entire window
812 772
... ... @@ -855,12 +815,12 @@ int WINAPI TTYChildProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
855 815 //
856 816 // keyboard activity in TTY Window
857 817 //
858   - if (TTYInfo.fConnected) {
  818 + if (g_appdata.fConnected) {
859 819
860 820 if (!WriterAddNewNode(WRITE_CHAR, 0, (char) wParam, NULL, NULL, NULL))
861 821 return FALSE;
862 822
863   - if (TTYInfo.fLocalEcho)
  823 + if (g_appdata.fLocalEcho)
864 824 OutputABufferToWindow(ghWndTTY, (CHAR *) &wParam, 1);
865 825 }
866 826 }
... ... @@ -885,3 +845,41 @@ int WINAPI TTYChildProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
885 845 }
886 846 return 0L;
887 847 }
  848 +BOOL ResizeAllWindow(DWORD mainwidth, WORD mainheigh)
  849 +{
  850 + RECT rect_setting,rect_info,rect_stauts;
  851 + rect_setting.left = 0;
  852 + rect_setting.top = 0;
  853 + rect_setting.right = mainwidth;
  854 + rect_setting.bottom = SETTINGSFACTOR*gwBaseY;
  855 +
  856 + rect_info.left = mainwidth*2/3;
  857 + rect_info.top = rect_setting.bottom;
  858 + rect_info.right = mainwidth;
  859 + rect_info.bottom = mainheigh;
  860 +
  861 + rect_stauts.left = 0;
  862 + rect_stauts.top = rect_setting.bottom;
  863 + rect_stauts.right = rect_info.left ;
  864 + rect_stauts.bottom = mainheigh;
  865 +
  866 + MoveWindow(ghWndToolbarDlg,
  867 + rect_setting.left,
  868 + rect_setting.top,
  869 + rect_setting.right -rect_setting.left,
  870 + rect_setting.bottom -rect_setting.top,
  871 + TRUE);
  872 + MoveWindow(ghWndTTY,
  873 + rect_info.left,
  874 + rect_info.top,
  875 + rect_info.right -rect_info.left,
  876 + rect_info.bottom -rect_info.top,
  877 + TRUE);
  878 + MoveWindow(ghWndStatusDlg,
  879 + rect_stauts.left,
  880 + rect_stauts.top,
  881 + rect_stauts.right -rect_stauts.left,
  882 + rect_stauts.bottom -rect_stauts.top,
  883 + TRUE);
  884 +
  885 +}
... ...
... ... @@ -203,7 +203,7 @@ $(OUTDIR)/MTTTY.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
203 203 SOURCE=.\MTTTY.c
204 204 DEP_MTTTY=\
205 205 .\MTTTY.h\
206   - .\TTYInfo.h
  206 + .\g_appdata.h
207 207
208 208 $(INTDIR)/MTTTY.obj : $(SOURCE) $(DEP_MTTTY) $(INTDIR)
209 209
... ... @@ -214,7 +214,7 @@ $(INTDIR)/MTTTY.obj : $(SOURCE) $(DEP_MTTTY) $(INTDIR)
214 214 SOURCE=.\Status.c
215 215 DEP_STATU=\
216 216 .\MTTTY.h\
217   - .\TTYInfo.h
  217 + .\g_appdata.h
218 218
219 219 $(INTDIR)/Status.obj : $(SOURCE) $(DEP_STATU) $(INTDIR)
220 220
... ... @@ -225,7 +225,7 @@ $(INTDIR)/Status.obj : $(SOURCE) $(DEP_STATU) $(INTDIR)
225 225 SOURCE=.\Reader.c
226 226 DEP_READE=\
227 227 .\MTTTY.h\
228   - .\TTYInfo.h
  228 + .\g_appdata.h
229 229
230 230 $(INTDIR)/Reader.obj : $(SOURCE) $(DEP_READE) $(INTDIR)
231 231
... ... @@ -236,7 +236,7 @@ $(INTDIR)/Reader.obj : $(SOURCE) $(DEP_READE) $(INTDIR)
236 236 SOURCE=.\Error.c
237 237 DEP_ERROR=\
238 238 .\MTTTY.h\
239   - .\TTYInfo.h
  239 + .\g_appdata.h
240 240
241 241 $(INTDIR)/Error.obj : $(SOURCE) $(DEP_ERROR) $(INTDIR)
242 242
... ... @@ -247,7 +247,7 @@ $(INTDIR)/Error.obj : $(SOURCE) $(DEP_ERROR) $(INTDIR)
247 247 SOURCE=.\About.c
248 248 DEP_ABOUT=\
249 249 .\MTTTY.h\
250   - .\TTYInfo.h
  250 + .\g_appdata.h
251 251
252 252 $(INTDIR)/About.obj : $(SOURCE) $(DEP_ABOUT) $(INTDIR)
253 253
... ... @@ -272,7 +272,7 @@ $(INTDIR)/MTTTY.res : $(SOURCE) $(DEP_MTTTY_) $(INTDIR)
272 272 SOURCE=.\Settings.c
273 273 DEP_SETTI=\
274 274 .\MTTTY.h\
275   - .\TTYInfo.h
  275 + .\g_appdata.h
276 276
277 277 $(INTDIR)/Settings.obj : $(SOURCE) $(DEP_SETTI) $(INTDIR)
278 278
... ... @@ -283,7 +283,7 @@ $(INTDIR)/Settings.obj : $(SOURCE) $(DEP_SETTI) $(INTDIR)
283 283 SOURCE=.\Init.c
284 284 DEP_INIT_=\
285 285 .\MTTTY.h\
286   - .\TTYInfo.h
  286 + .\g_appdata.h
287 287
288 288 $(INTDIR)/Init.obj : $(SOURCE) $(DEP_INIT_) $(INTDIR)
289 289
... ... @@ -294,7 +294,7 @@ $(INTDIR)/Init.obj : $(SOURCE) $(DEP_INIT_) $(INTDIR)
294 294 SOURCE=.\Writer.c
295 295 DEP_WRITE=\
296 296 .\MTTTY.h\
297   - .\TTYInfo.h
  297 + .\g_appdata.h
298 298
299 299 $(INTDIR)/Writer.obj : $(SOURCE) $(DEP_WRITE) $(INTDIR)
300 300
... ... @@ -305,7 +305,7 @@ $(INTDIR)/Writer.obj : $(SOURCE) $(DEP_WRITE) $(INTDIR)
305 305 SOURCE=.\Transfer.c
306 306 DEP_TRANS=\
307 307 .\MTTTY.h\
308   - .\TTYInfo.h
  308 + .\g_appdata.h
309 309
310 310 $(INTDIR)/Transfer.obj : $(SOURCE) $(DEP_TRANS) $(INTDIR)
311 311
... ... @@ -316,7 +316,7 @@ $(INTDIR)/Transfer.obj : $(SOURCE) $(DEP_TRANS) $(INTDIR)
316 316 SOURCE=.\ReadStat.c
317 317 DEP_READS=\
318 318 .\MTTTY.h\
319   - .\TTYInfo.h
  319 + .\g_appdata.h
320 320
321 321 $(INTDIR)/ReadStat.obj : $(SOURCE) $(DEP_READS) $(INTDIR)
322 322
... ...
... ... @@ -29,7 +29,6 @@ IDR_MTTTYACCELERATOR ACCELERATORS
29 29 BEGIN
30 30 VK_F5, ID_TRANSFER_SENDFILETEXT, VIRTKEY, NOINVERT
31 31 VK_F5, ID_TRANSFER_ABORTREPEATEDSENDING, VIRTKEY, ALT, NOINVERT
32   - VK_F5, ID_TRANSFER_ABORTSENDING, VIRTKEY, SHIFT, NOINVERT
33 32 "x", ID_FILE_EXIT, ASCII, ALT, NOINVERT
34 33 END
35 34
... ... @@ -53,7 +52,7 @@ BEGIN
53 52 EDITTEXT IDC_OSVERSIONINFO,36,81,104,46,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY
54 53 END
55 54
56   -IDD_TOOLBARSETTINGS DIALOGEX 0, 0, 414, 18
  55 +IDD_TOOLBARSETTINGS DIALOGEX 0, 0, 340, 14
57 56 STYLE DS_ABSALIGN | DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER
58 57 FONT 12, "??", 400, 0, 0x0
59 58 BEGIN
... ... @@ -62,13 +61,11 @@ BEGIN
62 61 PUSHBUTTON "软件路径",IDC_BUTTON2_SEC_BINFILE,109,0,50,14
63 62 END
64 63
65   -IDD_STATUSDIALOG DIALOGEX 0, 0, 448, 19
  64 +IDD_STATUSDIALOG DIALOGEX 0, 0, 392, 281
66 65 STYLE DS_ABSALIGN | DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER
67 66 FONT 8, "MS Sans Serif", 0, 0, 0x0
68 67 BEGIN
69   - PUSHBUTTON "",IDC_ABORTBTN,0,1,60,12,NOT WS_VISIBLE
70   - CONTROL "Generic1",IDC_TRANSFERPROGRESS,"msctls_progress32",NOT WS_VISIBLE | WS_BORDER,68,3,65,6
71   - EDITTEXT IDC_STATUSEDIT,178,0,262,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
  68 + EDITTEXT IDC_STATUSEDIT,151,25,111,101,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
72 69 END
73 70
74 71
... ... @@ -110,7 +107,6 @@ BEGIN
110 107 BEGIN
111 108 MENUITEM "&Send Bin File .\tF5", ID_TRANSFER_SENDFILETEXT
112 109 MENUITEM "&Receive File (Text)...", ID_TRANSFER_RECEIVEFILETEXT
113   - MENUITEM "&Abort Sending\tShift+F5", ID_TRANSFER_ABORTSENDING, GRAYED
114 110 MENUITEM SEPARATOR
115 111 MENUITEM "S&end Repeatedly...", ID_TRANSFER_SENDREPEATEDLY
116 112 MENUITEM "A&bort Repeated Sending\tAlt+F5", ID_TRANSFER_ABORTREPEATEDSENDING
... ... @@ -186,6 +182,22 @@ BEGIN
186 182 END
187 183 END
188 184
  185 +
  186 +/////////////////////////////////////////////////////////////////////////////
  187 +//
  188 +// DESIGNINFO
  189 +//
  190 +
  191 +#ifdef APSTUDIO_INVOKED
  192 +GUIDELINES DESIGNINFO
  193 +BEGIN
  194 + IDD_TOOLBARSETTINGS, DIALOG
  195 + BEGIN
  196 + RIGHTMARGIN, 332
  197 + END
  198 +END
  199 +#endif // APSTUDIO_INVOKED
  200 +
189 201 #endif // 中文(中华人民共和国) resources
190 202 /////////////////////////////////////////////////////////////////////////////
191 203
... ...
... ... @@ -61,40 +61,40 @@ void OutputABufferToWindow(HWND hTTY, char * lpBuf, DWORD dwBufLen)
61 61 MessageBeep(0);
62 62 break;
63 63 case ASCII_BS: // Backspace CHAR
64   - if (TTYInfo.nColumn > 0)
65   - TTYInfo.nColumn--;
  64 + if (g_appdata.nColumn > 0)
  65 + g_appdata.nColumn--;
66 66 break;
67 67 case ASCII_CR: // Carriage Return
68   - TTYInfo.nColumn = 0;
69   - if (!TTYInfo.fNewLine)
  68 + g_appdata.nColumn = 0;
  69 + if (!g_appdata.fNewLine)
70 70 break;
71 71
72 72 //
73 73 // FALL THROUGH
74 74 //
75 75 case ASCII_LF: // Line Feed
76   - if (TTYInfo.nRow++ == MAXROWS - 1)
  76 + if (g_appdata.nRow++ == MAXROWS - 1)
77 77 {
78   - MoveMemory((LPSTR) (TTYInfo.Screen),
79   - (LPSTR) (TTYInfo.Screen + MAXCOLS),
  78 + MoveMemory((LPSTR) (g_appdata.Screen),
  79 + (LPSTR) (g_appdata.Screen + MAXCOLS),
80 80 (MAXROWS - 1) *MAXCOLS);
81   - FillMemory((LPSTR) (TTYInfo.Screen + (MAXROWS - 1) *MAXCOLS),
  81 + FillMemory((LPSTR) (g_appdata.Screen + (MAXROWS - 1) *MAXCOLS),
82 82 MAXCOLS, ' ');
83 83 InvalidateRect(hTTY, NULL, FALSE);
84   - TTYInfo.nRow--;
  84 + g_appdata.nRow--;
85 85 }
86 86 break;
87 87 default: // standard character
88   - TTYInfo.Screen[TTYInfo.nRow * MAXCOLS + TTYInfo.nColumn] = lpBuf[i];
89   - rect.left = (TTYInfo.nColumn * TTYInfo.xChar) -TTYInfo.xOffset;
90   - rect.right = rect.left + TTYInfo.xChar;
91   - rect.top = (TTYInfo.nRow * TTYInfo.yChar) -TTYInfo.yOffset;
92   - rect.bottom = rect.top + TTYInfo.yChar;
  88 + g_appdata.Screen[g_appdata.nRow * MAXCOLS + g_appdata.nColumn] = lpBuf[i];
  89 + rect.left = (g_appdata.nColumn * g_appdata.xChar) -g_appdata.xOffset;
  90 + rect.right = rect.left + g_appdata.xChar;
  91 + rect.top = (g_appdata.nRow * g_appdata.yChar) -g_appdata.yOffset;
  92 + rect.bottom = rect.top + g_appdata.yChar;
93 93 InvalidateRect(hTTY, &rect, FALSE);
94 94 // Line wrap
95   - if (TTYInfo.nColumn < MAXCOLS - 1)
96   - TTYInfo.nColumn++;
97   - else if (TTYInfo.fAutowrap)
  95 + if (g_appdata.nColumn < MAXCOLS - 1)
  96 + g_appdata.nColumn++;
  97 + else if (g_appdata.fAutowrap)
98 98 OutputABufferToWindow(hTTY, "\r\n", 2);
99 99 break;
100 100 }
... ...
... ... @@ -98,21 +98,21 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
98 98 // If no reading is allowed, then set flag to
99 99 // make it look like a read is already outstanding.
100 100 //
101   - if (TTYInfo.fNoReading)
  101 + if (g_appdata.fNoReading)
102 102 fWaitingOnRead = TRUE;
103 103
104 104 //
105 105 // if no read is outstanding, then issue another one
106 106 //
107 107 if (!fWaitingOnRead) {
108   - if (!ReadFile(TTYInfo.hCommPort, lpBuf_first, AMOUNT_TO_READ, &dwRead, &osReader)) {
  108 + if (!ReadFile(g_appdata.hCommPort, lpBuf_first, AMOUNT_TO_READ, &dwRead, &osReader)) {
109 109 if (GetLastError() != ERROR_IO_PENDING) // read not delayed?
110 110 ErrorInComm("ReadFile in ReaderAndStatusProc");
111 111
112 112 fWaitingOnRead = TRUE;
113 113 }
114 114 else { // read completed immediately
115   - if ((dwRead != MAX_READ_BUFFER) && TTYInfo.fDisplayTimeouts)
  115 + if ((dwRead != MAX_READ_BUFFER) && g_appdata.fDisplayTimeouts)
116 116 UpdateStatus("Read timed out immediately.\r\n");
117 117
118 118 if (dwRead)
... ... @@ -127,9 +127,9 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
127 127 // This will cause a pending WaitCommEvent to complete
128 128 // and the resultant event flag will be NULL.
129 129 //
130   - if (dwStoredFlags != TTYInfo.dwEventFlags) {
131   - dwStoredFlags = TTYInfo.dwEventFlags;
132   - if (!SetCommMask(TTYInfo.hCommPort, dwStoredFlags))
  130 + if (dwStoredFlags != g_appdata.dwEventFlags) {
  131 + dwStoredFlags = g_appdata.dwEventFlags;
  132 + if (!SetCommMask(g_appdata.hCommPort, dwStoredFlags))
133 133 ErrorReporter("SetCommMask");
134 134 }
135 135
... ... @@ -137,16 +137,16 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
137 137 // If event checks are not allowed, then make it look
138 138 // like an event check operation is outstanding
139 139 //
140   - if (TTYInfo.fNoEvents)
  140 + if (g_appdata.fNoEvents)
141 141 fWaitingOnStat = TRUE;
142 142 //
143 143 // if no status check is outstanding, then issue another one
144 144 //
145 145 if (!fWaitingOnStat) {
146   - if (TTYInfo.fNoEvents)
  146 + if (g_appdata.fNoEvents)
147 147 fWaitingOnStat = TRUE;
148 148 else {
149   - if (!WaitCommEvent(TTYInfo.hCommPort, &dwCommEvent, &osStatus)) {
  149 + if (!WaitCommEvent(g_appdata.hCommPort, &dwCommEvent, &osStatus)) {
150 150 if (GetLastError() != ERROR_IO_PENDING) // Wait not delayed?
151 151 ErrorReporter("WaitCommEvent");
152 152 else
... ... @@ -169,14 +169,14 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
169 169 // read completed
170 170 //
171 171 case WAIT_OBJECT_0:
172   - if (!GetOverlappedResult(TTYInfo.hCommPort, &osReader, &dwRead, FALSE)) {
  172 + if (!GetOverlappedResult(g_appdata.hCommPort, &osReader, &dwRead, FALSE)) {
173 173 if (GetLastError() == ERROR_OPERATION_ABORTED)
174 174 UpdateStatus("Read aborted\r\n");
175 175 else
176 176 ErrorInComm("GetOverlappedResult (in Reader)");
177 177 }
178 178 else { // read completed successfully
179   - if ((dwRead != MAX_READ_BUFFER) && TTYInfo.fDisplayTimeouts)
  179 + if ((dwRead != MAX_READ_BUFFER) && g_appdata.fDisplayTimeouts)
180 180 UpdateStatus("Read timed out overlapped.\r\n");
181 181
182 182 if (dwRead)
... ... @@ -196,24 +196,24 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
196 196
197 197 if (strstr(lpBuf,"ROM boot"))
198 198 {
199   - if (GetTickCount() - TTYInfo.tickcountFinish <2000)
  199 + if (GetTickCount() - g_appdata.tickcountFinish <2000)
200 200 {// 在很短的时间内收到PCB板的下载信号, 视为PCB板自动复位, 而不是合上夹具
201 201 return;
202 202 }
203   - TTYInfo.rgbBGColor = RGB(255,255,255);
  203 + g_appdata.rgbBGColor = RGB(255,255,255);
204 204 OutputABuffer(hTTY, "进入下载模式\r\n", dwRead);
205 205
206   - TTYInfo.DownloadReday = TRUE;
207   - if (strlen(TTYInfo.szFileName) != 0)
208   - TransferFileTextStart(TTYInfo.szFileName);
  206 + g_appdata.DownloadReday = TRUE;
  207 + if (strlen(g_appdata.szFileName) != 0)
  208 + TransferFileTextStart(g_appdata.szFileName);
209 209 }
210 210 //
211 211 else if (strstr(lpBuf,"Verify successful"))
212 212 {
213   - TTYInfo.tickcountFinish = GetTickCount();
214   - TTYInfo.rgbBGColor = RGB(50,255,50);
  213 + g_appdata.tickcountFinish = GetTickCount();
  214 + g_appdata.rgbBGColor = RGB(50,255,50);
215 215 OutputABuffer(hTTY, "下载完成\r\n", dwRead);
216   - TTYInfo.DownloadReday = FALSE;
  216 + g_appdata.DownloadReday = FALSE;
217 217 }
218 218 else if (strstr(lpBuf,"Programming:"))
219 219 {
... ... @@ -221,29 +221,29 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
221 221 char ascbufpercent[64];
222 222 if(pchar_percent != NULL)
223 223 {
224   - TTYInfo.tickcountFinish = GetTickCount();
225   - TTYInfo.rgbBGColor = RGB(255,255,255);
  224 + g_appdata.tickcountFinish = GetTickCount();
  225 + g_appdata.rgbBGColor = RGB(255,255,255);
226 226 memset(ascbufpercent,0,64);
227 227 strncpy(ascbufpercent,pchar_percent+12,2);
228 228 Flashed_percent = atoi(ascbufpercent);
229 229 sprintf(ascbufpercent,"下载已完成%d\r\n",Flashed_percent);
230 230 OutputABuffer(hTTY, ascbufpercent, dwRead);
231   - TTYInfo.DownloadReday = FALSE;
  231 + g_appdata.DownloadReday = FALSE;
232 232 }
233 233 }
234 234 else if (strstr(lpBuf,"Verify fail"))
235 235 {
236   - //TTYInfo.tickcountFinish = GetTickCount();
237   - TTYInfo.rgbBGColor = RGB(255,50,50);
  236 + //g_appdata.tickcountFinish = GetTickCount();
  237 + g_appdata.rgbBGColor = RGB(255,50,50);
238 238 OutputABuffer(hTTY, "下载失败\r\n", dwRead);
239 239
240   - TTYInfo.DownloadReday = FALSE;
  240 + g_appdata.DownloadReday = FALSE;
241 241 }
242 242 else
243 243 {
244   - TTYInfo.rgbBGColor = RGB(255,255,255);
  244 + g_appdata.rgbBGColor = RGB(255,255,255);
245 245 OutputABuffer(hTTY, lpBuf, dwRead);
246   - TTYInfo.DownloadReday = FALSE;
  246 + g_appdata.DownloadReday = FALSE;
247 247 }
248 248
249 249
... ... @@ -257,7 +257,7 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
257 257 // status completed
258 258 //
259 259 case WAIT_OBJECT_0 + 1:
260   - if (!GetOverlappedResult(TTYInfo.hCommPort, &osStatus, &dwOvRes, FALSE)) {
  260 + if (!GetOverlappedResult(g_appdata.hCommPort, &osStatus, &dwOvRes, FALSE)) {
261 261 if (GetLastError() == ERROR_OPERATION_ABORTED)
262 262 UpdateStatus("WaitCommEvent aborted\r\n");
263 263 else
... ... @@ -293,7 +293,7 @@ DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
293 293 // if status checks are not allowed, then don't issue the
294 294 // modem status check nor the com stat check
295 295 //
296   - if (!TTYInfo.fNoStatus) {
  296 + if (!g_appdata.fNoStatus) {
297 297 CheckModemStatus(FALSE); // take this opportunity to do
298 298 CheckComStat(FALSE); // a modem status check and
299 299 // a comm status check
... ...
... ... @@ -89,26 +89,14 @@ DWORD BaudTable[] = {
89 89 } ;
90 90
91 91 char * szParity[] = { "None", "Even", "Odd", "Mark", "Space" };
92   -
93 92 DWORD ParityTable[] = { NOPARITY, EVENPARITY, ODDPARITY, MARKPARITY, SPACEPARITY } ;
94   -
95 93 char * szStopBits[] = { "1", "1.5", "2" };
96   -
97 94 DWORD StopBitsTable[] = { ONESTOPBIT, ONE5STOPBITS, TWOSTOPBITS } ;
98   -
99 95 char * szDTRControlStrings[] = { "Enable", "Disable", "Handshake" };
100   -
101 96 DWORD DTRControlTable[] = { DTR_CONTROL_ENABLE, DTR_CONTROL_DISABLE, DTR_CONTROL_HANDSHAKE };
102   -
103 97 char * szRTSControlStrings[] = { "Enable", "Disable", "Handshake", "Toggle" };
104   -
105   -DWORD RTSControlTable[] = { RTS_CONTROL_ENABLE, RTS_CONTROL_DISABLE,
106   - RTS_CONTROL_HANDSHAKE, RTS_CONTROL_TOGGLE };
107   -
108   -DWORD EventFlagsTable[] = {
109   - EV_BREAK, EV_CTS, EV_DSR, EV_ERR, EV_RING,
110   - EV_RLSD, EV_RXCHAR, EV_RXFLAG, EV_TXEMPTY
111   - };
  98 +DWORD RTSControlTable[] = { RTS_CONTROL_ENABLE, RTS_CONTROL_DISABLE, RTS_CONTROL_HANDSHAKE, RTS_CONTROL_TOGGLE };
  99 +DWORD EventFlagsTable[] = { EV_BREAK, EV_CTS, EV_DSR, EV_ERR, EV_RING, EV_RLSD, EV_RXCHAR, EV_RXFLAG, EV_TXEMPTY };
112 100
113 101 /*-----------------------------------------------------------------------------
114 102
... ... @@ -173,8 +161,6 @@ void ChangeConnection( HWND hwnd, BOOL fConnected )
173 161 MF_ENABLED | MF_BYCOMMAND ) ;
174 162 EnableMenuItem( hMenu, ID_TRANSFER_SENDREPEATEDLY,
175 163 MF_ENABLED | MF_BYCOMMAND ) ;
176   - EnableMenuItem( hMenu, ID_TRANSFER_ABORTSENDING,
177   - MF_DISABLED | MF_GRAYED | MF_BYCOMMAND );
178 164 EnableMenuItem( hMenu, ID_TRANSFER_ABORTREPEATEDSENDING,
179 165 MF_DISABLED | MF_GRAYED | MF_BYCOMMAND );
180 166
... ... @@ -190,7 +176,6 @@ void ChangeConnection( HWND hwnd, BOOL fConnected )
190 176 EnableMenuItem( hMenu, ID_TRANSFER_SENDFILETEXT,MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
191 177 EnableMenuItem( hMenu, ID_TRANSFER_RECEIVEFILETEXT,MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
192 178 EnableMenuItem( hMenu, ID_TRANSFER_SENDREPEATEDLY,MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
193   - EnableMenuItem( hMenu, ID_TRANSFER_ABORTSENDING,MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
194 179 EnableMenuItem( hMenu, ID_TRANSFER_ABORTREPEATEDSENDING,MF_DISABLED | MF_GRAYED | MF_BYCOMMAND );
195 180 EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_PORTCOMBO), TRUE);
196 181 SetFocus(ghwndMain);
... ... @@ -217,7 +202,7 @@ HISTORY: Date: Author: Comment:
217 202 void UpdateTTYInfo()
218 203 {
219 204 GetDlgItemText(ghWndToolbarDlg, IDC_PORTCOMBO, gszPort, sizeof(gszPort));
220   - if (TTYInfo.fConnected) // if connected, then update port state
  205 + if (g_appdata.fConnected) // if connected, then update port state
221 206 UpdateConnection();
222 207 return;
223 208 }
... ... @@ -243,41 +228,41 @@ BOOL UpdateConnection()
243 228 //
244 229 // get current DCB settings
245 230 //
246   - if (!GetCommState(TTYInfo.hCommPort, &dcb))
  231 + if (!GetCommState(g_appdata.hCommPort, &dcb))
247 232 ErrorReporter("GetCommState");
248 233
249 234 //
250 235 // update DCB rate, byte size, parity, and stop bits size
251 236 //
252   - dcb.BaudRate = TTYInfo.dwBaudRate;
253   - dcb.ByteSize = TTYInfo.bByteSize;
254   - dcb.Parity = TTYInfo.bParity;
255   - dcb.StopBits = TTYInfo.bStopBits;
  237 + dcb.BaudRate = g_appdata.dwBaudRate;
  238 + dcb.ByteSize = g_appdata.bByteSize;
  239 + dcb.Parity = g_appdata.bParity;
  240 + dcb.StopBits = g_appdata.bStopBits;
256 241
257 242 //
258 243 // update event flags
259 244 //
260   - if (TTYInfo.dwEventFlags & EV_RXFLAG)
261   - dcb.EvtChar = TTYInfo.chFlag;
  245 + if (g_appdata.dwEventFlags & EV_RXFLAG)
  246 + dcb.EvtChar = g_appdata.chFlag;
262 247 else
263 248 dcb.EvtChar = '\0';
264 249
265 250 //
266 251 // update flow control settings
267 252 //
268   - dcb.fDtrControl = TTYInfo.fDtrControl;
269   - dcb.fRtsControl = TTYInfo.fRtsControl;
270   -
271   - dcb.fOutxCtsFlow = TTYInfo.fCTSOutFlow;
272   - dcb.fOutxDsrFlow = TTYInfo.fDSROutFlow;
273   - dcb.fDsrSensitivity = TTYInfo.fDSRInFlow;
274   - dcb.fOutX = TTYInfo.fXonXoffOutFlow;
275   - dcb.fInX = TTYInfo.fXonXoffInFlow;
276   - dcb.fTXContinueOnXoff = TTYInfo.fTXafterXoffSent;
277   - dcb.XonChar = TTYInfo.chXON;
278   - dcb.XoffChar = TTYInfo.chXOFF;
279   - dcb.XonLim = TTYInfo.wXONLimit;
280   - dcb.XoffLim = TTYInfo.wXOFFLimit;
  253 + dcb.fDtrControl = g_appdata.fDtrControl;
  254 + dcb.fRtsControl = g_appdata.fRtsControl;
  255 +
  256 + dcb.fOutxCtsFlow = g_appdata.fCTSOutFlow;
  257 + dcb.fOutxDsrFlow = g_appdata.fDSROutFlow;
  258 + dcb.fDsrSensitivity = g_appdata.fDSRInFlow;
  259 + dcb.fOutX = g_appdata.fXonXoffOutFlow;
  260 + dcb.fInX = g_appdata.fXonXoffInFlow;
  261 + dcb.fTXContinueOnXoff = g_appdata.fTXafterXoffSent;
  262 + dcb.XonChar = g_appdata.chXON;
  263 + dcb.XoffChar = g_appdata.chXOFF;
  264 + dcb.XonLim = g_appdata.wXONLimit;
  265 + dcb.XoffLim = g_appdata.wXOFFLimit;
281 266
282 267 //
283 268 // DCB settings not in the user's control
... ... @@ -287,13 +272,13 @@ BOOL UpdateConnection()
287 272 //
288 273 // set new state
289 274 //
290   - if (!SetCommState(TTYInfo.hCommPort, &dcb))
  275 + if (!SetCommState(g_appdata.hCommPort, &dcb))
291 276 ErrorReporter("SetCommState");
292 277
293 278 //
294 279 // set new timeouts
295 280 //
296   - if (!SetCommTimeouts(TTYInfo.hCommPort, &(TTYInfo.timeoutsnew)))
  281 + if (!SetCommTimeouts(g_appdata.hCommPort, &(g_appdata.timeoutsnew)))
297 282 ErrorReporter("SetCommTimeouts");
298 283
299 284 return TRUE;
... ... @@ -405,15 +390,15 @@ BOOL SettingsDlgInit( HWND hDlg )
405 390 //
406 391 for (wCount = 0; wCount < 255; wCount++)
407 392 {
408   - if (TTYInfo.unOpenedPortAry[wCount] == 0)
  393 + if (g_appdata.unOpenedPortAry[wCount] == 0)
409 394 continue;;
410   - wsprintf( szBuffer, "%s%d", (LPSTR) szTemp, TTYInfo.unOpenedPortAry[wCount] ) ;
  395 + wsprintf( szBuffer, "%s%d", (LPSTR) szTemp, g_appdata.unOpenedPortAry[wCount] ) ;
411 396 SendDlgItemMessage( hDlg, IDC_PORTCOMBO, CB_ADDSTRING, 0,
412 397 (LPARAM) (LPSTR) szBuffer ) ;
413 398 }
414 399
415 400 SendDlgItemMessage( hDlg, IDC_PORTCOMBO, CB_SETCURSEL,
416   - (WPARAM) (TTYInfo.bPort - 1), 0L ) ;
  401 + (WPARAM) (g_appdata.bPort - 1), 0L ) ;
417 402
418 403 GetDlgItemText(hDlg, IDC_PORTCOMBO, gszPort, sizeof(gszPort));
419 404
... ... @@ -426,13 +411,13 @@ BOOL SettingsDlgInit( HWND hDlg )
426 411 //wsprintf( szBuffer, "%d", wCount ) ;
427 412 //wPosition = LOWORD( SendDlgItemMessage( hDlg, IDC_DATABITSCOMBO,CB_ADDSTRING, 0,(LPARAM) (LPSTR) szBuffer ) ) ;
428 413 // if wCount is current selection, tell the combo box
429   - //if (wCount == TTYInfo.bByteSize)SendDlgItemMessage( hDlg, IDC_DATABITSCOMBO, CB_SETCURSEL,(WPARAM) wPosition, 0L ) ;
  414 + //if (wCount == g_appdata.bByteSize)SendDlgItemMessage( hDlg, IDC_DATABITSCOMBO, CB_SETCURSEL,(WPARAM) wPosition, 0L ) ;
430 415 }
431 416
432 417 // fill parity combo box and make initial selection
433   - //FillComboBox( GetDlgItem( hDlg, IDC_PARITYCOMBO ),szParity, ParityTable,sizeof( ParityTable ) / sizeof( ParityTable[ 0 ] ),TTYInfo.bParity ) ;
  418 + //FillComboBox( GetDlgItem( hDlg, IDC_PARITYCOMBO ),szParity, ParityTable,sizeof( ParityTable ) / sizeof( ParityTable[ 0 ] ),g_appdata.bParity ) ;
434 419 // fill stop bits combo box and make initial selection
435   - //FillComboBox( GetDlgItem( hDlg, IDC_STOPBITSCOMBO ),szStopBits, StopBitsTable,sizeof( StopBitsTable ) / sizeof ( StopBitsTable[ 0 ] ),TTYInfo.bStopBits ) ;
  420 + //FillComboBox( GetDlgItem( hDlg, IDC_STOPBITSCOMBO ),szStopBits, StopBitsTable,sizeof( StopBitsTable ) / sizeof ( StopBitsTable[ 0 ] ),g_appdata.bStopBits ) ;
436 421
437 422 return ( TRUE ) ;
438 423
... ... @@ -564,7 +549,7 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
564 549 {
565 550 case IDC_BUTTON2_SEC_BINFILE:
566 551 {
567   - if (strlen(TTYInfo.szFileName) == 0)
  552 + if (strlen(g_appdata.szFileName) == 0)
568 553 {
569 554 char * szFilter = "Text Files\0*.*\0";
570 555 OPENFILENAME ofn = {0};
... ... @@ -578,11 +563,11 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
578 563
579 564 if (!GetOpenFileName(&ofn))
580 565 break;
581   - strcpy(TTYInfo.szFileName,szFileName);
  566 + strcpy(g_appdata.szFileName,szFileName);
582 567 SetWindowText(GetDlgItem(hWndDlg, IDC_BUTTON2_SEC_BINFILE), "下载软件");
583 568
584 569 }
585   - if (TTYInfo.DownloadReday == FALSE)
  570 + if (g_appdata.DownloadReday == FALSE)
586 571 {
587 572 MessageBox(ghwndMain, "请合上夹具", "提示!", MB_OK);
588 573 return;
... ... @@ -590,17 +575,17 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
590 575
591 576
592 577 if (TRUE)
593   - TransferFileTextStart(TTYInfo.szFileName);
  578 + TransferFileTextStart(g_appdata.szFileName);
594 579
595 580 }
596 581 break;
597 582 case IDC_BUTTON_CONNECT_UART: // font button pressed
598 583 {
599   - if (!TTYInfo.fConnected)
  584 + if (!g_appdata.fConnected)
600 585 {
601 586 if (SetupCommPort() != NULL)
602 587 {
603   - ChangeConnection(hWndDlg, TTYInfo.fConnected);
  588 + ChangeConnection(hWndDlg, g_appdata.fConnected);
604 589 SetWindowText(GetDlgItem(hWndDlg, IDC_BUTTON_CONNECT_UART), "断开夹具");
605 590 }
606 591 }
... ... @@ -608,7 +593,7 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
608 593 {
609 594 if (BreakDownCommPort())
610 595 {
611   - ChangeConnection(hWndDlg, TTYInfo.fConnected);
  596 + ChangeConnection(hWndDlg, g_appdata.fConnected);
612 597 SetWindowText(GetDlgItem(hWndDlg, IDC_BUTTON_CONNECT_UART), "连接夹具");
613 598 }
614 599
... ... @@ -621,11 +606,11 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
621 606 CHOOSEFONT cf = {0};
622 607 LOGFONT lf;
623 608
624   - lf = TTYInfo.lfTTYFont;
  609 + lf = g_appdata.lfTTYFont;
625 610 cf.lStructSize = sizeof(CHOOSEFONT);
626 611 cf.hwndOwner = hWndDlg;
627 612 cf.lpLogFont = &lf;
628   - cf.rgbColors = TTYInfo.rgbFGColor;
  613 + cf.rgbColors = g_appdata.rgbFGColor;
629 614 cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_FIXEDPITCHONLY | \
630 615 CF_EFFECTS;
631 616
... ... @@ -638,7 +623,7 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
638 623 // fix scroll bar sizes since we may have more or less pixels per
639 624 // character now
640 625 //
641   - SizeTTY(ghWndTTY, (WORD)TTYInfo.xSize, (WORD)TTYInfo.ySize);
  626 + SizeTTY(ghWndTTY, (WORD)g_appdata.xSize, (WORD)g_appdata.ySize);
642 627
643 628 //
644 629 // repaint screen contents
... ... @@ -674,7 +659,7 @@ BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
674 659 break;
675 660
676 661 default: // some other control has been modified
677   - if (TTYInfo.fConnected)
  662 + if (g_appdata.fConnected)
678 663 UpdateTTYInfo();
679 664 break;
680 665 }
... ...
... ... @@ -124,27 +124,39 @@ BOOL CALLBACK StatusDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
124 124 switch(uMsg)
125 125 {
126 126 case WM_INITDIALOG: // setup dialog with defaults
  127 + InitStatusWindow(hWndDlg,0,0);
127 128 SendMessage(GetDlgItem(hWndDlg, IDC_STATUSEDIT), WM_SETFONT, (WPARAM)ghFontStatus, 0);
128 129 InitStatusMessage();
129 130 break;
130   -
131 131 case WM_COMMAND:
132 132 {
133 133 switch(LOWORD(wParam))
134 134 {
135 135 case IDC_ABORTBTN:
136   - SendMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, MAKELPARAM(IDC_ABORTBTN,0) );
  136 + // am I in a transfer repeat?
  137 + if (g_appdata.fRepeating) TransferRepeatDestroy();
  138 + // am I in a normal recieve state, then stop sending
  139 + else if (gdwReceiveState == RECEIVE_TTY)
  140 + TransferFileTextEnd();
  141 + // if I am not in a normal receive state, then stop capturing
  142 + else
  143 + gfAbortTransfer = TRUE;
137 144 fRet = TRUE;
138 145 break;
139   -
140 146 //CheckModemStatus(TRUE);
141 147 //fRet = TRUE;
142 148 //break;
143   -
144 149 default:
145 150 break;
146 151 }
147 152 }
  153 + case WM_SIZE:
  154 + {
  155 + DWORD Statuswidth = LOWORD(lParam);
  156 + WORD Statusheigh = HIWORD(lParam);
  157 + ResizeStatusWindow(Statuswidth, Statusheigh);
  158 + //HWND hBtnAbortSend[50];
  159 + }
148 160 break;
149 161
150 162 default:
... ... @@ -394,7 +406,7 @@ void CheckModemStatus( BOOL bUpdateNow )
394 406
395 407 DWORD dwNewModemStatus;
396 408
397   - if (!GetCommModemStatus(TTYInfo.hCommPort, &dwNewModemStatus))
  409 + if (!GetCommModemStatus(g_appdata.hCommPort, &dwNewModemStatus))
398 410 ErrorReporter("GetCommModemStatus");
399 411
400 412 //
... ... @@ -455,7 +467,7 @@ void CheckComStat(BOOL bUpdateNow)
455 467
456 468 BOOL bReport = bUpdateNow;
457 469
458   - if (!ClearCommError(TTYInfo.hCommPort, &dwErrors, &ComStatNew))
  470 + if (!ClearCommError(g_appdata.hCommPort, &dwErrors, &ComStatNew))
459 471 ErrorReporter("ClearCommError");
460 472
461 473 if (dwErrors != dwErrorsOld) {
... ... @@ -501,7 +513,7 @@ void ReportCommError()
501 513 //
502 514 // Get and clear current errors on the port
503 515 //
504   - if (!ClearCommError(TTYInfo.hCommPort, &dwErrors, &comStat))
  516 + if (!ClearCommError(g_appdata.hCommPort, &dwErrors, &comStat))
505 517 ErrorReporter("ClearCommError");
506 518
507 519 //
... ... @@ -680,3 +692,50 @@ void ReportStatusEvent(DWORD dwStatus)
680 692
681 693 return;
682 694 }
  695 +BOOL InitStatusWindow(HWND hwnd,DWORD mainwidth, WORD mainheigh)
  696 +{
  697 + int loop1,loop2,index_ctrl;
  698 + for (loop1 = 0; loop1 < 2; loop1++)
  699 + {
  700 + for (loop2 = 0; loop2 < MAX_DEVICES_NUM; loop2++)
  701 + {
  702 + index_ctrl = loop1*MAX_DEVICES_NUM+loop2;
  703 + g_appdata.hBtnAbortSend[index_ctrl] = CreateWindow("button", "start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0,0,0,0, hwnd, (HMENU)IDC_ABORTBTN+index_ctrl, ghInst, NULL);
  704 + g_appdata.hprocessFlash[index_ctrl] = CreateWindow("msctls_progress32", "", WS_CHILD|WS_VISIBLE|WS_BORDER, 0,0,0,0, hwnd, (HMENU)IDC_TRANSFERPROGRESS+index_ctrl, ghInst, NULL);
  705 + }
  706 + }
  707 + return TRUE;
  708 +}
  709 +BOOL ResizeStatusWindow(DWORD Statuswidth, WORD Statusheigh)
  710 +{
  711 + int loop1,loop2,index_ctrl;
  712 + RECT rect_statusInfo;
  713 + RECT rect_btn,rect_process;
  714 + for (loop1 = 0; loop1 < 2; loop1++)
  715 + {
  716 + for (loop2 = 0; loop2 < MAX_DEVICES_NUM; loop2++)
  717 + {
  718 + index_ctrl = loop1*MAX_DEVICES_NUM+loop2;
  719 + rect_btn.left = 5+loop1*110;
  720 + rect_btn.top = 5+loop2*25;
  721 + rect_btn.right = rect_btn.left+30;
  722 + rect_btn.bottom = rect_btn.top+20;
  723 +
  724 + rect_process.left = rect_btn.right+5;
  725 + rect_process.top = rect_btn.top;
  726 + rect_process.right = rect_process.left+80;
  727 + rect_process.bottom = rect_btn.bottom;
  728 + MoveWindow(g_appdata.hBtnAbortSend[index_ctrl] , rect_btn.left, rect_btn.top,
  729 + rect_btn.right -rect_btn.left, rect_btn.bottom -rect_btn.top, TRUE);
  730 + MoveWindow(g_appdata.hprocessFlash[index_ctrl] , rect_process.left, rect_process.top,
  731 + rect_process.right -rect_process.left, rect_process.bottom -rect_process.top, TRUE);
  732 + }
  733 + }
  734 + rect_statusInfo.left = rect_process.right + 5;
  735 + rect_statusInfo.top = 0;
  736 + rect_statusInfo.right = Statuswidth;
  737 + rect_statusInfo.bottom = Statusheigh;
  738 + MoveWindow(GetDlgItem(ghWndStatusDlg, IDC_STATUSEDIT), rect_statusInfo.left, rect_statusInfo.top,
  739 + rect_statusInfo.right-rect_statusInfo.left, rect_statusInfo.bottom-rect_statusInfo.top, TRUE);
  740 + return TRUE;
  741 +}
... ...
... ... @@ -75,70 +75,61 @@ HISTORY: Date: Author: Comment:
75 75 -----------------------------------------------------------------------------*/
76 76 void TransferRepeatCreate(LPCTSTR lpszFileName, DWORD dwFrequency)
77 77 {
78   - HMENU hMenu;
79   - UINT MenuFlags ;
80   - DWORD dwFileSize;
81   - DWORD dwMaxPackets;
82   - DWORD dwPacketSize;
83   - DWORD dwRead;
84   -
85   - //
86   - // open the file
87   - //
88   - hFile = OpenTheFile(lpszFileName);
89   - if (hFile == INVALID_HANDLE_VALUE)
90   - return;
91   -
92   - //
93   - // modify transfer menu
94   - //
95   - hMenu = GetMenu(ghwndMain);
96   - MenuFlags = MF_DISABLED | MF_GRAYED;
97   - EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
98   - EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
99   - EnableMenuItem(hMenu, ID_TRANSFER_ABORTREPEATEDSENDING, MF_ENABLED);
100   - EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
101   -
102   - //
103   - // enable abort button and progress bar
104   - //
105   - SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "Abort Tx");
106   - ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_SHOW);
107   -
108   - if (!GetTransferSizes(hFile, &dwPacketSize, &dwMaxPackets, &dwFileSize)) {
109   - TransferRepeatDestroy();
110   - return;
111   - }
  78 + HMENU hMenu;
  79 + UINT MenuFlags;
  80 + DWORD dwFileSize;
  81 + DWORD dwMaxPackets;
  82 + DWORD dwPacketSize;
  83 + DWORD dwRead;
  84 +
  85 + // open the file
  86 + hFile = OpenTheFile(lpszFileName);
  87 + if (hFile == INVALID_HANDLE_VALUE)
  88 + return;
  89 + // modify transfer menu
  90 + hMenu = GetMenu(ghwndMain);
  91 + MenuFlags = MF_DISABLED | MF_GRAYED;
  92 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  93 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  94 + EnableMenuItem(hMenu, ID_TRANSFER_ABORTREPEATEDSENDING, MF_ENABLED);
  95 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  96 + // enable abort button and progress bar
  97 + SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "Abort Tx");
  98 + EnableWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), TRUE);
  99 + if (!GetTransferSizes(hFile, &dwPacketSize, &dwMaxPackets, &dwFileSize))
  100 + {
  101 + TransferRepeatDestroy();
  102 + return;
  103 + }
  104 + lpBuf = HeapAlloc(ghWriterHeap, 0, dwFileSize);
  105 + if (lpBuf == NULL)
  106 + {
  107 + ErrorReporter("HeapAlloc (data block from writer heap).\r\nFile is too large");
  108 + TransferRepeatDestroy();
  109 + return;
  110 + }
  111 + if (!ReadFile(hFile, lpBuf, dwFileSize, &dwRead, NULL))
  112 + {
  113 + ErrorReporter("Can't read from file\n");
  114 + TransferRepeatDestroy();
  115 + }
  116 + if (dwRead != dwFileSize)
  117 + ErrorReporter("Didn't read entire file\n");
  118 + mmTimer = timeSetEvent((UINT) dwFrequency, 10, TransferRepeatDo, dwRead, TIME_PERIODIC);
  119 + if (mmTimer == (MMRESULT) NULL)
  120 + {
  121 + ErrorReporter("Could not create mm timer");
  122 + TransferRepeatDestroy();
  123 + }
  124 + else
  125 + {
  126 + g_appdata.fRepeating = TRUE;
  127 + OutputDebugString("Timer setup.\n");
  128 + }
  129 + return;
  130 +}
112 131
113   - // Allocate a buffer
114   - lpBuf = HeapAlloc(ghWriterHeap, 0, dwFileSize);
115   - if (lpBuf == NULL) {
116   - ErrorReporter("HeapAlloc (data block from writer heap).\r\nFile is too large");
117   - TransferRepeatDestroy();
118   - return;
119   - }
120 132
121   - // fill the buffer
122   - if (!ReadFile(hFile, lpBuf, dwFileSize, &dwRead, NULL)) {
123   - ErrorReporter("Can't read from file\n");
124   - TransferRepeatDestroy();
125   - }
126   -
127   - if (dwRead != dwFileSize)
128   - ErrorReporter("Didn't read entire file\n");
129   -
130   - mmTimer = timeSetEvent((UINT) dwFrequency, 10, TransferRepeatDo, dwRead, TIME_PERIODIC);
131   - if (mmTimer == (MMRESULT) NULL) {
132   - ErrorReporter("Could not create mm timer");
133   - TransferRepeatDestroy();
134   - }
135   - else {
136   - TTYInfo.fRepeating = TRUE;
137   - OutputDebugString("Timer setup.\n");
138   - }
139   -
140   - return;
141   -}
142 133
143 134 /*-----------------------------------------------------------------------------
144 135
... ... @@ -176,7 +167,7 @@ void TransferRepeatDestroy()
176 167 if (!HeapFree(ghWriterHeap, 0, lpBuf))
177 168 ErrorReporter("HeapFree (data block from writer heap)");
178 169
179   - TTYInfo.fRepeating = FALSE;
  170 + g_appdata.fRepeating = FALSE;
180 171 OutputDebugString("Repeated transfer destroyed.\r\n");
181 172
182 173 //
... ... @@ -188,8 +179,7 @@ void TransferRepeatDestroy()
188 179 EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
189 180 EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
190 181 EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
191   -
192   - ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_HIDE);
  182 + EnableWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), FALSE);
193 183
194 184 return;
195 185 }
... ... @@ -214,8 +204,7 @@ void CALLBACK TransferRepeatDo( UINT uTimerId,
214 204 DWORD dwRes2)
215 205 {
216 206 if (!WriterAddNewNodeTimeout(WRITE_BLOCK, dwFileSize, 0, lpBuf, 0, 0, 10))
217   - PostMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, MAKELPARAM(IDC_ABORTBTN, 0) );
218   -
  207 + PostMessage(ghWndStatusDlg, WM_COMMAND, IDC_ABORTBTN,0);
219 208 return;
220 209 }
221 210
... ... @@ -254,7 +243,6 @@ void TransferFileTextStart(LPCTSTR lpstrFileName)
254 243 MenuFlags = MF_DISABLED | MF_GRAYED;
255 244 EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
256 245 EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
257   - EnableMenuItem(hMenu, ID_TRANSFER_ABORTSENDING, MF_ENABLED);
258 246 EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
259 247
260 248 //
... ... @@ -262,7 +250,7 @@ void TransferFileTextStart(LPCTSTR lpstrFileName)
262 250 //
263 251 gfAbortTransfer = FALSE;
264 252 SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "停止下载");
265   - ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_SHOW);
  253 + EnableWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), TRUE);
266 254 ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_SHOW);
267 255
268 256 // start the transfer thread
... ... @@ -279,7 +267,7 @@ void TransferFileTextStart(LPCTSTR lpstrFileName)
279 267 TransferFileTextEnd();
280 268 }
281 269 else
282   - TTYInfo.fTransferring = TRUE;
  270 + g_appdata.fTransferring = TRUE;
283 271
284 272 return;
285 273 }
... ... @@ -316,7 +304,7 @@ void TransferFileTextEnd()
316 304 CloseHandle(hTransferAbortEvent);
317 305 CloseHandle(hTransferThread);
318 306
319   - TTYInfo.fTransferring = FALSE;
  307 + g_appdata.fTransferring = FALSE;
320 308
321 309 //
322 310 // enable transfer menu
... ... @@ -326,12 +314,11 @@ void TransferFileTextEnd()
326 314 EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
327 315 EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
328 316 EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
329   - EnableMenuItem(hMenu, ID_TRANSFER_ABORTSENDING, MF_DISABLED | MF_GRAYED);
330 317
331 318 //
332 319 // disable abort button and progress bar
333 320 //
334   - ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_HIDE);
  321 + EnableWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), FALSE);
335 322 ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_HIDE);
336 323
337 324 //
... ... @@ -389,7 +376,7 @@ void ReceiveFileText(LPCTSTR lpstrFileName)
389 376 //
390 377 gfAbortTransfer = FALSE;
391 378 SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "Close Capture");
392   - ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_SHOW);
  379 + EnableWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), TRUE);
393 380 ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_SHOW);
394 381
395 382 //
... ... @@ -402,7 +389,7 @@ void ReceiveFileText(LPCTSTR lpstrFileName)
402 389 //
403 390 hMenu = GetMenu(ghwndMain);
404 391 MenuFlags = MF_ENABLED;
405   - ChangeConnection(ghwndMain, TTYInfo.fConnected);
  392 + ChangeConnection(ghwndMain, g_appdata.fConnected);
406 393
407 394 //
408 395 // enable transfer menu
... ... @@ -414,7 +401,7 @@ void ReceiveFileText(LPCTSTR lpstrFileName)
414 401 //
415 402 // hide abort button and progress bar
416 403 //
417   - ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_HIDE);
  404 + EnableWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), FALSE);
418 405 ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_HIDE);
419 406
420 407 gfAbortTransfer = FALSE;
... ... @@ -841,8 +828,7 @@ DWORD WINAPI TransferThreadProc(LPVOID lpV)
841 828 // If I am done without user intervention, then post the
842 829 // "abort" message myself. This will cause the main thread to
843 830 // clean up after the file transfer.
844   - if (!fAborting)
845   - PostMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, 0);
  831 + //if (!fAborting) PostMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, 0);
846 832
847 833 // exit thread
848 834
... ...
... ... @@ -48,6 +48,9 @@
48 48 //
49 49 // data structures
50 50 //
  51 +
  52 +#define MAX_DEVICES_NUM 25
  53 +
51 54 struct TTYInfoStruct
52 55 {
53 56 HANDLE hCommPort, hReaderStatus, hWriter ;
... ... @@ -80,68 +83,70 @@ struct TTYInfoStruct
80 83 BYTE unOpenedPortAry[255];
81 84 BOOL DownloadReday;
82 85 DWORD tickcountFinish; //Íê³ÉÏÂÔØµÄʱ¼ä
  86 + HWND hBtnAbortSend[50];
  87 + HWND hprocessFlash[50];
83 88
84 89
85   -} TTYInfo;
  90 +} g_appdata;
86 91
87 92 //
88 93 // macros ( for easier readability )
89 94 //
90   -//#define COMDEV(TTYInfo) (TTYInfo.hCommPort)
91   -//#define CURSORSTATE(TTYInfo) (TTYInfo.wCursorState)
92   -//#define PORT(TTYInfo) (TTYInfo.bPort)
93   -//#define TTYInfo.Screen (TTYInfo.Screen)
94   -//#define CONNECTED(TTYInfo) (TTYInfo.fConnected)
95   -//#define TTYInfo.fTransferring (TTYInfo.fTransferring)
96   -//#define TTYInfo.fRepeating (TTYInfo.fRepeating)
97   -//#define TTYInfo.fLocalEcho (TTYInfo.fLocalEcho)
98   -//#define TTYInfo.fNewLine (TTYInfo.fNewLine)
99   -//#define TTYInfo.fAutowrap TTYInfo.fAutowrap
100   -//#define TTYInfo.bByteSize TTYInfo.bByteSize
101   -//#define TTYInfo.bParity TTYInfo.bParity
102   -//#define TTYInfo.bStopBits TTYInfo.bStopBits
103   -//#define TTYInfo.dwBaudRate TTYInfo.dwBaudRate
104   -//#define TTYInfo.hTTYFont TTYInfo.hTTYFont
105   -//#define TTYInfo.lfTTYFont TTYInfo.lfTTYFont
106   -//#define TTYInfo.rgbFGColor TTYInfo.rgbFGColor
107   -//#define TTYInfo.rgbBGColor TTYInfo.rgbBGColor
108   -//#define TTYInfo.xSize TTYInfo.xSize
109   -//#define TTYInfo.ySize TTYInfo.ySize
110   -//#define TTYInfo.xScroll TTYInfo.xScroll
111   -//#define TTYInfo.yScroll TTYInfo.yScroll
112   -//#define TTYInfo.xOffset TTYInfo.xOffset
113   -//#define TTYInfo.yOffset TTYInfo.yOffset
114   -//#define TTYInfo.nColumn TTYInfo.nColumn
115   -//#define TTYInfo.nRow TTYInfo.nRow
116   -//#define TTYInfo.xChar TTYInfo.xChar
117   -//#define TTYInfo.yChar TTYInfo.yChar
118   -//#define TTYInfo.fDisplayErrors TTYInfo.fDisplayErrors
119   -//#define TTYInfo.timeoutsorig TTYInfo.timeoutsorig
120   -//#define TTYInfo.timeoutsnew TTYInfo.timeoutsnew
121   -//#define TTYInfo.hWriter TTYInfo.hWriter
122   -//#define TTYInfo.hReaderStatus TTYInfo.hReaderStatus
123   -//#define TTYInfo.dwEventFlags TTYInfo.dwEventFlags
124   -//#define TTYInfo.chFlag TTYInfo.chFlag
125   -//#define SCREENCHAR( x, col, row ) TTYInfo.Screen[row * MAXCOLS + col]
126   -
127   -//#define TTYInfo.fDtrControl TTYInfo.fDtrControl
128   -//#define TTYInfo.fRtsControl TTYInfo.fRtsControl
129   -//#define TTYInfo.chXON TTYInfo.chXON
130   -//#define TTYInfo.chXOFF TTYInfo.chXOFF
131   -//#define TTYInfo.wXONLimit TTYInfo.wXONLimit
132   -//#define TTYInfo.wXOFFLimit TTYInfo.wXOFFLimit
133   -//#define TTYInfo.fCTSOutFlow TTYInfo.fCTSOutFlow
134   -//#define TTYInfo.fDSROutFlow TTYInfo.fDSROutFlow
135   -//#define TTYInfo.fDSRInFlow TTYInfo.fDSRInFlow
136   -//#define TTYInfo.fXonXoffOutFlow TTYInfo.fXonXoffOutFlow
137   -//#define TTYInfo.fXonXoffInFlow TTYInfo.fXonXoffInFlow
138   -//#define TTYInfo.fTXafterXoffSent TTYInfo.fTXafterXoffSent
  95 +//#define COMDEV(g_appdata) (g_appdata.hCommPort)
  96 +//#define CURSORSTATE(g_appdata) (g_appdata.wCursorState)
  97 +//#define PORT(g_appdata) (g_appdata.bPort)
  98 +//#define g_appdata.Screen (g_appdata.Screen)
  99 +//#define CONNECTED(g_appdata) (g_appdata.fConnected)
  100 +//#define g_appdata.fTransferring (g_appdata.fTransferring)
  101 +//#define g_appdata.fRepeating (g_appdata.fRepeating)
  102 +//#define g_appdata.fLocalEcho (g_appdata.fLocalEcho)
  103 +//#define g_appdata.fNewLine (g_appdata.fNewLine)
  104 +//#define g_appdata.fAutowrap g_appdata.fAutowrap
  105 +//#define g_appdata.bByteSize g_appdata.bByteSize
  106 +//#define g_appdata.bParity g_appdata.bParity
  107 +//#define g_appdata.bStopBits g_appdata.bStopBits
  108 +//#define g_appdata.dwBaudRate g_appdata.dwBaudRate
  109 +//#define g_appdata.hTTYFont g_appdata.hTTYFont
  110 +//#define g_appdata.lfTTYFont g_appdata.lfTTYFont
  111 +//#define g_appdata.rgbFGColor g_appdata.rgbFGColor
  112 +//#define g_appdata.rgbBGColor g_appdata.rgbBGColor
  113 +//#define g_appdata.xSize g_appdata.xSize
  114 +//#define g_appdata.ySize g_appdata.ySize
  115 +//#define g_appdata.xScroll g_appdata.xScroll
  116 +//#define g_appdata.yScroll g_appdata.yScroll
  117 +//#define g_appdata.xOffset g_appdata.xOffset
  118 +//#define g_appdata.yOffset g_appdata.yOffset
  119 +//#define g_appdata.nColumn g_appdata.nColumn
  120 +//#define g_appdata.nRow g_appdata.nRow
  121 +//#define g_appdata.xChar g_appdata.xChar
  122 +//#define g_appdata.yChar g_appdata.yChar
  123 +//#define g_appdata.fDisplayErrors g_appdata.fDisplayErrors
  124 +//#define g_appdata.timeoutsorig g_appdata.timeoutsorig
  125 +//#define g_appdata.timeoutsnew g_appdata.timeoutsnew
  126 +//#define g_appdata.hWriter g_appdata.hWriter
  127 +//#define g_appdata.hReaderStatus g_appdata.hReaderStatus
  128 +//#define g_appdata.dwEventFlags g_appdata.dwEventFlags
  129 +//#define g_appdata.chFlag g_appdata.chFlag
  130 +//#define SCREENCHAR( x, col, row ) g_appdata.Screen[row * MAXCOLS + col]
  131 +
  132 +//#define g_appdata.fDtrControl g_appdata.fDtrControl
  133 +//#define g_appdata.fRtsControl g_appdata.fRtsControl
  134 +//#define g_appdata.chXON g_appdata.chXON
  135 +//#define g_appdata.chXOFF g_appdata.chXOFF
  136 +//#define g_appdata.wXONLimit g_appdata.wXONLimit
  137 +//#define g_appdata.wXOFFLimit g_appdata.wXOFFLimit
  138 +//#define g_appdata.fCTSOutFlow g_appdata.fCTSOutFlow
  139 +//#define g_appdata.fDSROutFlow g_appdata.fDSROutFlow
  140 +//#define g_appdata.fDSRInFlow g_appdata.fDSRInFlow
  141 +//#define g_appdata.fXonXoffOutFlow g_appdata.fXonXoffOutFlow
  142 +//#define g_appdata.fXonXoffInFlow g_appdata.fXonXoffInFlow
  143 +//#define g_appdata.fTXafterXoffSent g_appdata.fTXafterXoffSent
139 144 //
140   -//#define TTYInfo.fNoReading TTYInfo.fNoReading
141   -//#define TTYInfo.fNoWriting TTYInfo.fNoWriting
142   -//#define TTYInfo.fNoEvents TTYInfo.fNoEvents
143   -//#define TTYInfo.fNoStatus TTYInfo.fNoStatus
144   -//#define TTYInfo.fDisplayTimeouts TTYInfo.fDisplayTimeouts)
  145 +//#define g_appdata.fNoReading g_appdata.fNoReading
  146 +//#define g_appdata.fNoWriting g_appdata.fNoWriting
  147 +//#define g_appdata.fNoEvents g_appdata.fNoEvents
  148 +//#define g_appdata.fNoStatus g_appdata.fNoStatus
  149 +//#define g_appdata.fDisplayTimeouts g_appdata.fDisplayTimeouts)
145 150
146 151
147 152
... ...
... ... @@ -432,7 +432,7 @@ void WriterGeneric(char * lpBuf, DWORD dwToWrite)
432 432 //
433 433 // If no writing is allowed, then just return
434 434 //
435   - if (TTYInfo.fNoWriting)
  435 + if (g_appdata.fNoWriting)
436 436 return ;
437 437
438 438 //
... ... @@ -448,7 +448,7 @@ void WriterGeneric(char * lpBuf, DWORD dwToWrite)
448 448 //
449 449 // issue write
450 450 //
451   - if (!WriteFile(TTYInfo.hCommPort, lpBuf, dwToWrite, &dwWritten, &osWrite)) {
  451 + if (!WriteFile(g_appdata.hCommPort, lpBuf, dwToWrite, &dwWritten, &osWrite)) {
452 452 if (GetLastError() == ERROR_IO_PENDING) {
453 453 //
454 454 // write is delayed
... ... @@ -461,7 +461,7 @@ void WriterGeneric(char * lpBuf, DWORD dwToWrite)
461 461 //
462 462 case WAIT_OBJECT_0:
463 463 SetLastError(ERROR_SUCCESS);
464   - if (!GetOverlappedResult(TTYInfo.hCommPort, &osWrite, &dwWritten, FALSE)) {
  464 + if (!GetOverlappedResult(g_appdata.hCommPort, &osWrite, &dwWritten, FALSE)) {
465 465 if (GetLastError() == ERROR_OPERATION_ABORTED)
466 466 UpdateStatus("Write aborted\r\n");
467 467 else
... ... @@ -469,7 +469,7 @@ void WriterGeneric(char * lpBuf, DWORD dwToWrite)
469 469 }
470 470
471 471 if (dwWritten != dwToWrite) {
472   - if ((GetLastError() == ERROR_SUCCESS) && TTYInfo.fDisplayTimeouts)
  472 + if ((GetLastError() == ERROR_SUCCESS) && g_appdata.fDisplayTimeouts)
473 473 UpdateStatus("Write timed out. (overlapped)\r\n");
474 474 else
475 475 ErrorReporter("Error writing data to port (overlapped)");
... ...
... ... @@ -24,8 +24,6 @@
24 24 #define IDC_LOCALECHOCHK 1008
25 25 #define IDC_DISPLAYERRORSCHK 1009
26 26 #define IDC_FONTBTN 1010
27   -#define IDC_ABORTBTN 1011
28   -#define IDC_TRANSFERPROGRESS 1013
29 27 #define IDC_MODEMSTATUSGRP 1018
30 28 #define IDC_COMMEVENTSBTN 1019
31 29 #define IDC_LFBTN 1032
... ... @@ -52,6 +50,8 @@
52 50 #define IDC_BUTTON_CONNECT_UART 1085
53 51 #define IDC_BUTTON2 1086
54 52 #define IDC_BUTTON2_SEC_BINFILE 1086
  53 +#define IDC_ABORTBTN 1100
  54 +#define IDC_TRANSFERPROGRESS 1200
55 55 #define ID_FILE_EXIT 40001
56 56 #define ID_HELP_ABOUTMTTTY 40002
57 57 #define ID_FILE_CONNECT 40004
... ... @@ -60,7 +60,6 @@
60 60 #define ID_TRANSFER_SENDFILETEXT 40010
61 61 #define ID_TRANSFER_RECEIVEFILETEXT 40011
62 62 #define ID_TRANSFER_SENDREPEATEDLY 40012
63   -#define ID_TRANSFER_ABORTSENDING 40016
64 63 #define ID_TRANSFER_ABORTREPEATEDSENDING 40018
65 64 #define IDC_STATIC 65535
66 65
... ...
Please register or login to post a comment