BOOL CToolAssocDlg::OnInitDialog() { CDialog::OnInitDialog(); EnableToolTips(); m_tooltips.Create(this); CString title; if (m_sType == _T("Diff")) { title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_DIFF_TOOL : IDS_DLGTITLE_EDIT_DIFF_TOOL); m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTDIFF_TT); } else { title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_MERGE_TOOL : IDS_DLGTITLE_EDIT_MERGE_TOOL); m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTMERGE_TT); } SetWindowText(title); SHAutoComplete(::GetDlgItem(m_hWnd, IDC_TOOLEDIT), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY); UpdateData(FALSE); return TRUE; }
void COpenDlg::AutoCompleteOn(int controlId) { HWND hwnd; GetDlgItem(controlId, &hwnd); if (hwnd) SHAutoComplete(hwnd, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON | SHACF_FILESYSTEM); }
void CHistoryCombo::SetPathHistory(BOOL bPathHistory) { m_bPathHistory = bPathHistory; if (m_bPathHistory) { HWND hwndEdit; // use for ComboEx hwndEdit = (HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0); if (NULL == hwndEdit) { //if not, try the old standby if(hwndEdit==NULL) { CWnd* pWnd = this->GetDlgItem(1001); if(pWnd) { hwndEdit = pWnd->GetSafeHwnd(); } } } if (hwndEdit) SHAutoComplete(hwndEdit, SHACF_FILESYSTEM); } #ifdef HISTORYCOMBO_WITH_SYSIMAGELIST SetImageList(&SYS_IMAGE_LIST()); #endif }
BOOL CRenameDlg::OnInitDialog() { CHorizontalResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); SHAutoComplete(GetDlgItem(IDC_NAME)->m_hWnd, SHACF_DEFAULT); if (!m_windowtitle.IsEmpty()) this->SetWindowText(m_windowtitle); if (!m_label.IsEmpty()) SetDlgItemText(IDC_LABEL, m_label); if (!m_name.IsEmpty()) { CString sTmp; sTmp.Format(IDS_RENAME_INFO, (LPCWSTR)m_name); SetDlgItemText(IDC_RENINFOLABEL, sTmp); } AddAnchor(IDC_RENINFOLABEL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_LABEL, TOP_LEFT); AddAnchor(IDC_NAME, TOP_LEFT, TOP_RIGHT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); CControlsBridge::AlignHorizontally(this, IDC_LABEL, IDC_NAME); if (hWndExplorer) CenterWindow(CWnd::FromHandle(hWndExplorer)); EnableSaveRestore(_T("RenameDlg")); m_originalName = m_name; return TRUE; }
void CHistoryCombo::SetURLHistory(BOOL bURLHistory) { m_bURLHistory = bURLHistory; if (m_bURLHistory) { HWND hwndEdit; // use for ComboEx hwndEdit = (HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0); if (NULL == hwndEdit) { // Try the unofficial way of getting the edit control CWnd* CWnd* pWnd = this->GetDlgItem(1001); if(pWnd) { hwndEdit = pWnd->GetSafeHwnd(); } } if (hwndEdit) SHAutoComplete(hwndEdit, SHACF_URLALL); } #ifdef HISTORYCOMBO_WITH_SYSIMAGELIST SetImageList(&SYS_IMAGE_LIST()); #endif }
void CThhylDlg::OnAutocomp() { // TODO: Add your control notification handler code here UpdateData(); SHAutoComplete( ((CEdit*)GetDlgItem(IDC_RPYFILE))->GetSafeHwnd(), m_bAutocomp ? 0x10000043 : 0x20000043 ); }
BOOL CExportDlg::OnInitDialog() { CHorizontalResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); if (g_Git.m_CurrentDir == m_orgPath.GetWinPathString()) { GetDlgItem(IDC_WHOLE_PROJECT)->EnableWindow(FALSE); ((CButton *)GetDlgItem(IDC_WHOLE_PROJECT))->SetCheck(TRUE); } AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_EXPORTFILE_LABEL, TOP_LEFT); AddAnchor(IDC_EXPORTFILE_BROWSE, TOP_RIGHT); AddAnchor(IDC_EXPORTFILE, TOP_LEFT, TOP_RIGHT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); AdjustControlSize(IDC_RADIO_BRANCH); AdjustControlSize(IDC_RADIO_TAGS); AdjustControlSize(IDC_RADIO_VERSION); SetDlgTitle(); CHOOSE_VERSION_ADDANCHOR; this->AddOthersToAnchor(); InitChooseVersion(); if (m_initialRefName.IsEmpty() || m_initialRefName == _T("HEAD")) { SetDefaultChoose(IDC_RADIO_HEAD); } else if (m_initialRefName.Left(10) == _T("refs/tags/")) SetDefaultChoose(IDC_RADIO_TAGS); CWnd* pHead = GetDlgItem(IDC_RADIO_HEAD); CString headText; pHead->GetWindowText(headText); pHead->SetWindowText(headText + " (" + g_Git.GetCurrentBranch() + ")"); AdjustControlSize(IDC_RADIO_HEAD); m_tooltips.AddTool(IDC_EXPORTFILE, IDS_EXPORTFILE_TT); SHAutoComplete(GetDlgItem(IDC_EXPORTFILE)->m_hWnd, SHACF_FILESYSTEM); if ((m_pParentWnd==NULL)&&(hWndExplorer)) CenterWindow(CWnd::FromHandle(hWndExplorer)); EnableSaveRestore(_T("ExportDlg")); return TRUE; }
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // create command bar window HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE); // attach menu m_CmdBar.AttachMenu(GetMenu()); // load command bar images m_CmdBar.LoadImages(IDR_MAINFRAME); // remove old menu SetMenu(NULL); HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE); CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE); AddSimpleReBarBand(hWndCmdBar); AddSimpleReBarBand(hWndToolBar, NULL, TRUE); CString szAddress; szAddress.LoadString(IDS_ADDRESS); m_URL.Create(m_hWnd,CRect(0,0,0,18),NULL,WS_CHILD|WS_VISIBLE,WS_EX_STATICEDGE); AddSimpleReBarBand(m_URL,szAddress.GetBuffer(0),TRUE); m_URL.SetFont(AtlGetDefaultGuiFont()); SHAutoComplete(m_URL,SHACF_URLALL); CreateSimpleStatusBar(); m_StatusBar.SubclassWindow(m_hWndStatusBar); int nPanes[]={ID_DEFAULT_PANE,IDR_LOCK,IDR_PROGRESS}; m_StatusBar.SetPanes(nPanes,sizeof(nPanes)/sizeof(int),false); m_StatusBar.SetPaneWidth(IDR_LOCK,30); m_StatusBar.SetPaneWidth(IDR_PROGRESS,50); //TODO: Replace with a URL of your choice m_hWndClient = m_view.Create(m_hWnd, rcDefault, _T("about:blank"), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL, WS_EX_CLIENTEDGE); UIAddToolBar(hWndToolBar); UISetCheck(ID_VIEW_TOOLBAR, 1); UISetCheck(ID_VIEW_STATUS_BAR, 1); // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); m_view.GoHome(); return 0; }
void CHistoryCombo::SetAutoComplete(DWORD flags) { // use for ComboEx HWND hwndEdit = (HWND)::SendMessage(this->m_hWnd, CBEM_GETEDITCONTROL, 0, 0); if (NULL == hwndEdit) { // Try the unofficial way of getting the edit control CWnd* CWnd* pWnd = this->GetDlgItem(1001); if(pWnd) { hwndEdit = pWnd->GetSafeHwnd(); } } if (hwndEdit) SHAutoComplete(hwndEdit, flags); }
void Explorerplusplus::CreateAddressBar(void) { m_hAddressBar = CreateComboBox(m_hMainRebar,WS_CHILD|WS_VISIBLE|WS_TABSTOP| CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_CLIPSIBLINGS|WS_CLIPCHILDREN); HIMAGELIST SmallIcons; Shell_GetImageLists(NULL,&SmallIcons); SendMessage(m_hAddressBar,CBEM_SETIMAGELIST,0,reinterpret_cast<LPARAM>(SmallIcons)); HWND hEdit = reinterpret_cast<HWND>(SendMessage(m_hAddressBar,CBEM_GETEDITCONTROL,0,0)); SetWindowSubclass(hEdit,EditSubclassStub,0,reinterpret_cast<DWORD_PTR>(this)); /* Turn on auto complete for the edit control within the combobox. This will let the os complete paths as they are typed. */ SHAutoComplete(hEdit,SHACF_FILESYSTEM|SHACF_AUTOSUGGEST_FORCE_ON); }
BOOL CSettingsProgsUniDiff::OnInitDialog() { ISettingsPropPage::OnInitDialog(); EnableToolTips(); m_sDiffViewerPath = m_regDiffViewerPath; m_iDiffViewer = IsExternal(m_sDiffViewerPath); SHAutoComplete(::GetDlgItem(m_hWnd, IDC_DIFFVIEWER), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY); m_tooltips.Create(this); m_tooltips.AddTool(IDC_DIFFVIEWER, IDS_SETTINGS_DIFFVIEWER_TT); UpdateData(FALSE); return TRUE; }
BOOL CExportDlg::OnInitDialog() { CHorizontalResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_EXPORTFILE_LABEL, TOP_LEFT); AddAnchor(IDC_EXPORTFILE_BROWSE, TOP_RIGHT); AddAnchor(IDC_EXPORTFILE, TOP_LEFT, TOP_RIGHT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); AdjustControlSize(IDC_RADIO_HEAD); AdjustControlSize(IDC_RADIO_BRANCH); AdjustControlSize(IDC_RADIO_TAGS); AdjustControlSize(IDC_RADIO_VERSION); CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); CHOOSE_VERSION_ADDANCHOR; this->AddOthersToAnchor(); Init(); if(this->m_Revision.IsEmpty()) { SetDefaultChoose(IDC_RADIO_HEAD); } else { SetDefaultChoose(IDC_RADIO_VERSION); this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Revision); } m_tooltips.Create(this); m_tooltips.AddTool(IDC_EXPORTFILE, IDS_EXPORTFILE_TT); SHAutoComplete(GetDlgItem(IDC_EXPORTFILE)->m_hWnd, SHACF_FILESYSTEM); if ((m_pParentWnd==NULL)&&(hWndExplorer)) CenterWindow(CWnd::FromHandle(hWndExplorer)); EnableSaveRestore(_T("ExportDlg")); return TRUE; }
BOOL CSettingsProgsMerge::OnInitDialog() { ISettingsPropPage::OnInitDialog(); EnableToolTips(); m_sMergePath = m_regMergePath; m_iExtMerge = IsExternal(m_sMergePath); SHAutoComplete(::GetDlgItem(m_hWnd, IDC_EXTMERGE), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY); m_tooltips.Create(this); m_tooltips.AddTool(IDC_EXTMERGE, IDS_SETTINGS_EXTMERGE_TT); UpdateData(FALSE); return TRUE; }
HRESULT STDMETHODCALLTYPE CAddressEditBox::Init(HWND comboboxEx, HWND editControl, long param14, IUnknown *param18) { CComPtr<IBrowserService> browserService; fCombobox.SubclassWindow(comboboxEx); fEditWindow.SubclassWindow(editControl); fSite = param18; SHAutoComplete(fEditWindow.m_hWnd, SHACF_FILESYSTEM | SHACF_URLALL | SHACF_USETAB); // take advice to watch events HRESULT hResult = IUnknown_QueryService(param18, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService)); if (SUCCEEDED(hResult)) { hResult = AtlAdvise(browserService, static_cast<IDispatch *>(this), DIID_DWebBrowserEvents, &fAdviseCookie); } return hResult; }
BOOL CSettingsProgsAlternativeEditor::OnInitDialog() { ISettingsPropPage::OnInitDialog(); AdjustControlSize(IDC_ALTERNATIVEEDITOR_OFF); AdjustControlSize(IDC_ALTERNATIVEEDITOR_ON); EnableToolTips(); m_sAlternativeEditorPath = m_regAlternativeEditorPath; m_iAlternativeEditor = IsExternal(m_sAlternativeEditorPath); SHAutoComplete(::GetDlgItem(m_hWnd, IDC_ALTERNATIVEEDITOR), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY); m_tooltips.AddTool(IDC_ALTERNATIVEEDITOR, IDS_SETTINGS_ALTERNATIVEEDITOR_TT); UpdateData(FALSE); return TRUE; }
BOOL CRenameDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); SHAutoComplete(GetDlgItem(IDC_NAME)->m_hWnd, SHACF_DEFAULT); if (!m_windowtitle.IsEmpty()) this->SetWindowText(m_windowtitle); if (!m_label.IsEmpty()) SetDlgItemText(IDC_LABEL, m_label); AddAnchor(IDC_LABEL, TOP_LEFT); AddAnchor(IDC_NAME, TOP_LEFT, TOP_RIGHT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); if (hWndExplorer) CenterWindow(CWnd::FromHandle(hWndExplorer)); EnableSaveRestore(_T("RenameDlg")); GetDlgItem(IDOK)->EnableWindow(FALSE); return TRUE; }
BOOL CCloneDlg::OnInitDialog() { CHorizontalResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_CLONE_BROWSE_URL, TOP_RIGHT); AddAnchor(IDC_CLONE_DIR, TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_CLONE_DIR_BROWSE, TOP_RIGHT); AddAnchor(IDOK,BOTTOM_RIGHT); AddAnchor(IDCANCEL,BOTTOM_RIGHT); AddAnchor(IDC_GROUP_CLONE,TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_PUTTYKEYFILE_BROWSE,TOP_RIGHT); AddAnchor(IDC_PUTTYKEY_AUTOLOAD,TOP_LEFT); AddAnchor(IDC_PUTTYKEYFILE,TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_CLONE_GROUP_SVN,TOP_LEFT,TOP_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); AdjustControlSize(IDC_CHECK_DEPTH); AdjustControlSize(IDC_CHECK_RECURSIVE); AdjustControlSize(IDC_CHECK_BARE); AdjustControlSize(IDC_PUTTYKEY_AUTOLOAD); AdjustControlSize(IDC_CHECK_SVN); AdjustControlSize(IDC_CHECK_SVN_TRUNK); AdjustControlSize(IDC_CHECK_SVN_TAG); AdjustControlSize(IDC_CHECK_SVN_BRANCH); AdjustControlSize(IDC_CHECK_SVN_FROM); AdjustControlSize(IDC_CHECK_USERNAME); CString tt; tt.LoadString(IDS_CLONE_DEPTH_TT); m_tooltips.AddTool(IDC_EDIT_DEPTH,tt); m_tooltips.AddTool(IDC_CHECK_DEPTH,tt); this->AddOthersToAnchor(); if (m_Directory.IsEmpty()) { CString dir = m_regCloneDir; int index = dir.ReverseFind('\\'); if (index >= 0) dir = dir.Left(index); m_Directory = dir; } if (m_Directory.IsEmpty()) { TCHAR szPath[MAX_PATH] = {0}; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, szPath))) m_Directory = szPath; } UpdateData(FALSE); m_URLCombo.SetCaseSensitive(TRUE); m_URLCombo.SetURLHistory(TRUE); m_URLCombo.LoadHistory(_T("Software\\TortoiseGit\\History\\repoURLS"), _T("url")); if(m_URL.IsEmpty()) { CString str = CAppUtils::GetClipboardLink(_T("git clone ")); str.Trim(); if(str.IsEmpty()) m_URLCombo.SetCurSel(0); else m_URLCombo.SetWindowText(str); } else m_URLCombo.SetWindowText(m_URL); CWnd *window=this->GetDlgItem(IDC_CLONE_DIR); if(window) SHAutoComplete(window->m_hWnd, SHACF_FILESYSTEM); this->m_BrowseUrl.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_CLONE_DIR))); this->m_BrowseUrl.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_CLONE_WEB))); m_BrowseUrl.SetCurrentEntry(m_regBrowseUrl); m_PuttyKeyCombo.SetPathHistory(TRUE); m_PuttyKeyCombo.LoadHistory(_T("Software\\TortoiseGit\\History\\puttykey"), _T("key")); m_PuttyKeyCombo.SetCurSel(0); this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow( CAppUtils::IsSSHPutty() ); this->GetDlgItem(IDC_PUTTYKEYFILE)->EnableWindow(m_bAutoloadPuttyKeyFile); this->GetDlgItem(IDC_PUTTYKEYFILE_BROWSE)->EnableWindow(m_bAutoloadPuttyKeyFile); EnableSaveRestore(_T("CloneDlg")); OnBnClickedCheckSvn(); OnBnClickedCheckDepth(); OnBnClickedCheckBranch(); OnBnClickedCheckOrigin(); return TRUE; // return TRUE unless you set the focus to a control }
BOOL CExportDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); ExtendFrameIntoClientArea(IDC_REVISIONGROUP); m_aeroControls.SubclassOkCancelHelp(this); m_sExportDirOrig = m_strExportDirectory; m_bAutoCreateTargetName = !(PathIsDirectoryEmpty(m_sExportDirOrig) || !PathFileExists(m_sExportDirOrig)); AdjustControlSize(IDC_NOEXTERNALS); AdjustControlSize(IDC_IGNOREKEYWORDS); AdjustControlSize(IDC_REVISION_HEAD); AdjustControlSize(IDC_REVISION_N); AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_REPOLABEL, TOP_LEFT); AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_BROWSE, TOP_RIGHT); AddAnchor(IDC_EXPORT_CHECKOUTDIR, TOP_LEFT); AddAnchor(IDC_CHECKOUTDIRECTORY, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_CHECKOUTDIRECTORY_BROWSE, TOP_RIGHT); AddAnchor(IDC_DEPTH, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_NOEXTERNALS, TOP_LEFT); AddAnchor(IDC_IGNOREKEYWORDS, TOP_LEFT); AddAnchor(IDC_EOLLABEL, TOP_LEFT); AddAnchor(IDC_EOLCOMBO, TOP_LEFT); AddAnchor(IDC_REVISIONGROUP, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_REVISION_HEAD, TOP_LEFT); AddAnchor(IDC_REVISION_N, TOP_LEFT); AddAnchor(IDC_REVISION_NUM, TOP_LEFT); AddAnchor(IDC_SHOW_LOG, TOP_LEFT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); // save the provided url since the url combo // will change that below CString origurl = m_URL; m_URLCombo.SetURLHistory(true, true); m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoURLS", L"url"); m_URLCombo.SetCurSel(0); m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_INFINITE))); m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_IMMEDIATE))); m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_FILES))); m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_EMPTY))); m_depthCombo.SetCurSel(0); // set radio buttons according to the revision SetRevision(Revision); m_editRevision.SetWindowText(L""); if (!origurl.IsEmpty()) m_URLCombo.SetWindowText(origurl); else { // if there is an url on the clipboard, use that url as the default. CAppUtils::AddClipboardUrlToWindow(m_URLCombo.GetSafeHwnd()); } GetDlgItem(IDC_BROWSE)->EnableWindow(!m_URLCombo.GetString().IsEmpty()); m_tooltips.AddTool(IDC_CHECKOUTDIRECTORY, IDS_CHECKOUT_TT_DIR); m_tooltips.AddTool(IDC_EOLCOMBO, IDS_EXPORT_TT_EOL); SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY)->m_hWnd, SHACF_FILESYSTEM); // fill the combobox with the choices of eol styles m_eolCombo.AddString(L"default"); m_eolCombo.AddString(L"CRLF"); m_eolCombo.AddString(L"LF"); m_eolCombo.AddString(L"CR"); m_eolCombo.SelectString(0, L"default"); if (!Revision.IsHead()) { // if the revision is not HEAD, change the radio button and // fill in the revision in the edit box CString temp; temp.Format(L"%ld", (LONG)Revision); m_editRevision.SetWindowText(temp); CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N); } DialogEnableWindow(IDOK, !m_strExportDirectory.IsEmpty()); if ((m_pParentWnd==NULL)&&(GetExplorerHWND())) CenterWindow(CWnd::FromHandle(GetExplorerHWND())); EnableSaveRestore(L"ExportDlg"); return TRUE; }
// CSetDialogs message handlers BOOL CSetDialogs::OnInitDialog() { CMFCFontComboBox::m_bDrawUsingFont = true; ISettingsPropPage::OnInitDialog(); EnableToolTips(); int ind = m_cAutoClose.AddString(CString(MAKEINTRESOURCE(IDS_PROGRS_CLOSE_MANUAL))); m_cAutoClose.SetItemData(ind, CLOSE_MANUAL); ind = m_cAutoClose.AddString(CString(MAKEINTRESOURCE(IDS_PROGRS_CLOSE_NOMERGES))); m_cAutoClose.SetItemData(ind, CLOSE_NOMERGES); ind = m_cAutoClose.AddString(CString(MAKEINTRESOURCE(IDS_PROGRS_CLOSE_NOCONFLICTS))); m_cAutoClose.SetItemData(ind, CLOSE_NOCONFLICTS); ind = m_cAutoClose.AddString(CString(MAKEINTRESOURCE(IDS_PROGRS_CLOSE_NOERROR))); m_cAutoClose.SetItemData(ind, CLOSE_NOERRORS); m_dwAutoClose = m_regAutoClose; m_bAutoCloseLocal = m_regAutoCloseLocal; m_bShortDateFormat = m_regShortDateFormat; m_bUseSystemLocaleForDates = m_regUseSystemLocaleForDates; m_sFontName = m_regFontName; m_dwFontSize = m_regFontSize; m_bUseWCURL = m_regUseWCURL; m_sDefaultCheckoutPath = m_regDefaultCheckoutPath; m_sDefaultCheckoutUrl = m_regDefaultCheckoutUrl; m_bDiffByDoubleClick = m_regDiffByDoubleClick; m_bUseRecycleBin = m_regUseRecycleBin; SHAutoComplete(GetDlgItem(IDC_CHECKOUTPATH)->m_hWnd, SHACF_FILESYSTEM); SHAutoComplete(GetDlgItem(IDC_CHECKOUTURL)->m_hWnd, SHACF_URLALL); for (int i=0; i<m_cAutoClose.GetCount(); ++i) if (m_cAutoClose.GetItemData(i)==m_dwAutoClose) m_cAutoClose.SetCurSel(i); CString temp; temp.Format(L"%ld", (DWORD)m_regDefaultLogs); m_sDefaultLogs = temp; m_tooltips.AddTool(IDC_SHORTDATEFORMAT, IDS_SETTINGS_SHORTDATEFORMAT_TT); m_tooltips.AddTool(IDC_SYSTEMLOCALEFORDATES, IDS_SETTINGS_USESYSTEMLOCALEFORDATES_TT); m_tooltips.AddTool(IDC_AUTOCLOSECOMBO, IDS_SETTINGS_AUTOCLOSE_TT); m_tooltips.AddTool(IDC_WCURLFROM, IDS_SETTINGS_USEWCURL_TT); m_tooltips.AddTool(IDC_CHECKOUTPATHLABEL, IDS_SETTINGS_CHECKOUTPATH_TT); m_tooltips.AddTool(IDC_CHECKOUTPATH, IDS_SETTINGS_CHECKOUTPATH_TT); m_tooltips.AddTool(IDC_CHECKOUTURLLABEL, IDS_SETTINGS_CHECKOUTURL_TT); m_tooltips.AddTool(IDC_CHECKOUTURL, IDS_SETTINGS_CHECKOUTURL_TT); m_tooltips.AddTool(IDC_DIFFBYDOUBLECLICK, IDS_SETTINGS_DIFFBYDOUBLECLICK_TT); m_tooltips.AddTool(IDC_USERECYCLEBIN, IDS_SETTINGS_USERECYCLEBIN_TT); int count = 0; for (int i=6; i<32; i=i+2) { temp.Format(L"%d", i); m_cFontSizes.AddString(temp); m_cFontSizes.SetItemData(count++, i); } BOOL foundfont = FALSE; for (int i=0; i<m_cFontSizes.GetCount(); i++) { if (m_cFontSizes.GetItemData(i) == m_dwFontSize) { m_cFontSizes.SetCurSel(i); foundfont = TRUE; } } if (!foundfont) { temp.Format(L"%lu", m_dwFontSize); m_cFontSizes.SetWindowText(temp); } m_cFontNames.Setup(DEVICE_FONTTYPE|RASTER_FONTTYPE|TRUETYPE_FONTTYPE, 1, FIXED_PITCH); m_cFontNames.SelectFont(m_sFontName); UpdateData(FALSE); return TRUE; }
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct FileDlgData *dat; dat = (struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR szPath[450]; CLISTEVENT* cle = (CLISTEVENT*)lParam; dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = cle->hContact; dat->hDbEvent = cle->hDbEvent; dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); for (int i=0; i < MAX_MRU_DIRS; i++) { char idstr[32]; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", idstr, &dbv)) break; SendDlgItemMessage(hwndDlg, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal); db_free(&dbv); } db_event_markRead(dat->hContact, dat->hDbEvent); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) { dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1); db_event_get(dat->hDbEvent, &dbei); dbei.pBlob[dbei.cbBlob] = 0; dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; char *str = (char*)dbei.pBlob + 4; ptrT ptszFileName( DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); unsigned len = (unsigned)strlen(str) + 1; if (len + 4 < dbei.cbBlob) { str += len; ptrT ptszDescription( DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); } } else DestroyWindow(hwndDlg); TCHAR datetimestr[64]; tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); char* szProto = GetContactProto(dat->hContact); if (szProto) { int hasName = 0; char buf[128]; CONTACTINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch(ci.type) { case CNFT_ASCIIZ: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal); mir_free(ci.pszVal); break; case CNFT_DWORD: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; } } if (hasName) SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) { RECT rcBtn1, rcBtn2, rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2); GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl); SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right-rcDateCtrl.left-(rcBtn2.left-rcBtn1.left), rcDateCtrl.bottom-rcDateCtrl.top, SWP_NOZORDER|SWP_NOMOVE); } else if (db_get_b(NULL, "SRFile", "AutoAccept", 0)) { //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } return TRUE; case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_FILEDIRBROWSE: { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName)); GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName)); if (BrowseForFolder(hwndDlg, szExistingDirName)) SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } break; case IDOK: { //most recently used directories TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir)); RemoveInvalidPathChars(szRecvDir); GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE); if (_tcsnicmp(szRecvDir, szDefaultRecvDir, lstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; for (i = MAX_MRU_DIRS-2; i>=0; i--) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); if (db_get_ts(NULL, "SRFile", idstr, &dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i+1); db_set_ts(NULL, "SRFile", idstr, dbv.ptszVal); db_free(&dbv); } db_set_ts(NULL, "SRFile", idstr, szRecvDir); } } EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAMES), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 if (db_get_b(NULL, "SRFile", "AutoAccept", 0) && db_get_b(NULL, "SRFile", "AutoMin", 0)) { ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); } DestroyWindow(hwndDlg); break; case IDCANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENYT, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled")); dat->fs = NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = {0}; acs.handle = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); if (dat) FreeFileDlgData(dat); break; } return FALSE; }
BOOL CSetProxyPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); m_tooltips.Create(this); m_tooltips.AddTool(IDC_SERVERADDRESS, IDS_SETTINGS_PROXYSERVER_TT); CString proxy = g_Git.GetConfigValue(_T("http.proxy"), CP_UTF8); m_SSHClient = m_regSSHClient; m_serveraddress = m_regServeraddress; m_serverport = _ttoi((LPCTSTR)(CString)m_regServerport); m_username = m_regUsername; m_password = m_regPassword; if (proxy.IsEmpty()) { m_isEnabled = FALSE; EnableGroup(FALSE); } else { int start=0; start = proxy.Find(_T("://"),start); if(start<0) start =0; else start+=3; int at = proxy.Find(_T("@"), 0); int port; if(at<0) { m_username=_T(""); m_password=_T(""); port=proxy.Find(_T(":"),start); if(port<0) m_serveraddress = proxy.Mid(start); else m_serveraddress = proxy.Mid(start, port-start); } else { int username; username = proxy.Find(_T(":"),start); if(username<=0 || username >at) { StringUnescape(proxy.Mid(start, at - start), &m_username); m_password=_T(""); } else if(username < at) { StringUnescape(proxy.Mid(start, username - start), &m_username); StringUnescape(proxy.Mid(username + 1, at - username - 1), &m_password); } port=proxy.Find(_T(":"),at); if(port<0) m_serveraddress = proxy.Mid(at+1); else m_serveraddress = proxy.Mid(at+1, port-at-1); } if(port<0) { m_serverport= 0; } else m_serverport = _ttoi(proxy.Mid(port+1)); m_isEnabled = TRUE; EnableGroup(TRUE); } SHAutoComplete(::GetDlgItem(m_hWnd, IDC_SSHCLIENT), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY); UpdateData(FALSE); return TRUE; }
BOOL CSetMainPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); // disable features that have not yet been implemented GetDlgItem(IDC_CHECKNEWERVERSION)->EnableWindow( FALSE ); GetDlgItem(IDC_CHECKNEWERBUTTON)->EnableWindow( FALSE ); GetDlgItem(IDC_SOUNDS)->EnableWindow( FALSE ); GetDlgItem(IDC_SOUNDS_TEXT)->EnableWindow( FALSE ); EnableToolTips(); m_sMsysGitPath = m_regMsysGitPath; m_dwLanguage = m_regLanguage; m_bCheckNewer = m_regCheckNewer; CString temp; temp = m_regLastCommitTime; m_bLastCommitTime = (temp.CompareNoCase(_T("yes"))==0); m_tooltips.Create(this); m_tooltips.AddTool(IDC_MSYSGIT_PATH,IDS_MSYSGIT_PATH_TT); //m_tooltips.AddTool(IDC_CHECKNEWERVERSION, IDS_SETTINGS_CHECKNEWER_TT); //m_tooltips.AddTool(IDC_COMMITFILETIMES, IDS_SETTINGS_COMMITFILETIMES_TT); //m_tooltips.AddTool(IDC_ASPDOTNETHACK, IDS_SETTINGS_DOTNETHACK_TT); // set up the language selecting combobox SHAutoComplete(GetDlgItem(IDC_MSYSGIT_PATH)->m_hWnd, SHACF_FILESYSTEM); TCHAR buf[MAX_PATH]; GetLocaleInfo(1033, LOCALE_SNATIVELANGNAME, buf, sizeof(buf)/sizeof(TCHAR)); m_LanguageCombo.AddString(buf); m_LanguageCombo.SetItemData(0, 1033); CString path = CPathUtils::GetAppParentDirectory(); path = path + _T("Languages\\"); CSimpleFileFind finder(path, _T("*.dll")); int langcount = 1; while (finder.FindNextFileNoDirectories()) { CString file = finder.GetFilePath(); CString filename = finder.GetFileName(); if (filename.Left(12).CompareNoCase(_T("TortoiseProc"))==0) { CString sVer = _T(STRPRODUCTVER); sVer = sVer.Left(sVer.ReverseFind(',')); CString sFileVer = CPathUtils::GetVersionFromFile(file); sFileVer = sFileVer.Left(sFileVer.ReverseFind(',')); if (sFileVer.Compare(sVer)!=0) continue; DWORD loc = _tstoi(filename.Mid(12)); TCHAR buf[MAX_PATH]; GetLocaleInfo(loc, LOCALE_SNATIVELANGNAME, buf, sizeof(buf)/sizeof(TCHAR)); m_LanguageCombo.AddString(buf); m_LanguageCombo.SetItemData(langcount++, loc); } } for (int i=0; i<m_LanguageCombo.GetCount(); i++) { if (m_LanguageCombo.GetItemData(i) == m_dwLanguage) m_LanguageCombo.SetCurSel(i); } UpdateData(FALSE); return TRUE; }
BOOL CSetProxyPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); m_tooltips.Create(this); m_tooltips.AddTool(IDC_SERVERADDRESS, IDS_SETTINGS_PROXYSERVER_TT); CString proxy = g_Git.GetConfigValue(_T("http.proxy"), CP_UTF8); m_SSHClient = m_regSSHClient; if (m_SSHClient.IsEmpty()) m_SSHClient = CRegString(_T("Software\\TortoiseGit\\SSH"), _T(""), FALSE, HKEY_LOCAL_MACHINE); if (m_SSHClient.IsEmpty()) { TCHAR sPlink[MAX_PATH]; GetModuleFileName(NULL, sPlink, _countof(sPlink)); LPTSTR ptr = _tcsrchr(sPlink, _T('\\')); if (ptr) { _tcscpy_s(ptr + 1, MAX_PATH - (ptr - sPlink + 1), _T("TortoiseGitPLink.exe")); m_SSHClient = CString(sPlink); } } m_serveraddress = m_regServeraddress; m_serverport = _ttoi((LPCTSTR)(CString)m_regServerport); m_username = m_regUsername; m_password = m_regPassword; if (proxy.IsEmpty()) { m_isEnabled = FALSE; EnableGroup(FALSE); } else { int start=0; start = proxy.Find(_T("://"),start); if(start<0) start =0; else start+=3; int at = proxy.Find(_T("@"), 0); int port; if(at<0) { m_username=_T(""); m_password=_T(""); port=proxy.Find(_T(":"),start); if(port<0) m_serveraddress = proxy.Mid(start); else m_serveraddress = proxy.Mid(start, port-start); } else { int username; username = proxy.Find(_T(":"),start); if(username<=0 || username >at) { StringUnescape(proxy.Mid(start, at - start), &m_username); m_password=_T(""); } else if(username < at) { StringUnescape(proxy.Mid(start, username - start), &m_username); StringUnescape(proxy.Mid(username + 1, at - username - 1), &m_password); } port=proxy.Find(_T(":"),at); if(port<0) m_serveraddress = proxy.Mid(at+1); else m_serveraddress = proxy.Mid(at+1, port-at-1); } if(port<0) { m_serverport= 0; } else m_serverport = _ttoi(proxy.Mid(port+1)); m_isEnabled = TRUE; EnableGroup(TRUE); } SHAutoComplete(::GetDlgItem(m_hWnd, IDC_SSHCLIENT), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY); UpdateData(FALSE); return TRUE; }
BOOL CSetMainPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); EnableToolTips(); AdjustControlSize(IDC_CHECKNEWERVERSION); m_dwLanguage = m_regLanguage; m_bCheckNewer = m_regCheckNewer; m_tooltips.AddTool(IDC_MSYSGIT_PATH,IDS_MSYSGIT_PATH_TT); m_tooltips.AddTool(IDC_MSYSGIT_EXTERN_PATH, IDS_EXTRAPATH_TT); m_tooltips.AddTool(IDC_CHECKNEWERVERSION, IDS_SETTINGS_CHECKNEWER_TT); m_tooltips.AddTool(IDC_CREATELIB, IDS_SETTINGS_CREATELIB_TT); SHAutoComplete(GetDlgItem(IDC_MSYSGIT_PATH)->m_hWnd, SHACF_FILESYSTEM); // set up the language selecting combobox TCHAR buf[MAX_PATH] = {0}; GetLocaleInfo(1033, LOCALE_SNATIVELANGNAME, buf, _countof(buf)); m_LanguageCombo.AddString(buf); m_LanguageCombo.SetItemData(0, 1033); CString path = CPathUtils::GetAppParentDirectory(); path = path + L"Languages\\"; CSimpleFileFind finder(path, L"*.dll"); int langcount = 1; while (finder.FindNextFileNoDirectories()) { CString file = finder.GetFilePath(); CString filename = finder.GetFileName(); if (CStringUtils::StartsWithI(filename, L"TortoiseProc")) { CString sVer = _T(STRPRODUCTVER); sVer = sVer.Left(sVer.ReverseFind('.')); CString sFileVer = CPathUtils::GetVersionFromFile(file); sFileVer = sFileVer.Left(sFileVer.ReverseFind('.')); if (sFileVer.Compare(sVer)!=0) continue; CString sLoc = filename.Mid((int)wcslen(L"TortoiseProc")); sLoc = sLoc.Left(sLoc.GetLength() - (int)wcslen(L".dll")); // cut off ".dll" if (CStringUtils::StartsWith(sLoc, L"32") && (sLoc.GetLength() > 5)) continue; DWORD loc = _wtoi(filename.Mid((int)wcslen(L"TortoiseProc"))); GetLocaleInfo(loc, LOCALE_SNATIVELANGNAME, buf, _countof(buf)); CString sLang = buf; GetLocaleInfo(loc, LOCALE_SNATIVECTRYNAME, buf, _countof(buf)); if (buf[0]) { sLang += L" ("; sLang += buf; sLang += L')'; } m_LanguageCombo.AddString(sLang); m_LanguageCombo.SetItemData(langcount++, loc); } } for (int i=0; i<m_LanguageCombo.GetCount(); i++) { if (m_LanguageCombo.GetItemData(i) == m_dwLanguage) m_LanguageCombo.SetCurSel(i); } UpdateData(FALSE); return TRUE; }
INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static HWND hwndParent, hwndDragOver; static int dragging; static int dragItem, dropHiLite; static HWND hPreview = NULL; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); hwndParent = (HWND)lParam; hPreview = GetDlgItem(hwndDlg, IDC_PREVIEW); dragging = dragItem = 0; ListView_SetImageList(hPreview, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 0, 100), LVSIL_NORMAL); ListView_SetIconSpacing(hPreview, 56, 67); { RECT rcThis, rcParent; int cxScreen = GetSystemMetrics(SM_CXSCREEN); GetWindowRect(hwndDlg, &rcThis); GetWindowRect(hwndParent, &rcParent); OffsetRect(&rcThis, rcParent.right-rcThis.left, 0); OffsetRect(&rcThis, 0, rcParent.top-rcThis.top); GetWindowRect(GetParent(hwndParent), &rcParent); if (rcThis.right > cxScreen) { OffsetRect(&rcParent, cxScreen-rcThis.right, 0); OffsetRect(&rcThis, cxScreen-rcThis.right, 0); MoveWindow(GetParent(hwndParent), rcParent.left, rcParent.top, rcParent.right-rcParent.left, rcParent.bottom-rcParent.top, TRUE); } MoveWindow(hwndDlg, rcThis.left, rcThis.top, rcThis.right-rcThis.left, rcThis.bottom-rcThis.top, FALSE); GetClientRect(hwndDlg, &rcThis); SendMessage(hwndDlg, WM_SIZE, 0, MAKELPARAM(rcThis.right-rcThis.left, rcThis.bottom-rcThis.top)); } SHAutoComplete( GetDlgItem(hwndDlg, IDC_ICONSET), 1); SetDlgItemText(hwndDlg, IDC_ICONSET, _T("icons.dll")); return TRUE; case DM_REBUILDICONSPREVIEW: { MySetCursor(IDC_WAIT); ListView_DeleteAllItems(hPreview); HIMAGELIST hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL); ImageList_RemoveAll(hIml); TCHAR filename[MAX_PATH], caption[64]; GetDlgItemText(hwndDlg, IDC_ICONSET, filename, SIZEOF(filename)); { RECT rcPreview, rcGroup; GetWindowRect(hPreview, &rcPreview); GetWindowRect( GetDlgItem(hwndDlg, IDC_IMPORTMULTI), &rcGroup); //SetWindowPos(hPreview, 0, 0, 0, rcPreview.right-rcPreview.left, rcGroup.bottom-rcPreview.top, SWP_NOZORDER|SWP_NOMOVE); } if ( _taccess(filename, 0) != 0) { MySetCursor(IDC_ARROW); break; } LVITEM lvi; lvi.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; lvi.iSubItem = 0; lvi.iItem = 0; int count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR); for (int i=0; i < count; lvi.iItem++, i++) { mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i+1); lvi.pszText = caption; HICON hIcon; _ExtractIconEx(filename, i, 16, 16, &hIcon, LR_DEFAULTCOLOR); lvi.iImage = ImageList_AddIcon(hIml, hIcon); DestroyIcon(hIcon); lvi.lParam = i; ListView_InsertItem(hPreview, &lvi); } MySetCursor(IDC_ARROW); } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_BROWSE: { TCHAR str[MAX_PATH], *file; GetDlgItemText(hwndDlg, IDC_ICONSET, str, SIZEOF(str)); if (!(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE))) break; SetDlgItemText(hwndDlg, IDC_ICONSET, file); SAFE_FREE((void**)&file); } break; case IDC_GETMORE: OpenIconsPage(); break; case IDC_ICONSET: if (HIWORD(wParam) == EN_CHANGE) SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, 0); break; } break; case WM_MOUSEMOVE: if (dragging) { LVHITTESTINFO lvhti; int onItem = 0; HWND hwndOver; RECT rc; POINT ptDrag; HWND hPPreview = GetDlgItem(hwndParent, IDC_PREVIEW); lvhti.pt.x = (short)LOWORD(lParam); lvhti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &lvhti.pt); hwndOver = WindowFromPoint(lvhti.pt); GetWindowRect(hwndOver, &rc); ptDrag.x = lvhti.pt.x - rc.left; ptDrag.y = lvhti.pt.y - rc.top; if (hwndOver != hwndDragOver) { ImageList_DragLeave(hwndDragOver); hwndDragOver = hwndOver; ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y); } ImageList_DragMove(ptDrag.x, ptDrag.y); if (hwndOver == hPPreview) { ScreenToClient(hPPreview, &lvhti.pt); if (ListView_HitTest(hPPreview, &lvhti) != -1) { if (lvhti.iItem != dropHiLite) { ImageList_DragLeave(hwndDragOver); if (dropHiLite != -1) ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED); dropHiLite = lvhti.iItem; ListView_SetItemState(hPPreview, dropHiLite, LVIS_DROPHILITED, LVIS_DROPHILITED); UpdateWindow(hPPreview); ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y); } onItem = 1; } } if (!onItem && dropHiLite != -1) { ImageList_DragLeave(hwndDragOver); ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED); UpdateWindow(hPPreview); ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y); dropHiLite = -1; } MySetCursor(onItem ? IDC_ARROW : IDC_NO); } break; case WM_LBUTTONUP: if (dragging) { ReleaseCapture(); ImageList_EndDrag(); dragging = 0; if (dropHiLite != -1) { TCHAR path[MAX_PATH], fullPath[MAX_PATH], filename[MAX_PATH]; LVITEM lvi; GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, SIZEOF(fullPath)); PathToRelativeT(fullPath, filename); lvi.mask = LVIF_PARAM; lvi.iItem = dragItem; lvi.iSubItem = 0; ListView_GetItem(hPreview, &lvi); mir_sntprintf(path, SIZEOF(path), _T("%s,%d"), filename, (int)lvi.lParam); SendMessage(hwndParent, DM_CHANGEICON, dropHiLite, (LPARAM)path); ListView_SetItemState( GetDlgItem(hwndParent, IDC_PREVIEW), dropHiLite, 0, LVIS_DROPHILITED); } } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_PREVIEW: switch (((LPNMHDR)lParam)->code) { case LVN_BEGINDRAG: SetCapture(hwndDlg); dragging = 1; dragItem = ((LPNMLISTVIEW)lParam)->iItem; dropHiLite = -1; ImageList_BeginDrag(ListView_GetImageList(hPreview, LVSIL_NORMAL), dragItem, GetSystemMetrics(SM_CXICON)/2, GetSystemMetrics(SM_CYICON)/2); { POINT pt; RECT rc; GetCursorPos(&pt); GetWindowRect(hwndDlg, &rc); ImageList_DragEnter(hwndDlg, pt.x - rc.left, pt.y - rc.top); hwndDragOver = hwndDlg; } break; } break; } break; case WM_SIZE: // make the dlg resizeable if (!IsIconic(hwndDlg)) { UTILRESIZEDIALOG urd = {0}; urd.cbSize = sizeof(urd); urd.hInstance = hInst; urd.hwndDlg = hwndDlg; urd.lParam = 0; // user-defined urd.lpTemplate = MAKEINTRESOURCEA(IDD_ICOLIB_IMPORT); urd.pfnResizer = IconDlg_Resize; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); } break; case WM_CLOSE: DestroyWindow(hwndDlg); EnableWindow( GetDlgItem(hwndParent, IDC_IMPORT), TRUE); break; } return FALSE; }
BOOL CSetMainPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); // disable features that have not yet been implemented GetDlgItem(IDC_SOUNDS)->EnableWindow( FALSE ); GetDlgItem(IDC_SOUNDS_TEXT)->EnableWindow( FALSE ); EnableToolTips(); m_dwLanguage = m_regLanguage; m_bCheckNewer = m_regCheckNewer; m_tooltips.Create(this); m_tooltips.AddTool(IDC_MSYSGIT_PATH,IDS_MSYSGIT_PATH_TT); m_tooltips.AddTool(IDC_CHECKNEWERVERSION, IDS_SETTINGS_CHECKNEWER_TT); m_tooltips.AddTool(IDC_CREATELIB, IDS_SETTINGS_CREATELIB_TT); GetDlgItem(IDC_CREATELIB)->EnableWindow(SysInfo::Instance().IsWin7OrLater()); SHAutoComplete(GetDlgItem(IDC_MSYSGIT_PATH)->m_hWnd, SHACF_FILESYSTEM); // set up the language selecting combobox TCHAR buf[MAX_PATH]; GetLocaleInfo(1033, LOCALE_SNATIVELANGNAME, buf, _countof(buf)); m_LanguageCombo.AddString(buf); m_LanguageCombo.SetItemData(0, 1033); CString path = CPathUtils::GetAppParentDirectory(); path = path + _T("Languages\\"); CSimpleFileFind finder(path, _T("*.dll")); int langcount = 1; while (finder.FindNextFileNoDirectories()) { CString file = finder.GetFilePath(); CString filename = finder.GetFileName(); if (filename.Left(12).CompareNoCase(_T("TortoiseProc"))==0) { CString sVer = _T(STRPRODUCTVER); sVer = sVer.Left(sVer.ReverseFind(',')); CString sFileVer = CPathUtils::GetVersionFromFile(file); sFileVer = sFileVer.Left(sFileVer.ReverseFind(',')); if (sFileVer.Compare(sVer)!=0) continue; CString sLoc = filename.Mid(12); sLoc = sLoc.Left(sLoc.GetLength()-4); // cut off ".dll" if ((sLoc.Left(2) == L"32")&&(sLoc.GetLength() > 5)) continue; DWORD loc = _tstoi(filename.Mid(12)); GetLocaleInfo(loc, LOCALE_SNATIVELANGNAME, buf, _countof(buf)); CString sLang = buf; GetLocaleInfo(loc, LOCALE_SNATIVECTRYNAME, buf, _countof(buf)); if (buf[0]) { sLang += _T(" ("); sLang += buf; sLang += _T(")"); } m_LanguageCombo.AddString(sLang); m_LanguageCombo.SetItemData(langcount++, loc); } } for (int i=0; i<m_LanguageCombo.GetCount(); i++) { if (m_LanguageCombo.GetItemData(i) == m_dwLanguage) m_LanguageCombo.SetCurSel(i); } UpdateData(FALSE); return TRUE; }
static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS); TCHAR str[MAX_PATH]; GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE); SetDlgItemText(hwndDlg, IDC_FILEDIR, str); CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, db_get_b(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOMIN, db_get_b(NULL, "SRFile", "AutoMin", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, db_get_b(NULL, "SRFile", "AutoClose", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, db_get_b(NULL, "SRFile", "AutoClear", 1) ? BST_CHECKED : BST_UNCHECKED); switch (db_get_b(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE)) { case VIRUSSCAN_AFTERDL: CheckDlgButton(hwndDlg, IDC_SCANAFTERDL, BST_CHECKED); break; case VIRUSSCAN_DURINGDL: CheckDlgButton(hwndDlg, IDC_SCANDURINGDL, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_NOSCANNER, BST_CHECKED); break; } CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED); for (int i = 0; i < _countof(virusScanners); i++) { TCHAR szScanExe[MAX_PATH]; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(szScanExe))) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i); } } if (SendDlgItemMessageA(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0) { int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T("")); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1); } DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", "ScanCmdLine", &dbv) == 0) { SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, dbv.ptszVal); db_free(&dbv); } else if (SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) { SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0); PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); } switch (db_get_b(NULL, "SRFile", "IfExists", FILERESUME_ASK)) { case FILERESUME_RESUMEALL: CheckDlgButton(hwndDlg, IDC_RESUME, BST_CHECKED); break; case FILERESUME_OVERWRITEALL: CheckDlgButton(hwndDlg, IDC_OVERWRITE, BST_CHECKED); break; case FILERESUME_RENAMEALL: CheckDlgButton(hwndDlg, IDC_RENAME, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_ASK, BST_CHECKED); break; } SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); } return TRUE; case M_UPDATEENABLING: { int on = BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINEBROWSE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINEHELP), on); EnableWindow(GetDlgItem(hwndDlg, IDC_AUTOMIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); } break; case M_SCANCMDLINESELCHANGE: { TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); if (iScanner >= _countof(virusScanners) || iScanner < 0) break; str[0] = '\0'; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe))) mir_sntprintf(str, virusScanners[iScanner].szCommandLine, szScanExe); SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_FILEDIR: if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; break; case IDC_FILEDIRBROWSE: { TCHAR str[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); if (BrowseForFolder(hwndDlg, str)) SetDlgItemText(hwndDlg, IDC_FILEDIR, str); } break; case IDC_AUTOACCEPT: case IDC_NOSCANNER: case IDC_SCANAFTERDL: case IDC_SCANDURINGDL: SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); break; case IDC_SCANCMDLINE: if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); else if (HIWORD(wParam) != CBN_EDITCHANGE) return 0; break; case IDC_SCANCMDLINEBROWSE: TCHAR str[MAX_PATH + 2]; GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); CMString tszFilter; tszFilter.AppendFormat(_T("%s (*.exe)%c*.exe%c"), TranslateT("Executable files"), 0, 0); tszFilter.AppendFormat(_T("%s (*)%c*%c"), TranslateT("All files"), 0, 0); OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; ofn.lpstrFilter = tszFilter; ofn.lpstrFile = str; ofn.nMaxFile = _countof(str) - 2; if (str[0] == '"') { TCHAR *pszQuote = _tcschr(str + 1, '"'); if (pszQuote) *pszQuote = 0; memmove(str, str + 1, (mir_tstrlen(str) * sizeof(TCHAR))); } else { TCHAR *pszSpace = _tcschr(str, ' '); if (pszSpace) *pszSpace = 0; } ofn.nMaxFileTitle = MAX_PATH; if (!GetOpenFileName(&ofn)) break; if (_tcschr(str, ' ') != NULL) { memmove(str + 1, str, ((_countof(str) - 2) * sizeof(TCHAR))); str[0] = '"'; mir_tstrcat(str, _T("\"")); } SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: TCHAR str[512]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str)); RemoveInvalidPathChars(str); db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str); db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); db_set_b(NULL, "SRFile", "AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN)); db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE)); db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR)); db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE))); GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str)); db_set_ts(NULL, "SRFile", "ScanCmdLine", str); db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING)); db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL)))); return TRUE; } break; } return FALSE; }
static INT_PTR APIENTRY OptSknWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { BOOL bEnable; char szPercent[20]; switch ( uMsg ) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); // Border CheckDlgButton(hwndDlg, IDC_DRAWBORDER, db_get_b(NULL, MODULE, "DrawBorder", FLT_DEFAULT_DRAWBORDER)); SendMessage(hwndDlg, M_REFRESHBORDERPICKERS, 0, 0); SendDlgItemMessage(hwndDlg, IDC_LTEDGESCOLOR, CPM_SETDEFAULTCOLOUR, 0, FLT_DEFAULT_LTEDGESCOLOR); SendDlgItemMessage(hwndDlg, IDC_LTEDGESCOLOR, CPM_SETCOLOUR, 0, db_get_dw(NULL, MODULE, "LTEdgesColor", FLT_DEFAULT_LTEDGESCOLOR)); SendDlgItemMessage(hwndDlg, IDC_RBEDGESCOLOR, CPM_SETDEFAULTCOLOUR, 0, FLT_DEFAULT_RBEDGESCOLOR); SendDlgItemMessage(hwndDlg, IDC_RBEDGESCOLOR, CPM_SETCOLOUR, 0, db_get_dw(NULL, MODULE, "RBEdgesColor", FLT_DEFAULT_RBEDGESCOLOR)); // Background CheckDlgButton(hwndDlg, IDC_CHK_WIDTH, (fcOpt.bFixedWidth ? BST_CHECKED : BST_UNCHECKED)); SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETDEFAULTCOLOUR, 0, FLT_DEFAULT_BKGNDCOLOR); SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETCOLOUR, 0, db_get_dw(NULL, MODULE, "BkColor", FLT_DEFAULT_BKGNDCOLOR)); CheckDlgButton(hwndDlg, IDC_BITMAP, db_get_b(NULL, MODULE, "BkUseBitmap", FLT_DEFAULT_BKGNDUSEBITMAP)); SendMessage(hwndDlg, M_REFRESHBKGBOXES, 0, 0); { DBVARIANT dbv; if ( !db_get_ts(NULL, MODULE, "BkBitmap", &dbv)) { SetDlgItemText(hwndDlg, IDC_FILENAME, dbv.ptszVal); db_free(&dbv); } WORD bmpUse = (WORD)db_get_w(NULL, MODULE, "BkBitmapOpt", FLT_DEFAULT_BKGNDBITMAPOPT); CheckDlgButton(hwndDlg, IDC_STRETCHH, ((bmpUse & CLB_STRETCHH) ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_STRETCHV, ((bmpUse & CLB_STRETCHV) ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_TILEH, ((bmpUse & CLBF_TILEH) ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_TILEV, ((bmpUse & CLBF_TILEV) ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_PROPORTIONAL, ((bmpUse & CLBF_PROPORTIONAL) ? BST_CHECKED : BST_UNCHECKED)); SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILENAME), 1); // Windows 2K/XP BYTE btOpacity = (BYTE)db_get_b(NULL, MODULE, "Opacity", 100); SendDlgItemMessage(hwndDlg, IDC_SLIDER_OPACITY, TBM_SETRANGE, TRUE, MAKELONG(0, 100)); SendDlgItemMessage(hwndDlg, IDC_SLIDER_OPACITY, TBM_SETPOS, TRUE, btOpacity); mir_snprintf(szPercent, SIZEOF(szPercent), "%d%%", btOpacity); SetDlgItemTextA(hwndDlg, IDC_OPACITY, szPercent); EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_OPACITY), SetLayeredWindowAttributes != 0); EnableWindow(GetDlgItem(hwndDlg, IDC_OPACITY), SetLayeredWindowAttributes != 0); } return TRUE; case M_REFRESHBKGBOXES: bEnable = IsDlgButtonChecked(hwndDlg, IDC_BITMAP); EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_STRETCHH), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_STRETCHV), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_TILEH), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_TILEV), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_PROPORTIONAL), bEnable); break; case M_REFRESHBORDERPICKERS: bEnable = IsDlgButtonChecked(hwndDlg, IDC_DRAWBORDER); EnableWindow(GetDlgItem(hwndDlg, IDC_LTEDGESCOLOR), bEnable); EnableWindow(GetDlgItem(hwndDlg, IDC_RBEDGESCOLOR), bEnable); break; case WM_HSCROLL: if (wParam != TB_ENDTRACK) { int nPos = (int)SendDlgItemMessage(hwndDlg, IDC_SLIDER_OPACITY, TBM_GETPOS, 0, 0); fcOpt.thumbAlpha = (BYTE)(( nPos * 255 ) / 100 ); SetThumbsOpacity(fcOpt.thumbAlpha); mir_snprintf(szPercent, SIZEOF(szPercent), "%d%%", nPos); SetDlgItemTextA(hwndDlg, IDC_OPACITY, szPercent); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_DRAWBORDER: SendMessage(hwndDlg, M_REFRESHBORDERPICKERS, 0, 0); break; case IDC_BROWSE: { char str[MAX_PATH]; OPENFILENAMEA ofn = {0}; char filter[512]; GetDlgItemTextA(hwndDlg, IDC_FILENAME, str, sizeof(str)); ofn.lStructSize = sizeof(OPENFILENAMEA); ofn.hwndOwner = hwndDlg; ofn.hInstance = NULL; CallService(MS_UTILS_GETBITMAPFILTERSTRINGS, sizeof(filter), (LPARAM)filter); ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.nMaxFile = sizeof(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = "bmp"; if (!GetOpenFileNameA(&ofn)) return FALSE; SetDlgItemTextA(hwndDlg, IDC_FILENAME, str); } break; case IDC_FILENAME: if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus()) return FALSE; break; case IDC_BITMAP: SendMessage(hwndDlg, M_REFRESHBKGBOXES, 0, 0); break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: if (0 == ((LPNMHDR)lParam)->idFrom) { switch (((LPNMHDR)lParam)->code) { case PSN_RESET: fcOpt.thumbAlpha = (BYTE)((double)db_get_b(NULL, MODULE, "Opacity", 100) * 2.55); SetThumbsOpacity(fcOpt.thumbAlpha); break; case PSN_APPLY: // Border db_set_b(NULL, MODULE, "DrawBorder", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DRAWBORDER)); COLORREF col = SendDlgItemMessage(hwndDlg, IDC_LTEDGESCOLOR, CPM_GETCOLOUR, 0, 0); db_set_dw(NULL, MODULE, "LTEdgesColor", col); col = SendDlgItemMessage(hwndDlg, IDC_RBEDGESCOLOR, CPM_GETCOLOUR, 0, 0); db_set_dw(NULL, MODULE, "RBEdgesColor", col); db_set_b(NULL, MODULE, "Opacity", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SLIDER_OPACITY, TBM_GETPOS, 0, 0)); // Backgroud col = SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_GETCOLOUR, 0, 0); db_set_dw(NULL, MODULE, "BkColor", col); db_set_b(NULL, MODULE, "BkUseBitmap", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BITMAP)); TCHAR str[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str)); db_set_ts(NULL, MODULE, "BkBitmap", str); WORD flags = 0; if (IsDlgButtonChecked(hwndDlg, IDC_STRETCHH)) flags |= CLB_STRETCHH; if (IsDlgButtonChecked(hwndDlg, IDC_STRETCHV)) flags |= CLB_STRETCHV; if (IsDlgButtonChecked(hwndDlg, IDC_TILEH)) flags |= CLBF_TILEH; if (IsDlgButtonChecked(hwndDlg, IDC_TILEV)) flags |= CLBF_TILEV; if (IsDlgButtonChecked(hwndDlg, IDC_PROPORTIONAL)) flags |= CLBF_PROPORTIONAL; db_set_w(NULL, MODULE, "BkBitmapOpt", flags); ApplyOptionsChanges(); OnStatusChanged(); return TRUE; } } break; } return FALSE; }
// // FUNCTION: MediaPlayerDialogProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // INT_PTR CALLBACK MediaPlayerDialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { BOOL handled = FALSE; switch (message) { case WM_INITDIALOG: { SendMessage(GetDlgItem(hWnd, IDC_SLIDER_PLAYBACKPOS), TBM_SETRANGE, TRUE, MAKELONG(0, 1000)); SendMessage(GetDlgItem(hWnd, IDC_SLIDER_PLAYBACKPOS), TBM_SETTICFREQ, 10, 0); SendMessage(GetDlgItem(hWnd, IDC_SLIDER_VOLUME), TBM_SETRANGE, TRUE, MAKELONG(0, 100)); SendMessage(GetDlgItem(hWnd, IDC_SLIDER_VOLUME), TBM_SETTICFREQ, 10, 0); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); SHAutoComplete(GetDlgItem(hWnd, IDC_EDIT_FILENAME), SHACF_FILESYSTEM | SHACF_USETAB); g_MediaPlayer = new (std::nothrow) CMediaPlayer(hWnd); if (g_MediaPlayer == NULL) { MessageBox(hWnd, L"Unable to allocate media player", L"Initialization Failure", MB_OK); EndDialog(hWnd, -1); break; } HRESULT hr = g_MediaPlayer->Initialize(); if (FAILED(hr)) { MessageBox(hWnd, L"Unable to initialize media player", L"Initialization Failure", MB_OK); EndDialog(hWnd, -1); break; } float volume = g_MediaPlayer->GetVolume(); SendMessage(GetDlgItem(hWnd, IDC_SLIDER_VOLUME), TBM_SETPOS, TRUE, static_cast<int>(volume * 100.0f)); bool mute = g_MediaPlayer->GetMute(); CheckDlgButton(hWnd, IDC_CHECK_MUTE, mute ? BST_CHECKED : BST_UNCHECKED); break; } case WM_DESTROY: g_MediaPlayer->Shutdown(); g_MediaPlayer->Release(); g_MediaPlayer = NULL; break; case WM_COMMAND: { int wmId = LOWORD(wParam); int wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: case IDCANCEL: // // Stop on Cancel/OK. // EndDialog(hWnd, TRUE); handled = TRUE; break; // // The user checked the "Pause on Duck" option - ask the media player to sync to that state. // case IDC_CHECK_PAUSE_ON_DUCK: g_MediaPlayer->SyncPauseOnDuck(IsDlgButtonChecked(hWnd, IDC_CHECK_PAUSE_ON_DUCK) == BST_CHECKED); break; // // The user checked the "Opt Out" option - ask the media player to sync to that state. // case IDC_CHECK_DUCKING_OPT_OUT: g_MediaPlayer->SyncDuckingOptOut(IsDlgButtonChecked(hWnd, IDC_CHECK_DUCKING_OPT_OUT) == BST_CHECKED); break; // // See if the user navigated away from the filename edit control - if so, load the file in the filename edit control. // case IDC_EDIT_FILENAME: if (wmEvent == EN_KILLFOCUS) { wchar_t fileName[MAX_PATH]; // // If we're playing (the stop button is enabled), stop playing. // if (IsWindowEnabled(GetDlgItem(hWnd, IDC_BUTTON_STOP))) { g_MediaPlayer->Stop(); KillTimer(hWnd, progressTimer); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); } GetDlgItemText(hWnd, IDC_EDIT_FILENAME, fileName, ARRAYSIZE(fileName)); if (g_MediaPlayer->SetFileName(fileName)) { EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); } } break; // // If the user hit the "Browse" button, bring up the file common dialog box. // // If the user hit "OK" to the dialog then update the edit control to include the filename and load // the file into the player. // case IDC_BUTTON_BROWSE: { wchar_t fileName[MAX_PATH]; OPENFILENAME openFileName = {0}; openFileName.lStructSize = sizeof(openFileName); openFileName.lpstrFile = fileName; openFileName.nMaxFile = ARRAYSIZE(fileName); fileName[0] = L'\0'; openFileName.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST; openFileName.hInstance = g_hInstance; openFileName.hwndOwner = hWnd; if (GetOpenFileName(&openFileName)) { SetDlgItemText(hWnd, IDC_EDIT_FILENAME, openFileName.lpstrFile); // // If we're playing (the stop button is enabled), stop playing. // if (IsWindowEnabled(GetDlgItem(hWnd, IDC_BUTTON_STOP))) { g_MediaPlayer->Stop(); KillTimer(hWnd, progressTimer); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); } g_MediaPlayer->SetFileName(fileName); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); } break; } // // The user hit the "Play" button. // // Sync the "Pause On Duck" and "Ducking Opt Out" buttons with the player and then start playback. // // // Then disable the "Play" button and enable the "Pause" and "Stop" buttons. // case IDC_BUTTON_PLAY: { g_MediaPlayer->SyncPauseOnDuck(IsDlgButtonChecked(hWnd, IDC_CHECK_PAUSE_ON_DUCK) == BST_CHECKED); g_MediaPlayer->SyncDuckingOptOut(IsDlgButtonChecked(hWnd, IDC_CHECK_DUCKING_OPT_OUT) == BST_CHECKED); g_MediaPlayer->Play(); SetTimer(hWnd, progressTimer, 40, NULL); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), TRUE); break; } // // The user hit the "Pause/Continue" button. // // Toggle the "Pause" state in the player and update the button text as appropriate. // case IDC_BUTTON_PAUSE: { if (g_MediaPlayer->TogglePauseState()) { SetWindowText(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), L"Continue"); KillTimer(hWnd, progressTimer); } else { SetWindowText(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), L"Pause"); SetTimer(hWnd, progressTimer, 40, NULL); } break; } // // The user hit the "Stop" button. // // Stop the player and stop the progress timer and enable the "Play" button. // case IDC_BUTTON_STOP: { g_MediaPlayer->Stop(); KillTimer(hWnd, progressTimer); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); break; } case IDC_CHECK_MUTE: { g_MediaPlayer->SetMute(IsDlgButtonChecked(hWnd, IDC_CHECK_MUTE) == BST_CHECKED); } default: break; } break; } case WM_HSCROLL: { // // This horizontal scroll notification comes from the volume slider. Update the volume for the media player. // if (reinterpret_cast<HWND>(lParam) == GetDlgItem(hWnd, IDC_SLIDER_VOLUME)) { int volumePosition = static_cast<int>(SendMessage(GetDlgItem(hWnd, IDC_SLIDER_VOLUME), TBM_GETPOS, 0, 0)); g_MediaPlayer->SetVolume(static_cast<float>(volumePosition) / 100.0f); } break; } case WM_TIMER: { if (wParam == progressTimer) { // // Update the progress slider to match the current playback position. // long position = g_MediaPlayer->GetPosition(); SendMessage(GetDlgItem(hWnd, IDC_SLIDER_PLAYBACKPOS), TBM_SETPOS, TRUE, position); } break; } // // Let the media player know about the DShow graph event. If we come to the end of the track, reset the slider to the beginning of the track. // case WM_APP_GRAPHNOTIFY: { if (g_MediaPlayer->HandleGraphEvent()) { // Reset the slider and timer, we're at the end of the track. SendMessage(GetDlgItem(hWnd, IDC_SLIDER_PLAYBACKPOS), TBM_SETPOS, TRUE, 0); KillTimer(hWnd, progressTimer); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PLAY), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), FALSE); } break; } // // Called when the media player receives a ducking notification. Lets the media player know that the session has been ducked and pauses the player. // case WM_APP_SESSION_DUCKED: if (g_MediaPlayer->Pause()) { SetWindowText(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), L"Continue"); KillTimer(hWnd, progressTimer); } break; // // Called when the media player receives an unduck notification. Lets the media player know that the session has been unducked and continues the player. // case WM_APP_SESSION_UNDUCKED: if (g_MediaPlayer->Continue()) { SetWindowText(GetDlgItem(hWnd, IDC_BUTTON_PAUSE), L"Pause"); SetTimer(hWnd, progressTimer, 40, NULL); } break; // // Process a session volume changed notification. Sync the UI elements with the values in the notification. // // The caller passes the new Mute state in wParam and the new volume value in lParam. // case WM_APP_SESSION_VOLUME_CHANGED: { BOOL newMute = (BOOL)wParam; float newVolume = LPARAM2FLOAT(lParam); int volumePos = static_cast<int>(newVolume * 100); SendMessage(GetDlgItem(hWnd, IDC_SLIDER_VOLUME), TBM_SETPOS, TRUE, volumePos); CheckDlgButton(hWnd, IDC_CHECK_MUTE, newMute ? BST_CHECKED : BST_UNCHECKED); break; } default: // // If the current chat transport is going to handle this message, pass the message to the transport. // // Otherwise just let our caller know that they need to handle it. // break; } return handled; }