2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
18 * PROGRESS DIALOGS ___________________________________________________________
20 * The PROGRESSDISPLAY object is probably one of the most esoteric
21 * utilities in this library. It provides a convenient way to package
22 * up a background thread, and associate it with a dialog telling the user
23 * what's going on. It sounds a little hokey, and honestly isn't that
24 * terribly useful, but you may find you need it at some point.
28 * // Copy the files onto the user's machine.
30 * extern LPTSTR g_apszFilename[];
32 * LPPROGRESSDISPLAY pProg;
33 * pProg = new PROGRESSDISPLAY (hParent, IDD_COPYING_PROGRESS);
34 * pProg->SetProgressRange (0, nFILES(g_apszFilename));
35 * pProg->Show (fnCopyFiles, (LPARAM)g_apszFilename);
37 * // By default, Show() is modal--it pumps messages until the
38 * // background thread completes. If you have specified a
39 * // finish message ("pProg->SetFinishMessage (WM_USER+15)"),
40 * // then Show() is modeless, returning immediately. The WM_USER+15
41 * // message will be posted to the progress dialog when the background
42 * // thread completes (you can specify a dlgproc for your progress
43 * // dialog on the "new PROGRESSDISPLAY" line).
45 * DWORD CALLBACK fnCopyFiles (LPPROGRESSDISPLAY pProg, LPARAM lp)
47 * LPTSTR *apszFilename = (LPTSTR*)lp;
49 * for (ii = 0; ii < nFILES(apszFilename); ++ii) {
50 * pProg->SetOperation ("Copying "+apszFilename[ii]);
51 * CopyFile (apszFilename[ii])
52 * pProg->SetProgress (ii);
61 #include <WINNT/TaLocale.h>
62 #include <WINNT/subclass.h>
66 * DEFINITIONS ________________________________________________________________
71 #define THIS_HINST (HINSTANCE)GetModuleHandle(NULL)
74 #define IDC_OPERATION 900
75 #define IDC_PROGRESS 901
76 #define IDC_PROGRESSTEXT 902
78 typedef class EXPORTED PROGRESSDISPLAY PROGRESSDISPLAY, *LPPROGRESSDISPLAY;
82 * PROGRESSDISPLAY CLASS ______________________________________________________
90 PROGRESSDISPLAY (HWND hWnd);
91 PROGRESSDISPLAY (HWND hParent, int iddTemplate, DLGPROC dlgproc = 0);
93 static LPPROGRESSDISPLAY GetProgressDisplay (HWND hWnd);
95 void GetProgressRange (int *piStart, int *piFinish);
96 void SetProgressRange (int iStart, int iFinish);
98 int GetProgress (void);
99 void SetProgress (int iProgress);
101 void GetOperation (LPTSTR pszOperation);
102 void SetOperation (LPCTSTR pszOperation);
104 HWND GetWindow (void);
106 void SetFinishMessage (int msgFinish);
107 void Show (DWORD (CALLBACK *pfn)(LPPROGRESSDISPLAY ppd, LPARAM lp), LPARAM lp);
109 DWORD GetStatus (void);
113 ~PROGRESSDISPLAY (void);
114 void Init (HWND hWnd);
115 void Finish (DWORD dwStatus = 0);
116 void PROGRESSDISPLAY::OnUpdate (void);
118 static HRESULT CALLBACK ProgressDisplay_StubProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
119 static HRESULT CALLBACK ProgressDisplay_HookProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
120 static DWORD WINAPI PROGRESSDISPLAY::ThreadProc (PVOID lp);
126 CRITICAL_SECTION m_cs;
128 BOOL m_fCreatedWindow;
131 DWORD (CALLBACK *m_pfnUser)(LPPROGRESSDISPLAY ppd, LPARAM lp);
133 int m_iProgressStart;
134 int m_iProgressFinish;
136 TCHAR m_szOperation[ cchRESOURCE ];
137 TCHAR m_szProgressText[ cchRESOURCE ];