1 /* 2 * Progress dialog 3 * 4 * Copyright 2014 Huw Campbell 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #ifndef _PROGRESSDIALOG_H_ 22 #define _PROGRESSDIALOG_H_ 23 24 class CProgressDialog : 25 public CComCoClass<CProgressDialog, &CLSID_ProgressDialog>, 26 public CComObjectRootEx<CComMultiThreadModelNoCS>, 27 public IProgressDialog, 28 public IOleWindow 29 { 30 public: 31 CRITICAL_SECTION cs; 32 HWND hwnd; 33 DWORD dwFlags; 34 DWORD dwUpdate; 35 LPWSTR lines[3]; 36 LPWSTR cancelMsg; 37 LPWSTR title; 38 BOOL isCancelled; 39 ULONGLONG ullCompleted; 40 ULONGLONG ullTotal; 41 HWND hwndDisabledParent; 42 void set_progress_marquee(); 43 void update_dialog(DWORD dwUpdate); 44 void end_dialog(); 45 46 UINT clockHand; 47 struct progressMark { 48 ULONGLONG ullMark; 49 DWORD dwTime; 50 }; 51 progressMark progressClock[30]; 52 DWORD dwStartTime; 53 54 CProgressDialog(); 55 ~CProgressDialog(); 56 57 // IProgressDialog 58 virtual HRESULT WINAPI StartProgressDialog(HWND hwndParent, IUnknown *punkEnableModeless, DWORD dwFlags, LPCVOID reserved); 59 virtual HRESULT WINAPI StopProgressDialog(); 60 virtual HRESULT WINAPI SetTitle(LPCWSTR pwzTitle); 61 virtual HRESULT WINAPI SetAnimation(HINSTANCE hInstance, UINT uiResourceId); 62 virtual BOOL WINAPI HasUserCancelled(); 63 virtual HRESULT WINAPI SetProgress64(ULONGLONG ullCompleted, ULONGLONG ullTotal); 64 virtual HRESULT WINAPI SetProgress(DWORD dwCompleted, DWORD dwTotal); 65 virtual HRESULT WINAPI SetLine(DWORD dwLineNum, LPCWSTR pwzLine, BOOL bPath, LPCVOID reserved); 66 virtual HRESULT WINAPI SetCancelMsg(LPCWSTR pwzMsg, LPCVOID reserved); 67 virtual HRESULT WINAPI Timer(DWORD dwTimerAction, LPCVOID reserved); 68 69 //////// IOleWindow 70 virtual HRESULT WINAPI GetWindow(HWND* phwnd); 71 virtual HRESULT WINAPI ContextSensitiveHelp(BOOL fEnterMode); 72 73 DECLARE_REGISTRY_RESOURCEID(IDR_PROGRESSDIALOG) 74 DECLARE_NOT_AGGREGATABLE(CProgressDialog) 75 76 DECLARE_PROTECT_FINAL_CONSTRUCT() 77 78 BEGIN_COM_MAP(CProgressDialog) 79 COM_INTERFACE_ENTRY_IID(IID_IProgressDialog, IProgressDialog) 80 COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow) 81 END_COM_MAP() 82 }; 83 84 #endif /* _PROGRESSDIALOG_H_ */ 85