bool CPatchUndoTest::DoPageEdit(CWnd *pParent, CString& PageName, CString& CtrlCaption) { CHWNDArray Ctrl; CTabbedDlg *pTabDlg = GetPageControls(pParent, PageName, Ctrl); ASSERT(pTabDlg != NULL); ASSERT(Ctrl.GetSize()); int iCtrl = Random(Ctrl.GetSize()); CWnd *pWnd = CWnd::FromHandle(Ctrl[iCtrl]); if (pWnd == NULL || !pWnd->IsWindowEnabled()) // skip disabled controls return(FALSE); UINT nID = pWnd->GetDlgCtrlID(); CtrlCaption = pTabDlg->GetControlCaption(nID); CNumEdit *pNumEdit = DYNAMIC_DOWNCAST(CNumEdit, pWnd); if (pNumEdit != NULL) { double val = pNumEdit->GetVal(); pNumEdit->AddSpin(1); if (pNumEdit->GetVal() == val) pNumEdit->AddSpin(-1); return(TRUE); } CComboBox *pCombo = DYNAMIC_DOWNCAST(CComboBox, pWnd); if (pCombo != NULL) { int nItems = pCombo->GetCount(); if (nID == IDC_PATCH_GEN_PPQ) // if PPQ combo nItems /= 4; // limit range to avoid zero timer period int iItem = RandomExcluding(nItems, pCombo->GetCurSel()); if (iItem < 0) return(FALSE); pCombo->SetCurSel(iItem); pCombo->GetParent()->SendMessage(WM_COMMAND, MAKELONG(pCombo->GetDlgCtrlID(), CBN_SELCHANGE)); return(TRUE); } CButton *pBtn = DYNAMIC_DOWNCAST(CButton, pWnd); if (pBtn != NULL) { pBtn->SetCheck(!pBtn->GetCheck()); pBtn->GetParent()->SendMessage(WM_COMMAND, MAKELONG(pBtn->GetDlgCtrlID(), BN_CLICKED)); return(TRUE); } return(FALSE); }
AFX_STATIC int CALLBACK EnumFontFamExProc( ENUMLOGFONTEX *lpelfe, // logical-font data NEWTEXTMETRICEX *lpntme, // physical-font data DWORD FontType, // type of font LPARAM lParam) // application-defined data { CComboBox* pWndCombo = DYNAMIC_DOWNCAST(CComboBox, (CComboBox*)lParam); if (::IsWindow(pWndCombo->GetSafeHwnd())) { switch (pWndCombo->GetDlgCtrlID()) { case XTP_IDC_EDIT_COMB_NAMES: { //if (lpelfe->elfLogFont.lfPitchAndFamily & FIXED_PITCH) { // Make sure the fonts are only added once. if (pWndCombo->FindStringExact(0, (LPCTSTR)lpelfe->elfFullName) == CB_ERR) { // Add to list pWndCombo->AddString((LPCTSTR)lpelfe->elfLogFont.lfFaceName); } } } break; case XTP_IDC_EDIT_COMB_SIZES: { if (FontType != TRUETYPE_FONTTYPE) { CWindowDC dc(NULL); CString csSize; csSize.Format(_T("%i"), ::MulDiv(lpntme->ntmTm.tmHeight - lpntme->ntmTm.tmInternalLeading, 72, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY))); // Make sure the fonts are only added once. if (pWndCombo->FindStringExact(0, (LPCTSTR)csSize) == CB_ERR) { // Add to list pWndCombo->AddString((LPCTSTR)csSize); } } } break; case XTP_IDC_EDIT_COMB_SCRIPT: { if (lpelfe->elfScript[0] != _T('\0')) { // Make sure the fonts are only added once. if (pWndCombo->FindStringExact(0, (LPCTSTR)lpelfe->elfScript) == CB_ERR) { // Add to list int iIndex = pWndCombo->AddString((LPCTSTR)lpelfe->elfScript); if (iIndex != CB_ERR) { pWndCombo->SetItemData(iIndex, (DWORD)lpelfe->elfLogFont.lfCharSet); } } } } break; } } return TRUE; }