9 * PROGRESS DIALOGS ___________________________________________________________
11 * The PROGRESSDISPLAY object is probably one of the most esoteric
12 * utilities in this library. It provides a convenient way to package
13 * up a background thread, and associate it with a dialog telling the user
14 * what's going on. It sounds a little hokey, and honestly isn't that
15 * terribly useful, but you may find you need it at some point.
19 * // Copy the files onto the user's machine.
21 * extern LPTSTR g_apszFilename[];
23 * LPPROGRESSDISPLAY pProg;
24 * pProg = new PROGRESSDISPLAY (hParent, IDD_COPYING_PROGRESS);
25 * pProg->SetProgressRange (0, nFILES(g_apszFilename));
26 * pProg->Show (fnCopyFiles, (LPARAM)g_apszFilename);
28 * // By default, Show() is modal--it pumps messages until the
29 * // background thread completes. If you have specified a
30 * // finish message ("pProg->SetFinishMessage (WM_USER+15)"),
31 * // then Show() is modeless, returning immediately. The WM_USER+15
32 * // message will be posted to the progress dialog when the background
33 * // thread completes (you can specify a dlgproc for your progress
34 * // dialog on the "new PROGRESSDISPLAY" line).
36 * DWORD CALLBACK fnCopyFiles (LPPROGRESSDISPLAY pProg, LPARAM lp)
38 * LPTSTR *apszFilename = (LPTSTR*)lp;
40 * for (ii = 0; ii < nFILES(apszFilename); ++ii) {
41 * pProg->SetOperation ("Copying "+apszFilename[ii]);
42 * CopyFile (apszFilename[ii])
43 * pProg->SetProgress (ii);
52 #include <WINNT/TaLocale.h>
53 #include <WINNT/subclass.h>
57 * DEFINITIONS ________________________________________________________________
62 #define THIS_HINST (HINSTANCE)GetModuleHandle(NULL)
65 #define IDC_OPERATION 900
66 #define IDC_PROGRESS 901
67 #define IDC_PROGRESSTEXT 902
69 typedef class EXPORTED PROGRESSDISPLAY PROGRESSDISPLAY, *LPPROGRESSDISPLAY;
73 * PROGRESSDISPLAY CLASS ______________________________________________________
81 PROGRESSDISPLAY (HWND hWnd);
82 PROGRESSDISPLAY (HWND hParent, int iddTemplate, DLGPROC dlgproc = 0);
84 static LPPROGRESSDISPLAY GetProgressDisplay (HWND hWnd);
86 void GetProgressRange (int *piStart, int *piFinish);
87 void SetProgressRange (int iStart, int iFinish);
89 int GetProgress (void);
90 void SetProgress (int iProgress);
92 void GetOperation (LPTSTR pszOperation);
93 void SetOperation (LPCTSTR pszOperation);
95 HWND GetWindow (void);
97 void SetFinishMessage (int msgFinish);
98 void Show (DWORD (CALLBACK *pfn)(LPPROGRESSDISPLAY ppd, LPARAM lp), LPARAM lp);
100 DWORD GetStatus (void);
104 ~PROGRESSDISPLAY (void);
105 void Init (HWND hWnd);
106 void Finish (DWORD dwStatus = 0);
107 void PROGRESSDISPLAY::OnUpdate (void);
109 static BOOL CALLBACK ProgressDisplay_StubProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
110 static BOOL CALLBACK ProgressDisplay_HookProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
111 static DWORD WINAPI PROGRESSDISPLAY::ThreadProc (PVOID lp);
117 CRITICAL_SECTION m_cs;
119 BOOL m_fCreatedWindow;
122 DWORD (CALLBACK *m_pfnUser)(LPPROGRESSDISPLAY ppd, LPARAM lp);
124 int m_iProgressStart;
125 int m_iProgressFinish;
127 TCHAR m_szOperation[ cchRESOURCE ];
128 TCHAR m_szProgressText[ cchRESOURCE ];