summaryrefslogtreecommitdiff
path: root/win32/droplet/progressdlg.h
blob: 1e416a1308e659c8337578858b217cc900c2eea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * AUTHOR
 * N. Nielsen
 *
 * LICENSE
 * This software is in the public domain.
 *
 * The software is provided "as is", without warranty of any kind,
 * express or implied, including but not limited to the warranties
 * of merchantability, fitness for a particular purpose, and
 * noninfringement. In no event shall the author(s) be liable for any
 * claim, damages, or other liability, whether in an action of
 * contract, tort, or otherwise, arising from, out of, or in connection
 * with the software or the use or other dealings in the software.
 *
 * SUPPORT
 * Send bug reports to: <nielsen@memberwebs.com>
 */

#ifndef __PROGRESSDLG_H_
#define __PROGRESSDLG_H_

#include "resource.h"       // main symbols
#include <atlhost.h>

// ProgressDlg: --------------------------------------------------------
//  The status dialog which is run in another thread

class ProgressDlg :
	public CDialogImpl<ProgressDlg>
{
public:
	ProgressDlg();
	~ProgressDlg();

	enum { IDD = IDD_PROGRESSDLG };

BEGIN_MSG_MAP(ProgressDlg)
	MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog)
	MESSAGE_HANDLER(WM_CLOSE, onClose)
	COMMAND_ID_HANDLER(IDCANCEL, onCancel)
END_MSG_MAP()

public:
	// Start dialog in another thread
	HRESULT startDialog();

	// Stop the dialog thread
	int stopDialog();

	// Called when a replacement is noted
	void onReplaced();

	// Called (by Replace::replaceSingleFile) when starting
	// to process new file
	void onNewFile(LPCTSTR fileName);

	// Polled (by Replace::matchStatus) to check if user cancelled
	bool isCancelled();

	// Set the dialog title
	void setTitle(const string& title);

protected:
	// Update status etc...
	void updateControls();

// The message handlers
protected:
	LRESULT onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT onClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT onCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	// Handler prototypes:
	//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

protected:
	HANDLE m_hThread;			// The dialog thread
	string m_title;				// The dialog title

	HANDLE m_hEvent;			// dialog initialization event
	CRITICAL_SECTION m_sec;		// Used for syncing access to date below

	bool m_isCancelled;			// Set when user clicks cancel
	uint m_numFiles;			// Number of files processed
	uint m_numReplaces;			// Number of replaces seen
	bool m_flip;				// Used for flicker display
};

#endif //__PROGRESSDLG_H_