Sync DrDump crash handler with TortoiseSVN codebase
[TortoiseGit.git] / ext / CrashServer / CrashHandler / SendRpt / SendReportDlg.cpp
blobd480efb19cf921b2997d9f92abe0a194db17f6dd
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 #include "StdAfx.h"
19 #include "SendReportDlg.h"
21 LRESULT CStaticEx::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
23 PAINTSTRUCT ps;
24 CDCHandle dc(BeginPaint(&ps));
26 dc.SetTextColor(m_TextColor);
28 CFontHandle font(GetFont());
29 dc.SelectFont(font);
31 RECT rect;
32 GetClientRect(&rect);
34 CString text;
35 GetWindowText(text);
36 dc.DrawText(text, -1, &rect, DT_END_ELLIPSIS | DT_WORDBREAK);
38 EndPaint(&ps);
40 bHandled = TRUE;
42 return 0;
45 LRESULT CSolutionDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
47 LRESULT res = Base::OnInitDialog(uMsg, wParam, lParam, bHandled);
48 GetDlgItem(IDC_QUESTION).SetWindowText(m_question);
50 m_Quest.m_TextColor = CDC(GetDlgItem(IDC_QUESTION).GetDC()).GetTextColor();
51 m_Quest.SubclassWindow(GetDlgItem(IDC_QUESTION));
53 return res;
56 LRESULT CSendFullDumpDlg::OnSetProgress(UINT uMsg, WPARAM wTotal, LPARAM lSent, BOOL& bHandled)
58 if (m_Progress.IsWindow())
60 if (!m_progressBegan)
62 m_Text.LockWindowUpdate(); // without that CStaticEx::OnPaint doesn't called ???
63 m_Text.SetWindowText(m_translator.GetString(L"SendingData"));
64 m_Text.LockWindowUpdate(FALSE);
65 m_Progress.ModifyStyle(PBS_MARQUEE, 0);
66 m_Progress.SetRange(0, 1000); // 1000 to make moving smooth (not less than pixels in progress bar)
67 m_progressBegan = true;
69 m_Progress.SetPos(int((1000.0 * lSent) / wTotal));
71 return 0;
74 LRESULT CAskSendFullDumpDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
76 Base::OnInitDialog(uMsg, wParam, lParam, bHandled);
77 RECT rect_client, rect_main, rect_details;
78 GetClientRect(&rect_client);
79 ClientToScreen(&rect_client);
80 GetWindowRect(&rect_main);
81 GetDlgItem(IDC_DETAILS).GetWindowRect(&rect_details);
82 m_nWidth = rect_client.right - rect_client.left;
83 m_nFullHeight = rect_client.bottom - rect_client.top;
84 int nNewHeight = rect_details.bottom - rect_client.top + 8;
86 ResizeClient(m_nWidth, nNewHeight);
88 m_Details = GetDlgItem(IDC_DETAILS_TEXT);
89 m_Details.SetEventMask(ENM_LINK);
91 SetDetailsText(m_translator.GetString(L"PrivateInfoText"));
93 return 0;
96 void CAskSendFullDumpDlg::SetDetailsText(const CString &text)
98 CString clearText = text;
99 std::vector<std::pair<DWORD, DWORD>> links;
100 int pos;
101 while ((pos = clearText.Find(_T("<a>"))) != -1)
103 DWORD beg = pos;
104 clearText.Delete(pos, 3);
105 pos = clearText.Find(_T("</a>"));
106 if (pos != -1)
108 links.push_back(std::make_pair(beg, DWORD(pos)));
109 clearText.Delete(pos, 4);
113 m_Details.SetWindowTextW(clearText);
115 CHARRANGE sel;
116 m_Details.GetSel(sel);
118 CHARFORMAT2 cf;
119 cf.cbSize = sizeof(cf);
120 cf.dwMask = CFM_LINK | CFM_WEIGHT;
121 cf.dwEffects = CFE_LINK;
122 cf.wWeight = FW_BOLD;
124 for (size_t i = 0; i < links.size(); ++i)
126 m_Details.SetSel(links[i].first, links[i].second);
127 m_Details.SetWordCharFormat(cf);
130 m_Details.SetSel(sel);
133 LRESULT CAskSendFullDumpDlg::OnClickedDetails(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
135 ResizeClient(m_nWidth, m_nFullHeight);
136 GetDlgItem(IDC_DETAILS).EnableWindow(FALSE);
137 return 0;
140 LRESULT CAskSendFullDumpDlg::OnLinkClicked(int windowId, LPNMHDR wParam, BOOL& bHandled)
142 ENLINK* enLink = (ENLINK*) wParam;
143 if (enLink->msg != WM_LBUTTONUP)
144 return 0;
146 if (!m_url.IsEmpty())
147 ShellExecute(NULL, _T("open"), CW2CT(m_url), NULL, NULL, SW_SHOWNORMAL);
149 bHandled = TRUE;
151 return 0;
154 LRESULT CAskSendFullDumpDlg::OnClickedOKCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
156 if (wID == IDCANCEL)
158 if (IDNO == MessageBox(m_translator.GetString(L"MotivateToSendFull"), m_translator.GetAppName(), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
159 return 0;
161 EndDialog(wID);
162 return 0;