[d1d6776] | 1 | // PropPaths.cpp : implementation file |
---|
| 2 | // |
---|
| 3 | |
---|
| 4 | #define BITLBEE_CORE |
---|
| 5 | #include "bitlbeewin.h" |
---|
| 6 | #include "PropPaths.h" |
---|
| 7 | #include "shlobj.h" |
---|
| 8 | |
---|
| 9 | #ifdef _DEBUG |
---|
| 10 | #define new DEBUG_NEW |
---|
| 11 | #undef THIS_FILE |
---|
| 12 | static char THIS_FILE[] = __FILE__; |
---|
| 13 | #endif |
---|
| 14 | |
---|
| 15 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 16 | // CPropPaths dialog |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | CPropPaths::CPropPaths() |
---|
| 20 | : CPropertyPage(CPropPaths::IDD) |
---|
| 21 | { |
---|
| 22 | //{{AFX_DATA_INIT(CPropPaths) |
---|
| 23 | // NOTE: the ClassWizard will add member initialization here |
---|
| 24 | //}}AFX_DATA_INIT |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | void CPropPaths::DoDataExchange(CDataExchange* pDX) |
---|
| 29 | { |
---|
| 30 | CDialog::DoDataExchange(pDX); |
---|
| 31 | //{{AFX_DATA_MAP(CPropPaths) |
---|
| 32 | DDX_Control(pDX, IDC_MOTDFILE, m_motdfile); |
---|
| 33 | DDX_Control(pDX, IDC_EDIT_MOTD, m_edit_motd); |
---|
| 34 | DDX_Control(pDX, IDC_CONFIGDIR, m_configdir); |
---|
| 35 | DDX_Control(pDX, IDC_BROWSE_MOTD, m_browse_motd); |
---|
| 36 | DDX_Control(pDX, IDC_BROWSE_CONFIG, m_browse_config); |
---|
| 37 | //}}AFX_DATA_MAP |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | BEGIN_MESSAGE_MAP(CPropPaths, CPropertyPage) |
---|
| 42 | //{{AFX_MSG_MAP(CPropPaths) |
---|
| 43 | ON_BN_CLICKED(IDC_BROWSE_CONFIG, OnBrowseConfig) |
---|
| 44 | ON_BN_CLICKED(IDC_BROWSE_MOTD, OnBrowseMotd) |
---|
| 45 | ON_BN_CLICKED(IDC_EDIT_MOTD, OnEditMotd) |
---|
| 46 | //}}AFX_MSG_MAP |
---|
| 47 | END_MESSAGE_MAP() |
---|
| 48 | |
---|
| 49 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 50 | // CPropPaths message handlers |
---|
| 51 | |
---|
| 52 | void CPropPaths::OnOK() |
---|
| 53 | { |
---|
| 54 | CString tmp; |
---|
| 55 | g_free((void *)global.conf->configdir); |
---|
| 56 | m_configdir.GetWindowText(tmp); |
---|
| 57 | |
---|
| 58 | if (tmp.GetLength() > 0 |
---|
| 59 | && tmp.GetAt(tmp.GetLength() - 1) != '/' |
---|
| 60 | && tmp.GetAt(tmp.GetLength() - 1) != '\\') |
---|
| 61 | { |
---|
| 62 | global.conf->configdir = g_strdup_printf("%s\\", tmp); |
---|
| 63 | } else { |
---|
| 64 | global.conf->configdir = g_strdup(tmp); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | g_free((void *)global.conf->motdfile); |
---|
| 68 | m_motdfile.GetWindowText(tmp); |
---|
| 69 | global.conf->motdfile = g_strdup(tmp); |
---|
| 70 | |
---|
| 71 | CPropertyPage::OnOK(); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | void CPropPaths::OnBrowseConfig() |
---|
| 75 | { |
---|
| 76 | BROWSEINFO bi = { 0 }; |
---|
| 77 | bi.lpszTitle = _T("Choose a config directory"); |
---|
| 78 | LPITEMIDLIST pidl = SHBrowseForFolder(&bi); |
---|
| 79 | if( pidl != 0) |
---|
| 80 | { |
---|
| 81 | TCHAR path[MAX_PATH]; |
---|
| 82 | if( SHGetPathFromIDList (pidl, path) ) { |
---|
| 83 | m_configdir.SetWindowText(path); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | IMalloc * imalloc = 0; |
---|
| 87 | if ( SUCCEEDED (SHGetMalloc (&imalloc)) ) |
---|
| 88 | { |
---|
| 89 | imalloc->Free(pidl); |
---|
| 90 | imalloc->Release(); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | void CPropPaths::OnBrowseMotd() |
---|
| 96 | { |
---|
| 97 | CFileDialog f(TRUE); |
---|
| 98 | |
---|
| 99 | if(f.DoModal() == IDOK) { |
---|
| 100 | m_motdfile.SetWindowText(f.GetPathName()); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | void CPropPaths::OnEditMotd() |
---|
| 106 | { |
---|
| 107 | CString loc;m_motdfile.GetWindowText(loc); |
---|
| 108 | ShellExecute(this->GetSafeHwnd(), NULL, loc, NULL, NULL, SW_SHOWNORMAL); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | BOOL CPropPaths::OnInitDialog() |
---|
| 112 | { |
---|
| 113 | CPropertyPage::OnInitDialog(); |
---|
| 114 | |
---|
| 115 | m_configdir.SetWindowText(global.conf->configdir); |
---|
| 116 | m_motdfile.SetWindowText(global.conf->motdfile); |
---|
| 117 | |
---|
| 118 | return TRUE; |
---|
| 119 | } |
---|