6 CMainDlg::CMainDlg(void)
10 CMainDlg::~CMainDlg(void)
14 LRESULT
CMainDlg::DlgFunc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
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
);
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
);
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
);
65 return DoCommand(LOWORD(wParam
));
72 LRESULT
CMainDlg::DoCommand(int id
)
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
);
88 lpStr
= new TCHAR
[nDescLen
+1];
89 ::GetWindowText(hWndDesc
, lpStr
, nDescLen
);
90 m_sDescription
= lpStr
;
93 EndDialog(*this, IDOK
);
97 EndDialog(*this, IDC_SAVE
);
101 EndDialog(*this, IDCANCEL
);
102 PostQuitMessage(IDCANCEL
);