BOOL CManageFiltersDlg::OnInitDialog() { CPWDialog::OnInitDialog(); if (m_bDBReadOnly) { GetDlgItem(IDC_FILTERCOPY)->EnableWindow(FALSE); } // Make some columns centered LVCOLUMN lvc; lvc.mask = LVCF_FMT; lvc.fmt = LVCFMT_CENTER; DWORD dwExStyle = m_FilterLC.GetExtendedStyle(); dwExStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_SUBITEMIMAGES; m_FilterLC.SetExtendedStyle(dwExStyle); CString cs_text; cs_text.LoadString(IDS_FILTERNAME); m_FilterLC.InsertColumn(MFLC_FILTER_NAME, cs_text); cs_text.LoadString(IDS_FILTERSOURCE); m_FilterLC.InsertColumn(MFLC_FILTER_SOURCE, cs_text); cs_text.LoadString(IDS_FILTERAPPLY); m_FilterLC.InsertColumn(MFLC_INUSE, cs_text); cs_text.LoadString(IDS_FILTERCOPY2DB); m_FilterLC.InsertColumn(MFLC_COPYTODATABASE, cs_text); cs_text.LoadString(IDS_FILTEREXPORT); m_FilterLC.InsertColumn(MFLC_EXPORT, cs_text); // Make some columns centered m_FilterLC.SetColumn(MFLC_FILTER_SOURCE, &lvc); m_FilterLC.SetColumn(MFLC_INUSE, &lvc); m_FilterLC.SetColumn(MFLC_COPYTODATABASE, &lvc); m_FilterLC.SetColumn(MFLC_EXPORT, &lvc); // Populate CListCtrl UpdateFilterList(); // if no filters - add a dummy before adjusting item height bool bAddDummy(false); if (m_FilterLC.GetItemCount() == 0) { bAddDummy = true; int iItem = m_FilterLC.InsertItem(0 /* MFLC_FILTER_NAME */, L""); CString cs_source = GetFilterPoolName(FPOOL_SESSION); m_FilterLC.SetItemText(iItem, MFLC_FILTER_SOURCE, cs_source); m_FilterLC.SetItemText(iItem, MFLC_INUSE, L"."); m_FilterLC.SetItemText(iItem, MFLC_COPYTODATABASE, L"."); m_FilterLC.SetItemText(iItem, MFLC_EXPORT, L"."); st_FilterItemData *pflt_idata = new st_FilterItemData; pflt_idata->flt_key.cs_filtername = L"."; pflt_idata->flt_key.fpool = FPOOL_SESSION; pflt_idata->flt_flags = MFLT_REQUEST_COPY_TO_DB | MFLT_REQUEST_EXPORT | MFLT_INUSE; m_FilterLC.SetItemData(iItem, (DWORD_PTR)pflt_idata); } // Set row height to take image by adding a dummy ImageList CRect rect; m_FilterLC.GetItemRect(0, &rect, LVIR_BOUNDS); IMAGEINFO imageinfo; m_pCheckImageList->GetImageInfo(0, &imageinfo); int irowheight = std::max(rect.Height(), (int)abs(imageinfo.rcImage.top - imageinfo.rcImage.bottom)); m_pImageList = new CImageList; m_pImageList->Create(1, irowheight, ILC_COLOR4, 1, 1); m_FilterLC.SetImageList(m_pImageList, LVSIL_SMALL); // If we added a dummy row - delete it if (bAddDummy) { st_FilterItemData *pflt_idata = (st_FilterItemData *)m_FilterLC.GetItemData(0); delete pflt_idata; m_FilterLC.DeleteItem(0); } dwExStyle = m_FilterProperties.GetExtendedStyle(); dwExStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES; m_FilterProperties.SetExtendedStyle(dwExStyle); cs_text = L" # "; m_FilterProperties.InsertColumn(MFPRP_FILTER_NUMBER, cs_text); cs_text.LoadString(IDS_FILTERACTIVE); cs_text += L"?"; m_FilterProperties.InsertColumn(MFPRP_FILTER_ACTIVE, cs_text); cs_text.LoadString(IDS_AND_OR); m_FilterProperties.InsertColumn(MFPRP_AND_OR, cs_text); cs_text.LoadString(IDS_FILTERFIELD); m_FilterProperties.InsertColumn(MFPRP_FIELD, cs_text); cs_text.LoadString(IDS_CRITERIA_DESC); m_FilterProperties.InsertColumn(MFPRP_CRITERIA_TEXT, cs_text); // Make first 3 columns centered m_FilterProperties.SetColumn(MFPRP_FILTER_NUMBER, &lvc); m_FilterProperties.SetColumn(MFPRP_FILTER_ACTIVE, &lvc); m_FilterProperties.SetColumn(MFPRP_AND_OR, &lvc); CHeaderCtrl* pHCtrl; pHCtrl = m_FilterLC.GetHeaderCtrl(); ASSERT(pHCtrl != NULL); pHCtrl->SetDlgCtrlID(IDC_FILTERLC_HEADER); m_FLCHeader.SubclassWindow(pHCtrl->GetSafeHwnd()); pHCtrl = m_FilterProperties.GetHeaderCtrl(); ASSERT(pHCtrl != NULL); pHCtrl->SetDlgCtrlID(IDC_FILTERPROP_HEADER); m_FPROPHeader.SubclassWindow(pHCtrl->GetSafeHwnd()); for (int i = 0; i < MFPRP_NUM_COLUMNS; i++) { m_FilterProperties.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER); } m_FLCHeader.SetStopChangeFlag(true); m_FPROPHeader.SetStopChangeFlag(true); // Nothing is selected yet GetDlgItem(IDC_FILTEREDIT)->EnableWindow(FALSE); GetDlgItem(IDC_FILTERDELETE)->EnableWindow(FALSE); // Don't import if we can't validate #ifndef USE_XML_LIBRARY GetDlgItem(IDC_FILTERIMPORT)->EnableWindow(FALSE); #endif UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control }
BOOL COptionsShortcuts::OnInitDialog() { BOOL brc; COptions_PropertyPage::OnInitDialog(); m_ShortcutLC.Init(this); // Override default HeaderCtrl ID of 0 CHeaderCtrl *pLCHdrCtrl = m_ShortcutLC.GetHeaderCtrl(); pLCHdrCtrl->SetDlgCtrlID(IDC_LIST_HEADER); DWORD dwExtendedStyle = m_ShortcutLC.GetExtendedStyle() | LVS_EX_GRIDLINES; m_ShortcutLC.SetExtendedStyle(dwExtendedStyle); CString cs_colname; cs_colname.LoadString(IDS_COL_SHORTCUT); m_ShortcutLC.InsertColumn(0, cs_colname); // SHCT_SHORTCUTKEYS cs_colname.LoadString(IDS_COL_MENUITEM); m_ShortcutLC.InsertColumn(1, cs_colname); // SHCT_MENUITEMTEXT MapMenuShortcutsIter iter, iter_parent; CString str; int iItem(0); for (iter = m_MapMenuShortcuts.begin(); iter != m_MapMenuShortcuts.end(); iter++) { // We don't allow change of certain menu items // Just don't put in the list that the user sees. if (iter->second.uiParentID == 0) continue; if (std::find(m_ExcludedMenuItems.begin(), m_ExcludedMenuItems.end(), iter->first) != m_ExcludedMenuItems.end()) continue; str = CMenuShortcut::FormatShortcut(iter); iter_parent = m_MapMenuShortcuts.find(iter->second.uiParentID); ASSERT(iter_parent != m_MapMenuShortcuts.end()); CString sMenuItemtext = (CString(iter_parent->second.name.c_str()) + CString(L" \xbb ") + CString(iter->second.name.c_str())); // Remove the ampersand from the menu item the user sees here sMenuItemtext.Remove(L'&'); iItem = m_ShortcutLC.InsertItem(iItem, str); // SHCT_SHORTCUTKEYS ASSERT(iItem != -1); brc = m_ShortcutLC.SetItemText(iItem, 1, sMenuItemtext); // SHCT_MENUITEMTEXT ASSERT(brc != 0); DWORD dwData = MAKELONG(iter->first, iter->second.iMenuPosition); brc = m_ShortcutLC.SetItemData(iItem, dwData); ASSERT(brc != 0); } // foreach m_MapMenuShortcuts // Now sort via Menu item position brc = m_ShortcutLC.SortItems(CompareFunc, NULL); ASSERT(brc != 0); brc = m_ShortcutLC.SetColumnWidth(0, m_iColWidth); // SHCT_SHORTCUTKEYS ASSERT(brc != 0); brc = m_ShortcutLC.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER); // SHCT_MENUITEMTEXT ASSERT(brc != 0); brc = m_ShortcutLC.ModifyStyle(LVS_OWNERDRAWFIXED, 0, 0); ASSERT(brc != 0); m_stc_warning.SetColour(RGB(255, 0, 0)); m_stc_warning.ShowWindow(SW_HIDE); return TRUE; }
BOOL COptionsShortcuts::OnInitDialog() { COptions_PropertyPage::OnInitDialog(); m_AppHotKeyCtrl.m_pParent = this; m_AppHotKeyCtrl.SetHotKey(LOWORD(m_AppHotKeyValue),HIWORD(m_AppHotKeyValue)); if (m_bAppHotKeyEnabled == FALSE) m_AppHotKeyCtrl.EnableWindow(FALSE); // Program shortcuts m_ShortcutLC.Init(this); // Override default HeaderCtrl ID of 0 CHeaderCtrl *pLCHdrCtrl = m_ShortcutLC.GetHeaderCtrl(); pLCHdrCtrl->SetDlgCtrlID(IDC_LIST_HEADER); DWORD dwExtendedStyle = m_ShortcutLC.GetExtendedStyle() | LVS_EX_GRIDLINES; m_ShortcutLC.SetExtendedStyle(dwExtendedStyle); CString cs_colname; cs_colname.LoadString(IDS_COL_SHORTCUT); m_ShortcutLC.InsertColumn(0, cs_colname); // SHCT_SHORTCUTKEYS cs_colname.LoadString(IDS_COL_MENUITEM); m_ShortcutLC.InsertColumn(1, cs_colname); // SHCT_MENUITEMTEXT MapMenuShortcutsIter MenuMapiter, MenuMapiter_parent; CString str; int iItem(0); for (MenuMapiter = m_MapMenuShortcuts.begin(); MenuMapiter != m_MapMenuShortcuts.end(); MenuMapiter++) { // We don't allow change of certain menu items // Just don't put in the list that the user sees. if (MenuMapiter->second.uiParentID == 0) continue; if (std::find(m_ExcludedMenuItems.begin(), m_ExcludedMenuItems.end(), MenuMapiter->first) != m_ExcludedMenuItems.end()) continue; str = CMenuShortcut::FormatShortcut(MenuMapiter); MenuMapiter_parent = m_MapMenuShortcuts.find(MenuMapiter->second.uiParentID); ASSERT(MenuMapiter_parent != m_MapMenuShortcuts.end()); CString sMenuItemtext = (CString(MenuMapiter_parent->second.name.c_str()) + CString(L" \xbb ") + CString(MenuMapiter->second.name.c_str())); // Remove the ampersand from the menu item the user sees here sMenuItemtext.Remove(L'&'); iItem = m_ShortcutLC.InsertItem(iItem, str); // SHCT_SHORTCUTKEYS m_ShortcutLC.SetItemText(iItem, 1, sMenuItemtext); // SHCT_MENUITEMTEXT DWORD dwData = MAKELONG(MenuMapiter->first, MenuMapiter->second.iMenuPosition); m_ShortcutLC.SetItemData(iItem, dwData); } // foreach m_MapMenuShortcuts // Now sort via Menu item position m_ShortcutLC.SortItems(CompareFunc, NULL); m_ShortcutLC.SetColumnWidth(0, m_iColWidth); // SHCT_SHORTCUTKEYS m_ShortcutLC.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER); // SHCT_MENUITEMTEXT m_ShortcutLC.ModifyStyle(LVS_OWNERDRAWFIXED, 0, 0); // Entry shortcuts // Override default HeaderCtrl ID of 0 CHeaderCtrl *pEntryLCHdrCtrl = m_EntryShortcutLC.GetHeaderCtrl(); pEntryLCHdrCtrl->SetDlgCtrlID(IDC_ENTLIST_HEADER); dwExtendedStyle = m_EntryShortcutLC.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT; m_EntryShortcutLC.SetExtendedStyle(dwExtendedStyle); cs_colname.LoadString(IDS_COL_SHORTCUT); m_EntryShortcutLC.InsertColumn(0, cs_colname); // SHORTCUT cs_colname.LoadString(IDS_GROUP); m_EntryShortcutLC.InsertColumn(1, cs_colname); // GROUP cs_colname.LoadString(IDS_TITLE); m_EntryShortcutLC.InsertColumn(2, cs_colname); // TITLE cs_colname.LoadString(IDS_USERNAME); m_EntryShortcutLC.InsertColumn(3, cs_colname); // USER iItem = 0; KBShortcutMapConstIter kbiter; m_KBShortcutMap = GetMainDlg()->GetAllKBShortcuts(); for (kbiter = m_KBShortcutMap.begin(); kbiter != m_KBShortcutMap.end(); kbiter++) { int32 iKBShortcut = kbiter->first; WORD wVirtualKeyCode = iKBShortcut & 0xff; WORD wPWSModifiers = iKBShortcut >> 16; // Translate from PWS modifers to HotKey WORD wHKModifiers = ConvertModifersPWS2MFC(wPWSModifiers); str = CMenuShortcut::FormatShortcut(wHKModifiers, wVirtualKeyCode); ItemListIter iter = app.GetCore()->Find(kbiter->second); const StringX sxGroup = iter->second.GetGroup(); const StringX sxTitle = iter->second.GetTitle(); const StringX sxUser = iter->second.GetUser(); iItem = m_EntryShortcutLC.InsertItem(iItem, str); // SHCT_SHORTCUTKEYS ASSERT(iItem != -1); m_EntryShortcutLC.SetItemText(iItem, 1, sxGroup.c_str()); // Group m_EntryShortcutLC.SetItemText(iItem, 2, sxTitle.c_str()); // Title m_EntryShortcutLC.SetItemText(iItem, 3, sxUser.c_str()); // User m_EntryShortcutLC.SetItemData(iItem, iKBShortcut); } // foreach mapKBShortcutMap // Now sort via keyboard shortcut m_EntryShortcutLC.SortItems(CKBSHCompareFunc, (LPARAM)this); m_EntryShortcutLC.SetColumnWidth(0, m_iColWidth); // SHCT_SHORTCUTKEYS m_EntryShortcutLC.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER); // GROUP m_EntryShortcutLC.SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER); // TITLE m_EntryShortcutLC.SetColumnWidth(3, LVSCW_AUTOSIZE_USEHEADER); // USER InitToolTip(); AddTool(IDC_ENTSHORTCUTLIST, IDS_KBS_TOOLTIP1); ActivateToolTip(); m_stc_warning.ShowWindow(SW_HIDE); m_stc_warning.SetColour(RGB(255, 0, 0)); return TRUE; }
BOOL CPWFiltersDlg::OnInitDialog() { std::vector<UINT> vibottombtns; UINT main_bns[] = {IDC_APPLY, IDOK, IDCANCEL, ID_HELP}; UINT other_bns[] = {IDOK, IDCANCEL, ID_HELP}; if (m_iType == DFTYPE_MAIN && m_bAllowSet) vibottombtns.assign(main_bns, main_bns + _countof(main_bns)); else vibottombtns.assign(other_bns, other_bns + _countof(other_bns)); AddMainCtrlID(IDC_FILTERLC); AddBtnsCtrlIDs(vibottombtns); UINT statustext[1] = {IDS_BLANK}; SetStatusBar(&statustext[0], 1); CPWResizeDialog::OnInitDialog(); SetWindowText(m_cstitle); m_hAccel = ::LoadAccelerators(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_FILTERACCELERATOR)); DWORD dwExStyle = m_FilterLC.GetExtendedStyle(); dwExStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_SUBITEMIMAGES; m_FilterLC.SetExtendedStyle(dwExStyle); m_FilterLC.Init(this, m_pfilters, m_iType, m_bCanHaveAttachments, m_psMediaTypes); if (m_filtername.IsEmpty() || m_pfilters->fname.empty()) m_filtername.LoadString(IDS_FILTER_NAME); else m_filtername = m_pfilters->fname.c_str(); CHeaderCtrl* pHCtrl; pHCtrl = m_FilterLC.GetHeaderCtrl(); ASSERT(pHCtrl != NULL); pHCtrl->SetDlgCtrlID(IDC_FILTERLC_HEADER); m_FLCHeader.SubclassWindow(pHCtrl->GetSafeHwnd()); m_FLCHeader.SetStopChangeFlag(true); CRect rect; // Move over History & Policy dialogs so as not to obscure main filter dialog if (m_iType != DFTYPE_MAIN) { GetParent()->GetWindowRect(&rect); SetWindowPos(NULL, rect.left + rect.Width() / 3, rect.top + rect.Width() / 3, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } // Main window has Apply (if not called via Manage), OK, Cancel buttons // History/Policy/Attachment have OK, Cancel, Help buttons // but only one dialog definition in resource file for both in // order to ensure that the dialogs look exactly the same and also // easier to maintain if (m_iType != DFTYPE_MAIN) { GetDlgItem(IDC_FILTERNAME)->EnableWindow(FALSE); } if (!m_bAllowSet) { // Change buttons if called via ManageFilters or // is a History/Policy dialog GetDlgItem(IDC_APPLY)->EnableWindow(FALSE); GetDlgItem(IDC_APPLY)->ShowWindow(SW_HIDE); } int itotalwidth = 0; for (int i = 0; i < FLC_NUM_COLUMNS; i++) { itotalwidth += m_FilterLC.GetColumnWidth(i); } int iMaxWidth = itotalwidth + 16; int iMaxHeight = 1024; SetMaxHeightWidth(iMaxHeight, iMaxWidth); // Update dialog window text UpdateStatusText(); UpdateData(FALSE); if (m_iType == DFTYPE_MAIN) GetDlgItem(IDC_APPLY)->EnableWindow(m_pfilters->num_Mactive == 0 ? FALSE : TRUE); return TRUE; // return TRUE unless you set the focus to a control }