Use CAutoGeneralHandle
[TortoiseGit.git] / src / TortoiseProc / ProgressDlg.h
blob36a74f4bae05f35f39f4537362b24ff302258880
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "StandAloneDlg.h"
22 #include "git.h"
23 #include "MenuButton.h"
24 #include "Win7.h"
26 #define MSG_PROGRESSDLG_UPDATE_UI (WM_USER+121)
28 // CProgressDlg dialog
29 #define MSG_PROGRESSDLG_START 0
30 #define MSG_PROGRESSDLG_RUN 50
31 #define MSG_PROGRESSDLG_END 110
32 #define MSG_PROGRESSDLG_FAILED 111
34 class CProgressDlg : public CResizableStandAloneDialog
36 DECLARE_DYNAMIC(CProgressDlg)
37 public:
38 CProgressDlg(CWnd* pParent = NULL); // standard constructor
39 virtual ~CProgressDlg();
41 private:
42 virtual BOOL OnInitDialog();
44 // Dialog Data
45 enum { IDD = IDD_GITPROGRESS };
47 public:
48 CString m_Title;
49 CString m_GitCmd;
50 CStringArray m_PostCmdList;
51 std::vector<CString> m_GitCmdList;
52 CString m_PreText; // optional text to show in log window before running command
53 bool m_bShowCommand; // whether to display the command in the log window (default true)
54 CString m_LogFile;
55 bool m_bBufferAll; // Buffer All to improve speed when there are many file add at commit
56 bool m_bAutoCloseOnSuccess;
58 DWORD m_GitStatus;
59 CString m_LogText;
61 private:
62 CMenuButton m_ctrlPostCmd;
64 CProgressCtrl m_Progress;
66 CRichEditCtrl m_Log;
67 CAnimateCtrl m_Animate;
68 CStatic m_CurrentWork;
69 CWinThread* m_pThread;
70 volatile LONG m_bThreadRunning;
72 bool m_bAbort;
73 bool m_bDone;
74 bool m_bAltAbortPress;
76 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
77 static UINT ProgressThreadEntry(LPVOID pVoid);
78 UINT ProgressThread();
80 CStringA m_LogTextA;
82 void ParserCmdOutput(char ch);
83 void RemoveLastLine(CString &str);
85 LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
87 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
88 CComPtr<ITaskbarList3> m_pTaskbarList;
90 void OnCancel();
91 afx_msg void OnClose();
92 void InsertCRLF(); //Insert \r before \n
93 void KillProcessTree(DWORD dwProcessId);
95 CGitByteArray m_Databuf;
96 virtual CString Convert2UnionCode(char *buff, int size=-1)
98 CString str;
99 g_Git.StringAppend(&str, (BYTE*)buff, CP_UTF8, size);
100 return str;
103 int m_BufStart;
105 DECLARE_MESSAGE_MAP()
107 //Share with Sync Dailog
108 static int FindPercentage(CString &log);
110 static void ClearESC(CString &str);
112 public:
113 static void ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,HWND m_hWnd,CComPtr<ITaskbarList3> m_pTaskbarList,
114 CStringA &oneline, char ch,CWnd *CurrentWork=NULL);
116 static UINT RunCmdList(CWnd *pWnd,std::vector<CString> &cmdlist,bool bShowCommand,CString *pfilename,bool *bAbort,CGitByteArray *pdata=NULL);
118 private:
119 static void InsertColorText(CRichEditCtrl &edit,CString text,COLORREF rgb);
121 afx_msg void OnBnClickedOk();
122 afx_msg void OnBnClickedButton1();
124 virtual BOOL PreTranslateMessage(MSG* pMsg);
127 class CCommitProgressDlg:public CProgressDlg
129 public:
130 CCommitProgressDlg(CWnd* pParent = NULL):CProgressDlg(pParent)
134 virtual CString Convert2UnionCode(char *buff, int size=-1);