PageRenderTime 26ms CodeModel.GetById 23ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/3rd_party/wtl/Samples/TabBrowser/OpenDlg.h

https://code.google.com/p/softart/
C Header | 66 lines | 51 code | 14 blank | 1 comment | 2 complexity | 34e7a2075bc190056a57cb6fc425137f MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, JSON, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, BSD-2-Clause
 1// OpenDlg.h - COpenDlg class
 2
 3#pragma once
 4
 5
 6class COpenDlg : public CDialogImpl<COpenDlg>
 7{
 8public:
 9	enum { IDD = IDD_OPEN };
10
11	CString m_strURL;
12	bool m_bNewTab;
13
14	COpenDlg(LPCTSTR lpstrURL) : m_bNewTab(false)
15	{
16		m_strURL = lpstrURL;
17	}
18
19	BEGIN_MSG_MAP(COpenDlg)
20		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
21		COMMAND_ID_HANDLER(IDOK, OnOK)
22		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
23	END_MSG_MAP()
24
25	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
26	{
27
28		if(m_strURL.IsEmpty())
29		{
30			m_bNewTab = true;
31			CButton btnCheck = GetDlgItem(IDC_NEW_TAB);
32			btnCheck.SetCheck(1);
33			btnCheck.EnableWindow(FALSE);
34		}
35		else
36		{
37			CEdit edit = GetDlgItem(IDC_EDIT_URL);
38			edit.SetWindowText(m_strURL);
39
40			CButton btnCheck = GetDlgItem(IDC_NEW_TAB);
41			btnCheck.SetCheck(m_bNewTab ? 1 : 0);
42		}
43
44		return TRUE;
45	}
46
47	LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
48	{
49		CEdit edit = GetDlgItem(IDC_EDIT_URL);
50		int nLen = edit.GetWindowTextLength();
51		edit.GetWindowText(m_strURL.GetBuffer(nLen), nLen + 1);
52		m_strURL.ReleaseBuffer();
53
54		CButton btnCheck = GetDlgItem(IDC_NEW_TAB);
55		m_bNewTab = (btnCheck.GetCheck() != 0);
56
57		EndDialog(wID);
58		return 0;
59	}
60
61	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
62	{
63		EndDialog(wID);
64		return 0;
65	}
66};