Added methods to FTProgress class for creating, destroying
and intialization the progress bar controls.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@379 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/FTProgress.cxx b/vncviewer/FTProgress.cxx
index 309c8cd..63b104b 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 @@
 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 74243de..2aef36d 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 @@
     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 bb19dcc..fb23e8e 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 784fa5f..cf3c512 100644
--- a/vncviewer/vncviewer.rc
+++ b/vncviewer/vncviewer.rc
@@ -31,7 +31,7 @@
     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 @@
     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 @@
 #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 @@
 #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
 /////////////////////////////////////////////////////////////////////////////
 //