[Ttssh2-commit] [4379] SCP の進捗ダイアログで、プログレスバーを表示するようにした。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 3月 9日 (水) 17:56:17 JST


Revision: 4379
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4379
Author:   doda
Date:     2011-03-09 17:56:17 +0900 (Wed, 09 Mar 2011)

Log Message:
-----------
SCP の進捗ダイアログで、プログレスバーを表示するようにした。

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/resource.h
    trunk/ttssh2/ttxssh/ssh.c
    trunk/ttssh2/ttxssh/ttxssh.rc


-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/resource.h
===================================================================
--- trunk/ttssh2/ttxssh/resource.h	2011-03-08 14:19:03 UTC (rev 4378)
+++ trunk/ttssh2/ttxssh/resource.h	2011-03-09 08:56:17 UTC (rev 4379)
@@ -158,6 +158,7 @@
 #define IDC_KEYBITS_LABEL               1105
 #define IDC_KEYBITS                     1106
 #define IDC_KEYGEN_PROGRESS_LABEL       1107
+#define IDC_PROGBAR                     1108
 #define IDC_SSHUSEPASSWORD              1201
 #define IDC_SSHUSERSA                   1202
 #define IDC_SSHFWDREMOTETOLOCAL         1202

Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2011-03-08 14:19:03 UTC (rev 4378)
+++ trunk/ttssh2/ttxssh/ssh.c	2011-03-09 08:56:17 UTC (rev 4379)
@@ -46,6 +46,7 @@
 #include <stdlib.h>
 #include <process.h>
 #include <time.h>
+#include <commctrl.h>
 #include "buffer.h"
 #include "ssh.h"
 #include "crypt.h"
@@ -7443,6 +7444,19 @@
 	return 0;
 }
 
+void InitDlgProgress(HWND HDlg, int id_Progress, int *CurProgStat) {
+	HWND HProg;
+	HProg = GetDlgItem(HDlg, id_Progress);
+
+	*CurProgStat = 0;
+
+	SendMessage(HProg, PBM_SETRANGE, (WPARAM)0, MAKELPARAM(0, 100));
+	SendMessage(HProg, PBM_SETSTEP, (WPARAM)1, 0);
+	SendMessage(HProg, PBM_SETPOS, (WPARAM)0, 0);
+
+	return;
+}
+
 static unsigned __stdcall ssh_scp_thread(void FAR * p)
 {
 	Channel_t *c = (Channel_t *)p;
@@ -7453,10 +7467,13 @@
 	size_t ret;
 	HWND hWnd = c->scp.progress_window;
 	scp_dlg_parm_t parm;
+	int rate, ProgStat;
 
 	//SendMessage(GetDlgItem(hWnd, IDC_FILENAME), WM_SETTEXT, 0, (LPARAM)c->scp.localfile);
 	SendMessage(GetDlgItem(hWnd, IDC_FILENAME), WM_SETTEXT, 0, (LPARAM)c->scp.localfilefull);
 
+	InitDlgProgress(hWnd, IDC_PROGBAR, &ProgStat);
+
 	do {
 		// Cancelƒ{ƒ^ƒ“‚ª‰Ÿ‰º‚³‚ꂽ‚çƒEƒBƒ“ƒhƒE‚ªÁ‚¦‚éB
 		if (is_canceled_window(hWnd))
@@ -7487,9 +7504,13 @@
 
 		total_size += ret;
 
-		_snprintf_s(s, sizeof(s), _TRUNCATE, "%lld / %lld (%d%%)", total_size, c->scp.filestat.st_size, 
-			(100 * total_size / c->scp.filestat.st_size)%100 );
+		rate = (int)(100 * total_size / c->scp.filestat.st_size);
+		_snprintf_s(s, sizeof(s), _TRUNCATE, "%lld / %lld (%d%%)", total_size, c->scp.filestat.st_size, rate);
 		SendMessage(GetDlgItem(hWnd, IDC_PROGRESS), WM_SETTEXT, 0, (LPARAM)s);
+		if (ProgStat != rate) {
+			ProgStat = rate;
+			SendDlgItemMessage(hWnd, IDC_PROGBAR, PBM_SETPOS, (WPARAM)ProgStat, 0);
+		}
 
 	} while (ret <= sizeof(buf));
 
@@ -7580,7 +7601,10 @@
 	unsigned char *data;
 	unsigned int buflen;
 	int eof;
+	int rate, ProgStat;
 
+	InitDlgProgress(hWnd, IDC_PROGBAR, &ProgStat);
+
 	for (;;) {
 		// Cancelƒ{ƒ^ƒ“‚ª‰Ÿ‰º‚³‚ꂽ‚çƒEƒBƒ“ƒhƒE‚ªÁ‚¦‚éB
 		if (is_canceled_window(hWnd))
@@ -7611,10 +7635,15 @@
 
 				free(data);  // free!
 
-				_snprintf_s(s, sizeof(s), _TRUNCATE, "%lld / %lld (%d%%)", c->scp.filercvsize, c->scp.filetotalsize, 
-					(100 * c->scp.filercvsize / c->scp.filetotalsize)%100 );
+				rate =(int)(100 * c->scp.filercvsize / c->scp.filetotalsize);
+				_snprintf_s(s, sizeof(s), _TRUNCATE, "%lld / %lld (%d%%)", c->scp.filercvsize, c->scp.filetotalsize, rate);
 				SendMessage(GetDlgItem(c->scp.progress_window, IDC_PROGRESS), WM_SETTEXT, 0, (LPARAM)s);
 
+				if (ProgStat != rate) {
+					ProgStat = rate;
+					SendDlgItemMessage(c->scp.progress_window, IDC_PROGBAR, PBM_SETPOS, (WPARAM)ProgStat, 0);
+				}
+
 				if (eof)
 					goto done;
 

Modified: trunk/ttssh2/ttxssh/ttxssh.rc
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.rc	2011-03-08 14:19:03 UTC (rev 4378)
+++ trunk/ttssh2/ttxssh/ttxssh.rc	2011-03-09 08:56:17 UTC (rev 4379)
@@ -335,15 +335,16 @@
     PUSHBUTTON      "&Receive",IDC_RECV,222,77,50,14
 END
 
-IDD_SSHSCP_PROGRESS DIALOGEX 0, 0, 166, 82
+IDD_SSHSCP_PROGRESS DIALOGEX 0, 0, 166, 100
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "TTSSH: SCP sending file"
 FONT 8, "Tahoma", 0, 0, 0x0
 BEGIN
-    PUSHBUTTON      "Cancel",IDCANCEL,39,52,73,14
+    PUSHBUTTON      "Cancel",IDCANCEL,43,68,73,14
     LTEXT           "0%",IDC_PROGRESS,7,29,141,10
     EDITTEXT        IDC_FILENAME,45,7,114,14,ES_AUTOHSCROLL | ES_READONLY
     LTEXT           "Filename:",IDC_FN_STATIC,7,7,32,8
+    CONTROL         "",IDC_PROGBAR,"msctls_progress32",WS_BORDER,7,48,152,14
 END
 
 IDD_SSHPASSWD_INPUT DIALOGEX 0, 0, 231, 95
@@ -486,7 +487,7 @@
         LEFTMARGIN, 7
         RIGHTMARGIN, 159
         TOPMARGIN, 7
-        BOTTOMMARGIN, 75
+        BOTTOMMARGIN, 93
     END
 
     IDD_SSHPASSWD_INPUT, DIALOG



Ttssh2-commit メーリングリストの案内
Back to archive index