format title for log dialog
[TortoiseGit.git] / src / crashrpt / MainDlg.cpp
blobcac27ffd4559a11d384b977d1527f3d8c007827d
1 #include "StdAfx.h"
3 #include "MainDlg.h"
4 #include "resource.h"
6 CMainDlg::CMainDlg(void)
10 CMainDlg::~CMainDlg(void)
14 LRESULT CMainDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
16 switch (uMsg)
18 case WM_INITDIALOG:
20 InitDialog(hwndDlg, IDR_MAINFRAME);
22 // Set title using app name
24 ::SetWindowText(*this, CUtility::getAppName().c_str());
25 // Hide 'Send' button if required. Position 'Send' and 'Save'.
27 HWND okButton = ::GetDlgItem(*this, IDOK);
28 HWND saveButton = ::GetDlgItem(*this, IDC_SAVE);
29 if (m_sendButton)
31 // Line up Save, Send [OK] and Exit [Cancel] all in a row
32 HWND cancelButton = ::GetDlgItem(*this, IDCANCEL);
33 WINDOWPLACEMENT okPlace;
34 WINDOWPLACEMENT savePlace;
35 WINDOWPLACEMENT cancelPlace;
37 ::GetWindowPlacement(okButton, &okPlace);
38 ::GetWindowPlacement(saveButton, &savePlace);
39 ::GetWindowPlacement(cancelButton, &cancelPlace);
41 savePlace.rcNormalPosition.left =
42 okPlace.rcNormalPosition.left -
43 (savePlace.rcNormalPosition.right - savePlace.rcNormalPosition.left) +
44 (okPlace.rcNormalPosition.right - cancelPlace.rcNormalPosition.left);
45 ::SetWindowPlacement(saveButton, &savePlace);
47 DWORD style = ::GetWindowLong(okButton, GWL_STYLE);
48 ::SetWindowLong(okButton, GWL_STYLE, style | WS_VISIBLE);
50 else
52 WINDOWPLACEMENT okPlace;
54 // Put Save on top of the invisible Send [OK]
55 ::GetWindowPlacement(okButton, &okPlace);
57 ::SetWindowPlacement(saveButton, &okPlace);
59 DWORD style = ::GetWindowLong(okButton, GWL_STYLE);
60 ::SetWindowLong(okButton, GWL_STYLE, style & ~ WS_VISIBLE);
63 return TRUE;
64 case WM_COMMAND:
65 return DoCommand(LOWORD(wParam));
66 default:
67 return FALSE;
69 return TRUE;
72 LRESULT CMainDlg::DoCommand(int id)
74 switch (id)
76 case IDOK: // send
78 HWND hWndEmail = ::GetDlgItem(*this, IDC_EMAIL);
79 HWND hWndDesc = ::GetDlgItem(*this, IDC_DESCRIPTION);
80 int nEmailLen = ::GetWindowTextLength(hWndEmail) + 1;
81 int nDescLen = ::GetWindowTextLength(hWndDesc) + 1;
83 TCHAR * lpStr = new TCHAR[nEmailLen+1];
84 ::GetWindowText(hWndEmail, lpStr, nEmailLen);
85 m_sEmail = lpStr;
86 delete [] lpStr;
88 lpStr = new TCHAR[nDescLen+1];
89 ::GetWindowText(hWndDesc, lpStr, nDescLen);
90 m_sDescription = lpStr;
91 delete [] lpStr;
93 EndDialog(*this, IDOK);
94 return 0;
95 break;
96 case IDC_SAVE:
97 EndDialog(*this, IDC_SAVE);
98 return 0;
99 break;
100 case IDCANCEL:
101 EndDialog(*this, IDCANCEL);
102 PostQuitMessage(IDCANCEL);
103 return 0;
104 break;
106 return 1;