summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rfb_win32/ProgressControl.cxx13
-rw-r--r--rfb_win32/ProgressControl.h6
-rw-r--r--vncviewer/FTProgress.cxx87
-rw-r--r--vncviewer/FTProgress.h20
-rw-r--r--vncviewer/resource.h4
-rw-r--r--vncviewer/vncviewer.rc32
6 files changed, 137 insertions, 25 deletions
diff --git a/rfb_win32/ProgressControl.cxx b/rfb_win32/ProgressControl.cxx
index dd6a79f9..1beced0d 100644
--- a/rfb_win32/ProgressControl.cxx
+++ b/rfb_win32/ProgressControl.cxx
@@ -45,7 +45,8 @@ ProgressControl::init(DWORD64 maxValue, DWORD64 position)
m_dw64CurrentValue = position;
m_dw64MaxValue = maxValue;
- SendMessage(m_hwndProgress, PBM_SETRANGE, (WPARAM) 0, MAKELPARAM(0, MAX_RANGE));
+ if (!SendMessage(m_hwndProgress, PBM_SETRANGE, (WPARAM) 0, MAKELPARAM(0, MAX_RANGE)))
+ return false;
return true;
}
@@ -72,7 +73,15 @@ bool
ProgressControl::show()
{
DWORD curPos = (DWORD) ((m_dw64CurrentValue * MAX_RANGE) / m_dw64MaxValue);
- SendMessage(m_hwndProgress, PBM_SETPOS, (WPARAM) curPos, (LPARAM) 0);
+
+ if (!SendMessage(m_hwndProgress, PBM_SETPOS, (WPARAM) curPos, (LPARAM) 0))
+ return false;
return true;
}
+
+int
+ProgressControl::getCurrentPercent()
+{
+ return ((int) ((m_dw64CurrentValue * 100) / m_dw64MaxValue));
+} \ No newline at end of file
diff --git a/rfb_win32/ProgressControl.h b/rfb_win32/ProgressControl.h
index 480c4c89..ceeb153f 100644
--- a/rfb_win32/ProgressControl.h
+++ b/rfb_win32/ProgressControl.h
@@ -39,18 +39,16 @@ namespace rfb {
bool increase(DWORD64 value);
bool clear();
+
+ int getCurrentPercent();
private:
HWND m_hwndProgress;
- DWORD m_dwBarValue;
- DWORD m_dwBarValueMax;
-
DWORD64 m_dw64MaxValue;
DWORD64 m_dw64CurrentValue;
bool show();
-
};
}
}
diff --git a/vncviewer/FTProgress.cxx b/vncviewer/FTProgress.cxx
index 309c8cdd..63b104b0 100644
--- a/vncviewer/FTProgress.cxx
+++ b/vncviewer/FTProgress.cxx
@@ -26,19 +26,36 @@
using namespace rfb;
using namespace rfb::win32;
-FTProgress::FTProgress()
+FTProgress::FTProgress(HWND hwndParent)
{
+ m_bInitialized = false;
+ m_hwndParent = hwndParent;
+ m_pSingleProgress = NULL;
+ m_pGeneralProgress = NULL;
}
FTProgress::~FTProgress()
{
+
}
bool
FTProgress::initialize(DWORD64 totalMaxValue, DWORD maxValue)
{
- return false;
+ m_bInitialized = false;
+
+ m_hwndSinglePercent = GetDlgItem(m_hwndParent, IDC_FTSINGLEPERCENT);
+ m_hwndGeneralPercent = GetDlgItem(m_hwndParent, IDC_FTGENERALPERCENT);
+
+ if ((m_hwndSinglePercent == NULL) || (m_hwndGeneralPercent == NULL)) return false;
+
+ if (!createProgressBarObjects()) return false;
+
+ if (!initProgressControls(totalMaxValue, maxValue)) return false;
+
+ m_bInitialized = true;
+ return true;
}
void
@@ -51,4 +68,70 @@ void
FTProgress::clear()
{
+}
+
+bool
+FTProgress::createProgressBarObjects()
+{
+ if ((m_pSingleProgress != NULL) || (m_pGeneralProgress != NULL)) {
+ return false;
+ } else {
+ HWND hwndSingleProgr = GetDlgItem(m_hwndParent, IDC_FTSINGLEPROGRESS);
+ HWND hwndGeneralProgr = GetDlgItem(m_hwndParent, IDC_FTGENERALPROGRESS);
+
+ m_pSingleProgress = new ProgressControl(hwndSingleProgr);
+ if (m_pSingleProgress == NULL) return false;
+
+ m_pGeneralProgress = new ProgressControl(hwndGeneralProgr);
+ if (m_pGeneralProgress == NULL) {
+ delete m_pSingleProgress;
+ m_pSingleProgress = NULL;
+ return false;
+ }
+ }
+ return true;
+}
+
+bool
+FTProgress::destroyProgressBarObjects()
+{
+ if (m_pSingleProgress != NULL) {
+ delete m_pSingleProgress;
+ }
+
+ if (m_pGeneralProgress != NULL) {
+ delete m_pGeneralProgress;
+ }
+
+ return true;
+}
+
+bool
+FTProgress::initProgressControls(DWORD64 totalMaxValue, DWORD maxValue)
+{
+ bool bResult = true;
+
+ if ((m_pSingleProgress != NULL) && (m_pGeneralProgress != NULL)) {
+ if (!m_pSingleProgress->init(totalMaxValue, 0)) return false;
+ if (!m_pGeneralProgress->init(maxValue, 0)) return false;
+ } else {
+ return false;
+ }
+
+ setProgressText();
+ return true;
+}
+
+void
+FTProgress::setProgressText()
+{
+ char buf[16];
+
+ int percent = m_pSingleProgress->getCurrentPercent();
+ sprintf(buf, "%d%%", percent);
+ SetWindowText(m_hwndSinglePercent, buf);
+
+ percent = m_pGeneralProgress->getCurrentPercent();
+ sprintf(buf, "%d%%", percent);
+ SetWindowText(m_hwndGeneralPercent, buf);
} \ No newline at end of file
diff --git a/vncviewer/FTProgress.h b/vncviewer/FTProgress.h
index 74243dec..2aef36d7 100644
--- a/vncviewer/FTProgress.h
+++ b/vncviewer/FTProgress.h
@@ -26,7 +26,9 @@
#include <windows.h>
#include <commctrl.h>
+#include <stdio.h>
+#include <rfb_win32/ProgressControl.h>
#include <vncviewer/resource.h>
namespace rfb {
@@ -34,12 +36,28 @@ namespace rfb {
class FTProgress
{
public:
- FTProgress();
+ FTProgress(HWND hwndParent);
~FTProgress();
bool initialize(DWORD64 totalMaxValue, DWORD maxValue);
void increase(DWORD value);
void clear();
+
+ private:
+ ProgressControl *m_pSingleProgress;
+ ProgressControl *m_pGeneralProgress;
+
+ HWND m_hwndParent;
+ HWND m_hwndSinglePercent;
+ HWND m_hwndGeneralPercent;
+
+ bool m_bInitialized;
+
+ bool initProgressControls(DWORD64 totalMaxValue, DWORD maxValue);
+
+ void setProgressText();
+ bool createProgressBarObjects();
+ bool destroyProgressBarObjects();
};
}
}
diff --git a/vncviewer/resource.h b/vncviewer/resource.h
index bb19dcc7..fb23e8e4 100644
--- a/vncviewer/resource.h
+++ b/vncviewer/resource.h
@@ -88,10 +88,14 @@
#define IDC_FTREMOTEUP 1061
#define IDC_FTREMOTEBROWSE 1062
#define IDC_FTPROGRESS 1063
+#define IDC_FTGENERALPROGRESS 1063
#define IDC_PROGRESS 1064
+#define IDC_FTSINGLEPROGRESS 1064
#define IDC_FTSTATUS 1065
#define IDC_FTCURRENTPROCENT 1066
+#define IDC_FTSINGLEPERCENT 1066
#define IDC_FTTOTALPROCENT 1067
+#define IDC_FTGENERALPERCENT 1067
#define IDC_FTUPLOAD 1072
#define IDC_FTCANCEL 1073
#define IDC_FTDOWNLOAD 1074
diff --git a/vncviewer/vncviewer.rc b/vncviewer/vncviewer.rc
index 784fa5ff..cf3c512a 100644
--- a/vncviewer/vncviewer.rc
+++ b/vncviewer/vncviewer.rc
@@ -31,7 +31,7 @@ STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
EXSTYLE WS_EX_CONTEXTHELP | WS_EX_CONTROLPARENT
CAPTION "TightVNC File Transfers"
-FONT 8, "MS Sans Serif", 0, 0, 0x1
+FONT 8, "MS Sans Serif"
BEGIN
CTEXT "Local Computer",IDC_FTLOCALLABEL,7,7,200,10
CTEXT "TightVNC Server",IDC_FTREMOTELABEL,323,7,200,10
@@ -53,12 +53,12 @@ BEGIN
PUSHBUTTON "...",IDC_FTREMOTEBROWSE,481,20,14,12
LTEXT "File Transfer",IDC_STATIC,7,245,40,8
LTEXT "Current File",IDC_STATIC,323,245,36,8
- CONTROL "Progress1",IDC_FTPROGRESS,"msctls_progress32",WS_BORDER,
- 55,244,128,10
- CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,
- 370,244,128,10
- CTEXT "0%",IDC_FTTOTALPROCENT,189,245,18,8
- CTEXT "0%",IDC_FTCURRENTPROCENT,505,245,18,8
+ CONTROL "Progress1",IDC_FTGENERALPROGRESS,"msctls_progress32",
+ WS_BORDER,55,244,128,10
+ CONTROL "Progress1",IDC_FTSINGLEPROGRESS,"msctls_progress32",
+ WS_BORDER,370,244,128,10
+ CTEXT "0%",IDC_FTGENERALPERCENT,189,245,18,8
+ CTEXT "0%",IDC_FTSINGLEPERCENT,505,245,18,8
COMBOBOX IDC_FTSTATUS,7,262,516,30,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Upload Files and Folders",IDC_FTUPLOAD,218,66,94,12,
@@ -510,6 +510,15 @@ END
#endif // APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON ICON DISCARDABLE "vncviewer.ico"
+
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -536,15 +545,6 @@ END
#endif // APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ICON ICON DISCARDABLE "vncviewer.ico"
-
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//