Sync DrDump crash handler with TortoiseSVN codebase
[TortoiseGit.git] / ext / CrashServer / CrashHandler / SendRpt / SendReportDlg.h
blob5cf95fb1f2788b7339f208adaf60c141dbc3b586
1 // Copyright 2014 Idol Software, Inc.
2 //
3 // This file is part of Doctor Dump SDK.
4 //
5 // Doctor Dump SDK is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
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 Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include "resource.h" // main symbols
22 #include <atlhost.h>
23 #include "atlapp.h"
24 #include "atlctrls.h"
25 #include "atlctrlx.h"
26 #include "Translator.h"
29 class CStaticEx: public CWindowImpl<CStatic>
31 public:
32 BEGIN_MSG_MAP(CStaticEx)
33 MESSAGE_HANDLER(WM_PAINT, OnPaint)
34 END_MSG_MAP()
36 COLORREF m_TextColor;
38 LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
41 // CBaseDlgT
43 template <DWORD T>
44 class CBaseDlgT :
45 public CAxDialogImpl<CBaseDlgT<T> >
47 HFONT m_Big;
48 CStaticEx m_Header;
49 protected:
50 typedef CBaseDlgT<T> Base;
51 CStaticEx m_Text;
52 CProgressBarCtrl m_Progress;
53 Translator& m_translator;
54 public:
55 CBaseDlgT(Translator& translator)
56 : m_translator(translator)
60 enum { IDD = T };
62 BEGIN_MSG_MAP(CBaseDlgT<T>)
63 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
64 COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOKCancel)
65 COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedOKCancel)
66 CHAIN_MSG_MAP(CAxDialogImpl<CBaseDlgT<T> >)
67 END_MSG_MAP()
69 // Handler prototypes:
70 // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
71 // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
72 // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
74 void TranslateWindow(CWindow& window)
76 CString text;
77 window.GetWindowText(text);
78 if (text.Left(1) == L"@")
79 window.SetWindowText(m_translator.GetString(text.Mid(1)));
82 static BOOL CALLBACK TranslateWindows(HWND hwnd, LPARAM lParam)
84 CBaseDlgT* self = (CBaseDlgT*)lParam;
85 self->TranslateWindow(CWindow(hwnd));
86 return TRUE;
89 virtual LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
91 CAxDialogImpl<CBaseDlgT<T> >::OnInitDialog(uMsg, wParam, lParam, bHandled);
92 bHandled = TRUE;
93 SetIcon(::LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SENDRPT)));
95 HFONT hFont = GetFont();
96 LOGFONT lf;
97 GetObject(hFont, sizeof(lf), &lf);
98 lf.lfWeight = FW_THIN;
99 lf.lfHeight = 20;
100 m_Big = CreateFontIndirect(&lf);
102 TranslateWindow(*this);
103 EnumChildWindows(*this, TranslateWindows, (LPARAM)this);
105 GetDlgItem(IDC_HEADER_TEXT).SetFont(m_Big);
106 m_Header.SubclassWindow(GetDlgItem(IDC_HEADER_TEXT));
107 m_Header.m_TextColor = RGB(0, 0x33, 0x99);
109 m_Text.m_TextColor = CDC(GetDlgItem(IDC_TEXT).GetDC()).GetTextColor();
110 m_Text.SubclassWindow(GetDlgItem(IDC_TEXT));
112 m_Progress = GetDlgItem(IDC_PROGRESS);
113 if (m_Progress.IsWindow())
114 m_Progress.SetMarquee(TRUE);
116 return 1; // Let the system set the focus
119 virtual LRESULT OnClickedOKCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
121 EndDialog(wID);
122 return 0;
127 // CSendReportDlg
129 class CSendReportDlg : public CBaseDlgT<IDD_SENDREPORTDLG>
131 public:
132 CSendReportDlg(Translator& translator)
133 : CBaseDlgT(translator)
138 // CSendAssertReportDlg
140 class CSendAssertReportDlg : public CBaseDlgT<IDD_SENDASSERTREPORTDLG>
142 public:
143 CSendAssertReportDlg(Translator& translator)
144 : CBaseDlgT(translator)
149 // CSendFullDumpDlg
151 class CSendFullDumpDlg : public CBaseDlgT<IDD_SENDFULLDUMPDLG>
153 bool m_progressBegan;
154 public:
155 CSendFullDumpDlg(Translator& translator)
156 : CBaseDlgT(translator), m_progressBegan(false)
160 BEGIN_MSG_MAP(CSendFullDumpDlg)
161 MESSAGE_HANDLER(WM_USER, OnSetProgress)
162 CHAIN_MSG_MAP(Base)
163 END_MSG_MAP()
165 LRESULT OnSetProgress(UINT uMsg, WPARAM wTotal, LPARAM lSent, BOOL& bHandled);
168 // CSolutionDlg
170 class CSolutionDlg : public CBaseDlgT<IDD_SOLUTIONDLG>
172 CStaticEx m_Quest;
173 CString m_question;
174 public:
175 enum Type { Read, Install };
176 CSolutionDlg(Translator& translator, Type type)
177 : CBaseDlgT(translator), m_question(m_translator.GetString(type == Read ? L"DoYouWantToReadIt" : L"DoYouWantToInstallIt"))
181 LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override;
184 // CAskSendFullDumpDlg
186 class CAskSendFullDumpDlg : public CBaseDlgT<IDD_ASKSENDFULLDUMPDLG>
188 int m_nWidth, m_nFullHeight;
189 CRichEditCtrl m_Details;
190 CString m_url;
191 public:
192 CAskSendFullDumpDlg(Translator& translator, const wchar_t* pszUrl)
193 : CBaseDlgT(translator), m_url(pszUrl)
197 BEGIN_MSG_MAP(CAskSendFullDumpDlg)
198 COMMAND_HANDLER(IDC_DETAILS, BN_CLICKED, OnClickedDetails)
199 NOTIFY_HANDLER(IDC_DETAILS_TEXT, EN_LINK, OnLinkClicked)
200 CHAIN_MSG_MAP(Base)
201 END_MSG_MAP()
203 LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override;
204 void SetDetailsText(const CString &text);
205 LRESULT OnClickedDetails(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
206 LRESULT OnLinkClicked(int windowId, LPNMHDR wParam, BOOL& bHandled);
207 LRESULT OnClickedOKCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) override;