/*---------------------------------------------------------------------------------------------- The hwnd has been attached. ----------------------------------------------------------------------------------------------*/ void DcMainWnd::PostAttach(void) { StrAppBuf strbT; // Holds temp string // Set the default caption text. strbT.Load(kstidDllClient); ::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)strbT.Chars()); // This creates the main frame window and sets it as the current window. It also // creates the rebar and status bar. SuperClass::PostAttach(); // Create the menu bar. AfMenuBarPtr qmnbr; qmnbr.Create(); qmnbr->Initialize(m_hwnd, kridAppMenu, kridAppMenu, "Menu Bar"); m_vqtlbr.Push(qmnbr.Ptr()); CreateToolBar(qmnbr, true, true, 200); // Load window settings. LoadSettings(NULL, false); g_app.AddCmdHandler(this, 1); m_qstbr->RestoreStatusText(); // Create the client window. const int kwidChild = 1000; WndCreateStruct wcs; wcs.InitChild("DcClientWnd", m_hwnd, kwidChild); wcs.dwExStyle |= WS_EX_CLIENTEDGE; m_dccw.Create(); m_dccw->CreateHwnd(wcs); ::ShowWindow(m_dccw->Hwnd(), SW_SHOW); }
// Append a measurement, never with preceding comma. stid contains a %s which is replaced // with the nVal (initially mp) converted to the appropriate display units. void AppendMeasurement(StrApp & strDesc, int nVal, MsrSysType nMsrSys, int stid) { if (nVal == knNinch) return; StrAppBuf strb; AfUtil::MakeMsrStr(nVal , nMsrSys, &strb); StrApp strFmt(stid); strDesc.FormatAppend(strFmt.Chars(), strb.Chars()); }
// Append information about one border, if it is defined void AppendBorderInfo(StrApp & strDesc, int mp, int stid, bool & fFirst) { if (mp == knNinch) return; StrAppBuf strb; AfUtil::MakeMsrStr (mp , knpt, &strb); StrApp strFmt(stid); StrApp strT; strT.Format(strFmt.Chars(), strb.Chars()); AppendDescPart(strDesc, strT, fFirst); }
/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool FwPropDlg::OnInitDlg(HWND hwndCtrl, LPARAM lp) { StrApp str; str.Format(_T("%r %r"), AfApp::Papp()->GetAppPropNameId(), kstidPropProperties); ::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)str.Chars()); m_pszHelpUrl = m_strHelpF.Chars(); GeneralPropDlgTabPtr qgenp; qgenp.Attach(NewObj GeneralPropDlgTab(this, m_ctidName)); qgenp->EnableLocation(true); qgenp->EnableSize(true); qgenp->EnableModified(true); qgenp->EnableDescription(true); AfDialogViewPtr qdlgv; qdlgv = qgenp; m_vqdlgv.Push(qdlgv); m_hwndTab = ::GetDlgItem(m_hwnd, kcidLangProjPropDlgTab); // WARNING: If this ever gets changed to anything but a fixed length buffer, make sure // ti.pszText is set after loading each string, since the memory pointed to by strb // could be different each time. StrAppBuf strb; TCITEM ti; ti.mask = TCIF_TEXT; ti.pszText = const_cast<achar *>(strb.Chars()); // Add a tab to the tab control for each dialog view. strb.Load(kstidGeneralPropTab); TabCtrl_InsertItem(m_hwndTab, 0, &ti); // This section must be after at least one tab gets added to the tab control. RECT rcTab; ::GetWindowRect(m_hwndTab, &rcTab); TabCtrl_AdjustRect(m_hwndTab, false, &rcTab); POINT pt = { rcTab.left, rcTab.top }; ::ScreenToClient(m_hwnd, &pt); m_dxsClient = pt.x; m_dysClient = pt.y; // Subclass the Help button. AfButtonPtr qbtn; qbtn.Create(); qbtn->SubclassButton(m_hwnd, kctidHelp, kbtHelp, NULL, 0); ShowChildDlg(m_itabInitial); AfApp::Papp()->EnableMainWindows(false); ::SetFocus(m_hwndTab); return SuperClass::OnInitDlg(hwndCtrl, lp); }
void AppendOffsetInfo(StrApp & strDesc, int mpOffset, bool & fFirst) { if (mpOffset && mpOffset != knNinch) { StrApp strFmt; if (mpOffset < 0) strFmt.Load(kstidLoweredFmt); else strFmt.Load(kstidRaisedFmt); StrApp strAmt; StrAppBuf strb; AfUtil::MakeMsrStr (abs(mpOffset) , knpt, &strb); StrApp strT; strT.Format(strFmt.Chars(), strb.Chars()); AppendDescPart(strDesc, strT, fFirst); } }
/*---------------------------------------------------------------------------------------------- Fill in the string with the given "Date Created" or "Date Modified" value. @param flid Field id for either "DateCreated" or "DateModified". @param strb Reference to the output string. ----------------------------------------------------------------------------------------------*/ void GeneralPropDlgTab::GetDateString(int flid, StrAppBuf & strb) { strb.Clear(); try { AfLpInfo * plpi = m_ppropd->GetLangProjInfo(); AssertPtr(plpi); CustViewDaPtr qcvd; plpi->GetDataAccess(&qcvd); AssertPtr(qcvd); int64 ntim = 0; SilTime tim; SYSTEMTIME stim; achar rgchDate[50]; // Tuesday, August 15, 2000 mardi 15 août 2000 achar rgchTime[50]; // 10:17:09 PM 22:20:08 int cch; HVO hvo = m_ppropd->GetObjId(); HRESULT hr; CheckHr(hr = qcvd->get_TimeProp(hvo, flid, &ntim)); if (hr == S_FALSE && !ntim) { int clid = MAKECLIDFROMFLID(flid); AfDbInfo * pdbi = plpi->GetDbInfo(); AssertPtr(pdbi); IOleDbEncapPtr qode; pdbi->GetDbAccess(&qode); AssertPtr(qode); IFwMetaDataCachePtr qmdc; pdbi->GetFwMetaDataCache(&qmdc); AssertPtr(qmdc); SmartBstr sbstrField; CheckHr(qmdc->GetFieldName(flid, &sbstrField)); IOleDbCommandPtr qodc; CheckHr(qode->CreateCommand(&qodc)); StrUni stu; ComBool fIsNull; ComBool fMoreRows; ULONG cbSpaceTaken; SmartBstr sbstrClass; CheckHr(qmdc->GetClassName(clid, &sbstrClass)); // Note that we need the view, not just the class table proper, in case the // attribute is defined on a superclass (such as CmMajorObject). stu.Format(L"select [%b] from [%b_] where [Id] = %d", sbstrField.Bstr(), sbstrClass.Bstr(), hvo); CheckHr(qodc->ExecCommand(stu.Bstr(), knSqlStmtSelectWithOneRowset)); CheckHr(qodc->GetRowset(0)); CheckHr(qodc->NextRow(&fMoreRows)); if (fMoreRows) { DBTIMESTAMP dbtim; CheckHr(qodc->GetColValue(1, reinterpret_cast <BYTE *>(&dbtim), sizeof(DBTIMESTAMP), &cbSpaceTaken, &fIsNull, 0)); if (!fIsNull) { stim.wYear = (unsigned short)dbtim.year; stim.wMonth = (unsigned short)dbtim.month; stim.wDayOfWeek = 0; stim.wDay = (unsigned short)dbtim.day; stim.wHour = (unsigned short)dbtim.hour; stim.wMinute = (unsigned short)dbtim.minute; stim.wSecond = (unsigned short)dbtim.second; stim.wMilliseconds = (unsigned short)(dbtim.fraction/1000000); cch = ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stim, NULL, rgchDate, 50); rgchDate[cch] = 0; cch = ::GetTimeFormat(LOCALE_USER_DEFAULT, NULL, &stim, NULL, rgchTime, 50); rgchTime[cch] = 0; strb.Format(_T("%s %s"), rgchDate, rgchTime); } } } else if (ntim) { tim = ntim; // Convert the date to a system date. // Then format it to a time based on the current user locale. stim.wYear = (unsigned short)tim.Year(); stim.wMonth = (unsigned short)tim.Month(); stim.wDayOfWeek = (unsigned short)tim.WeekDay(); stim.wDay = (unsigned short)tim.Date(); stim.wHour = (unsigned short)tim.Hour(); stim.wMinute = (unsigned short)tim.Minute(); stim.wSecond = (unsigned short)tim.Second(); stim.wMilliseconds = (unsigned short)tim.MilliSecond(); cch = ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stim, NULL, rgchDate, 50); rgchDate[cch] = 0; cch = ::GetTimeFormat(LOCALE_USER_DEFAULT, NULL, &stim, NULL, rgchTime, 50); rgchTime[cch] = 0; strb.Format(_T("%s %s"), rgchDate, rgchTime); } } catch (...) // Was empty. { throw; // For now we have nothing to add, so pass it on up. } }
/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool GeneralPropDlgTab::OnInitDlg(HWND hwndCtrl, LPARAM lp) { HICON hicon = m_ppropd->GetIconHandle(); if (hicon) { ::SendMessage(::GetDlgItem(m_hwnd, kridGeneralPropTabObjIcon), STM_SETICON, (WPARAM)hicon, (LPARAM)0); } m_hfontLarge = AfGdi::CreateFont(16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, _T("MS Sans Serif")); if (m_hfontLarge) { ::SendMessage(::GetDlgItem(m_hwnd, kridGeneralPropTabBigName), WM_SETFONT, (WPARAM)m_hfontLarge, false); } ::SetWindowText(::GetDlgItem(m_hwnd, kridGeneralPropTabBigName), m_ppropd->GetName()); // Replace the kctidGeneralPropTabName editbox with a bespoke version, so that the // "what's this" help will work differently for the different circumstances: HWND hwndEdit = ::GetDlgItem(m_hwnd, kctidGeneralPropTabName); Rect rc; // Get the current edit box's size, font, previous sibling, style and extended style: ::GetWindowRect(hwndEdit, &rc); ::MapWindowPoints(NULL, m_hwnd, (POINT *)&rc, 2); HFONT hfontEdit = (HFONT)(::SendMessage(hwndEdit, WM_GETFONT, 0, 0)); HWND hwndPrev = ::GetWindow(hwndEdit, GW_HWNDPREV); DWORD dwStyle = ::GetWindowLong(hwndEdit, GWL_STYLE); DWORD dwExStyle = ::GetWindowLong(hwndEdit, GWL_EXSTYLE); // Get rid of original edit box: ::DestroyWindow(hwndEdit); // Put in an identical one, but with the id that we want: hwndEdit = ::CreateWindowEx(dwExStyle, _T("EDIT"), _T(""), dwStyle, 0, 0, 0, 0, m_hwnd, (HMENU)m_ctidName, NULL, NULL); ::SetWindowPos(hwndEdit, hwndPrev, rc.left, rc.top, rc.Width(), rc.Height(), 0); ::SendMessage(hwndEdit, WM_SETFONT, (WPARAM)hfontEdit, 0); ::SetWindowText(hwndEdit, m_ppropd->GetName()); const achar * pszType = m_ppropd->GetType(); ::SetWindowText(::GetDlgItem(m_hwnd, kridGeneralPropTabType), pszType); if (m_fLocationEnb) { const achar * pszLoc = m_ppropd->GetLocation(); ::SetWindowText(::GetDlgItem(m_hwnd, kridGeneralPropTabLocation), pszLoc); } else { ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabLocationLabel), SW_HIDE); ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabLocation), SW_HIDE); } if (m_fSizeEnb) { const achar * pszSize = m_ppropd->GetSizeString(); ::SetWindowText(::GetDlgItem(m_hwnd, kridGeneralPropTabSize), pszSize); } else { ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabSizeLabel), SW_HIDE); ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabSize), SW_HIDE); } StrAppBuf strb; GetDateString(m_ppropd->GetDateCreatedFlid(), strb); ::SetWindowText(::GetDlgItem(m_hwnd, kridGeneralPropTabCreated), strb.Chars()); if (m_fModifiedEnb) { GetDateString(m_ppropd->GetDateModifiedFlid(), strb); ::SetWindowText(::GetDlgItem(m_hwnd, kridGeneralPropTabModified), strb.Chars()); } else { ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabModifiedLabel), SW_HIDE); ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabModified), SW_HIDE); } if (m_fDescriptionEnb) { const achar * pszDesc = m_ppropd->GetDescription(); ::SetWindowText(::GetDlgItem(m_hwnd, kctidGeneralPropTabDescription), pszDesc); } else { ::ShowWindow(::GetDlgItem(m_hwnd, kridGeneralPropTabDescriptionLabel), SW_HIDE); ::ShowWindow(::GetDlgItem(m_hwnd, kctidGeneralPropTabDescription), SW_HIDE); } m_fInitialized = true; return SuperClass::OnInitDlg(hwndCtrl, lp); }
/*---------------------------------------------------------------------------------------------- Set the values for the dialog controls based on the style styi. @param vwsProj Union of the current Vernacular and Analysis encodings for the project. ----------------------------------------------------------------------------------------------*/ void FmtGenDlg::SetDialogValues(StyleInfo & styi, Vector<int> & vwsProj) { // During SetDialogValues we never need to handle loss of focus in the name control, // because if anything needed to be done about updating that, it was done during // GetDialogValues, which is always called before SetDialogValues. We need to suppress it // because during this call the current style index and the current value of the control // may not agree: the purpose of this method is to update the control from the new style. // The normal loss-of-focus code is trying to synchronize in the opposite direction, and // can cause problems, for example, when we are disabling the control. For example: // - Disabling the window causes it to lose focus if it previously had focus. // - There is a kill focus event that tries to make the contents of the box agree with // the name of the current style. // - when this method is called, the old style is still the current one, so if we // already changed the text in the box, we wind up trying to rename the old style // to the name of the 'provided' style and produce a name conflict error. try { m_vwsProj = vwsProj; StrApp strDesc; m_fSuppressLossOfFocus = true; StrApp strName = styi.m_stuName; StrApp strTemp; // Temporary string. bool fProtectedStyle = m_pafsd->IsStyleProtected(styi.m_stuName); // Name edit box. ::SetDlgItemText(m_hwnd, kctidFgEdName, strName.Chars()); // Diable the control for styles originally provided by FieldWorks. ::EnableWindow(m_hwndName, !fProtectedStyle); // Style type ltext. switch (styi.m_st) { case kstParagraph: strTemp.Load(kstidParagraph); break; case kstCharacter: strTemp.Load(kstidCharacter); break; default: Assert(false); // Should not happen. } ::SetWindowText(m_hwndType, strTemp.Chars()); // Update the "next" and "basedOn" comboboxes LoadNextStyleCombobox(styi); SetNextStyleComboboxValue(styi); LoadBasedOnStyleCombobox(styi); SetBasedOnStyleComboboxValue(styi); // ENHANCE LarryW(JohnT): When shortcut is implemented initialize the value instead. ::EnableWindow(m_hwndShortcut, false); // Disables it. // ************************************** m_vesi.Clear(); strDesc = m_pafsd->GetNameOfStyle(styi.m_hvoBasedOn); strDesc.Append(" + "); ITsTextProps * pttp = styi.m_qttp; if (pttp) { StrApp strT; StrAppBuf strb; // a temp, used for making strings with units // Add default font info bool fFirstPart = true; SmartBstr sbstr; CheckHr(pttp->GetStrPropValue(ktptFontFamily, &sbstr)); StrUni stuFont(sbstr.Chars()); AppendDescPart(strDesc, FwStyledText::FontStringMarkupToUi(false, stuFont), fFirstPart); int val, var; CheckHr(pttp->GetIntPropValues(ktptFontSize, &var, &val)); if (var != -1) { AfUtil::MakeMsrStr (val , knpt, &strb); AppendDescPart(strDesc, strb, fFirstPart); } CheckHr(pttp->GetIntPropValues(ktptBold, &var, &val)); if (val == kttvForceOn || val == kttvInvert) AppendDescPart(strDesc, kstidBold, fFirstPart); CheckHr(pttp->GetIntPropValues(ktptItalic, &var, &val)); if (val == kttvForceOn || val == kttvInvert) AppendDescPart(strDesc, kstidItalic, fFirstPart); CheckHr(pttp->GetIntPropValues(ktptSuperscript, &var, &val)); if (val == kssvSuper) AppendDescPart(strDesc, kstidFfdSuperscript, fFirstPart); else if (val == kssvSub) AppendDescPart(strDesc, kstidFfdSubscript, fFirstPart); AppendTextIs(strDesc, (COLORREF)ReadValOrNinch(pttp, ktptForeColor), (COLORREF)ReadValOrNinch(pttp, ktptBackColor), fFirstPart); AppendUnderlineInfo(strDesc, (COLORREF)ReadValOrNinch(pttp, ktptUnderColor), ReadValOrNinch(pttp, ktptUnderline), fFirstPart); AppendOffsetInfo(strDesc, ReadValOrNinch(pttp, ktptOffset), fFirstPart); // Add info about other tabs int nDir = ReadValOrNinch(pttp, ktptRightToLeft); AddIf(strDesc, nDir == 0, kstidLeftToRight, fFirstPart); AddIf(strDesc, nDir == 1, kstidRightToLeft, fFirstPart); static const Keyval rgkeyvals[] = { {ktalLeading, kstidFpAlignLead}, {ktalLeft, kstidFpAlignLeft}, {ktalCenter, kstidFpAlignCenter}, {ktalRight, kstidFpAlignRight}, {ktalTrailing, kstidFpAlignTrail}, {ktalJustify, kstidFpAlignJustify}, //TODO: support when in use. {0, 0} }; AddFromList(strDesc, ReadValOrNinch(pttp, ktptAlign), rgkeyvals, fFirstPart); int nLeadIndent = ReadValOrNinch(pttp, ktptLeadingIndent); int nTrailIndent = ReadValOrNinch(pttp, ktptTrailingIndent); int nFirstIndent = ReadValOrNinch(pttp, ktptFirstIndent); if (nLeadIndent != knNinch || nTrailIndent != knNinch || nFirstIndent != knNinch) { AppendDescPart(strDesc, kstidIndentColon, fFirstPart); AppendMeasurement(strDesc, nLeadIndent, m_nMsrSys, kstidLeadingFmt); if (nFirstIndent != knNinch) { if (nFirstIndent < 0) AppendMeasurement(strDesc, -nFirstIndent, m_nMsrSys, kstidHangingFmt); else AppendMeasurement(strDesc, nFirstIndent, m_nMsrSys, kstidFirstLineFmt); } AppendMeasurement(strDesc, nTrailIndent, m_nMsrSys, kstidTrailingFmt); } // line spacing CheckHr(pttp->GetIntPropValues(ktptLineHeight, &var, &val)); StrApp strSpacing; StrApp strFmt; if (var == ktpvMilliPoint) { if (val < 0) strFmt.Load(kstidFpLsExactFmt); else strFmt.Load(kstidFpLsAtLeastFmt); StrAppBuf strb; AfUtil::MakeMsrStr (val , knpt, &strb); strSpacing.Format(strFmt.Chars(), strb.Chars()); } else if (var == ktpvRelative) { if (val >= kdenTextPropRel * 2) strSpacing.Load(kstidFpLsDouble); else if (val >= kdenTextPropRel * 3 / 2) strSpacing.Load(kstidFpLs15Lines); else strSpacing.Load(kstidFpLsSingle); } if (strSpacing.Length() != 0) { strFmt.Load(kstidLineSpacingFmt); strT.Format(strFmt.Chars(), strSpacing.Chars()); AppendDescPart(strDesc, strT, fFirstPart); } int mpBefore = ReadValOrNinch(pttp, ktptSpaceBefore); int mpAfter = ReadValOrNinch(pttp, ktptSpaceAfter); if (mpBefore != knNinch || mpAfter != knNinch) { AppendDescPart(strDesc, kstidSpace, fFirstPart); AppendMeasurement(strDesc, mpBefore, knpt, kstidBeforeFmt); AppendMeasurement(strDesc, mpAfter, knpt, kstidAfterFmt); } int bulnum = ReadValOrNinch(pttp, ktptBulNumScheme); AddIf(strDesc, bulnum >= kvbnBulletBase && bulnum < kvbnBulletMax, kstidBulleted, fFirstPart); AddIf(strDesc, bulnum >= kvbnNumberBase && bulnum < kvbnNumberMax, kstidNumbered, fFirstPart); int mpBTop = ReadValOrNinch(pttp, ktptBorderTop); int mpBB = ReadValOrNinch(pttp, ktptBorderBottom); int mpBL = ReadValOrNinch(pttp, ktptBorderLeading); int mpBTr = ReadValOrNinch(pttp, ktptBorderTrailing); if (mpBTop != knNinch || mpBB != knNinch || mpBL != knNinch || mpBTr != knNinch) { AppendDescPart(strDesc, kstidBorderColon, fFirstPart); int clrBorder = ReadValOrNinch(pttp, ktptBorderColor); bool fFirstBorder = true; if (clrBorder != knNinch) { StrApp strClr; strClr.Load(g_ct.GetColorRid(g_ct.GetIndexFromColor(clrBorder))); strDesc.Append(strClr.Chars()); fFirstBorder = false; } AppendBorderInfo(strDesc, mpBTop, kstidTopBdrFmt, fFirstBorder); AppendBorderInfo(strDesc, mpBB, kstidBottomBdrFmt, fFirstBorder); AppendBorderInfo(strDesc, mpBL, kstidLeadingBdrFmt, fFirstBorder); AppendBorderInfo(strDesc, mpBTr, kstidTrailingBdrFmt, fFirstBorder); } // Add info about writing-system overrides of font info. Vector<int> vwsSoFar; // Get the appropropriate writing system factory. ILgWritingSystemFactoryPtr qwsf; AssertPtr(m_pafsd); m_pafsd->GetLgWritingSystemFactory(&qwsf); AssertPtr(qwsf); //- IWritingSystemPtr qws; // Each iteration of this loop processes information about one writing system. SmartBstr sbstrCharStyles; CheckHr(pttp->GetStrPropValue(kspWsStyle, &sbstrCharStyles)); if (sbstrCharStyles.Length()) { FwStyledText::DecodeFontPropsString(sbstrCharStyles, m_vesi, vwsSoFar); SmartBstr sbstrWs; StrApp strWs; int wsUser; CheckHr(qwsf->get_UserWs(&wsUser)); SmartBstr sbstrAbbr; for (int iesi = 0; iesi < m_vesi.Size(); iesi++) { WsStyleInfo & esi = m_vesi[iesi]; if (vwsSoFar[iesi] == 0) continue; // Ignore writing system set to 0. fFirstPart = true; StrApp strT; StrApp strT2; strT.Format(_T("\n")); // Use the abbreviation in the user ws if it exists. // else try for an abbreviation in each ws in m_vwsProj in turn, // else use the ICU locale name as a last resort. IWritingSystemPtr qws; CheckHr(qwsf->GetStrFromWs(vwsSoFar[iesi], &sbstrWs)); CheckHr(qwsf->get_Engine(sbstrWs, &qws)); CheckHr(qws->get_Abbr(wsUser, &sbstrAbbr)); if (sbstrAbbr.Length() == 0) { for (int iws = 0; iws < m_vwsProj.Size(); ++iws) { CheckHr(qws->get_Abbr(m_vwsProj[iws], &sbstrAbbr)); if (sbstrAbbr.Length() != 0) break; } } if (sbstrAbbr.Length() == 0) strWs.Assign(sbstrWs.Chars(), sbstrWs.Length()); else strWs.Assign(sbstrAbbr.Chars(), sbstrAbbr.Length()); strT2.Format(_T("%s: "), strWs.Chars()); if (strT2 == _T("___: ")) strT2.Load(kctidFgUnknown); strT.Append(strT2); strDesc.Append (strT); AppendDescPart(strDesc, FwStyledText::FontStringMarkupToUi(false, esi.m_stuFontFamily), fFirstPart); if (esi.m_mpSize != knNinch) { AfUtil::MakeMsrStr (esi.m_mpSize , knpt, &strb); AppendDescPart(strDesc, strb, fFirstPart); } if (esi.m_fBold == kttvForceOn || esi.m_fBold == kttvInvert) AppendDescPart(strDesc, kstidBold, fFirstPart); if (esi.m_fItalic == kttvForceOn || esi.m_fItalic == kttvInvert) AppendDescPart(strDesc, kstidItalic, fFirstPart); if (esi.m_ssv == kssvSuper) AppendDescPart(strDesc, kstidFfdSuperscript, fFirstPart); else if (esi.m_ssv == kssvSub) AppendDescPart(strDesc, kstidFfdSubscript, fFirstPart); AppendTextIs(strDesc, esi.m_clrFore, esi.m_clrBack, fFirstPart); AppendUnderlineInfo(strDesc, esi.m_clrUnder, esi.m_unt, fFirstPart); AppendOffsetInfo(strDesc, esi.m_mpOffset, fFirstPart); } // 'for' loop } } ::SetDlgItemText(m_hwnd, kctidFgDescription, strDesc.Chars()); // ************************************** } catch(...) { m_fSuppressLossOfFocus = false; throw; } m_fSuppressLossOfFocus = false; } //:> FmtGenDlg::SetDialogValues.
void AppendDescPart(StrApp & strDesc, StrAppBuf strbPart, bool & fFirst) { AppendDescPart(strDesc, strbPart.Chars(), fFirst); }
/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool RnTlsOptDlg::OnInitDlg(HWND hwndCtrl, LPARAM lp) { m_qrmw = dynamic_cast<RecMainWnd *>(MainWindow()); AfMdiClientWndPtr qmdic = m_qrmw->GetMdiClientWnd(); AssertPtr(qmdic); // Cancel the dialog if we aren't allowed to make changes. AfClientRecWndPtr qafcrw = dynamic_cast<AfClientRecWnd *>(qmdic->GetCurChild()); // This might not exist yet if the filter doesn't match anything during startup. if (qafcrw && !qafcrw->IsOkToChange()) { SuperClass::OnCancel(); return true; } Assert(m_cTabs == 6); // Ensure that the number of dialogs is what we expect. m_hwndTab = GetDlgItem(m_hwnd, kcidTlsOptDlgTab); AfLpInfo * plpi = m_qrmw->GetLpInfo(); AssertPtr(plpi); // Setup m_vuvs plpi->GetDbInfo()->GetCopyUserViewSpecs(&m_vuvs); SetVuvsCopy(); AfViewBarShell * pvwbrs = m_qrmw->GetViewBarShell(); AssertPtr(pvwbrs); // CAUTION! The order these are inserted is important since we use constant indexes to // access them (e.g., kidlgGeneral). AfDialogViewPtr qadv; qadv.Attach(NewObj TlsOptDlgCst(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgVw(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj FwFilterDlg(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgSort(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgOvr(this)); m_vdlgv.Push(qadv); qadv.Attach(NewObj TlsOptDlgGen(this)); m_vdlgv.Push(qadv); // Initialize the object classes that we can create in this dialog. TlsObject to; to.m_clsid = kclidRnEvent; to.m_nLevel = 0; to.m_strName.Load(kstidEventEntry); m_vto.Push(to); to.m_clsid = kclidRnAnalysis; to.m_nLevel = 0; to.m_strName.Load(kstidAnalEntry); m_vto.Push(to); // Initialize the Custom Define In vector. to.m_clsid = kclidRnEvent; to.m_nLevel = 0; to.m_strName.Load(kstidEventEntry); to.m_strClsName = "RnEvent"; m_vcdi.Push(to); to.m_clsid = kclidRnAnalysis; to.m_nLevel = 0; to.m_strName.Load(kstidAnalEntry); to.m_strClsName = "RnAnalysis"; m_vcdi.Push(to); to.m_clsid = kclidRnGenericRec; to.m_nLevel = 1000; // Level 1000 means ALL Entries to.m_strName.Load(kstidTlsOptCstAllEnt); to.m_strClsName = "RnGenericRec"; m_vcdi.Push(to); m_iDefaultCstDfn = m_vcdi.Size() - 1; // If we don't get a reasonable values from GetCurClsLevel, we just default to 0 for the // index. m_ivto = 0; for (int ivto = 0; ivto < m_vto.Size(); ++ivto) { if (m_vto[ivto].m_clsid == m_tgv.clsid && m_vto[ivto].m_nLevel == m_tgv.nLevel) { m_ivto = ivto; break; } } // Initialize the master view types supported by this dialog. TlsView tv; tv.m_vwt = kvwtBrowse; tv.m_fMaster = false; m_vtv.Push(tv); tv.m_vwt = kvwtDE; tv.m_fMaster = true; m_vtv.Push(tv); tv.m_vwt = kvwtDoc; tv.m_fMaster = false; m_vtv.Push(tv); // Update the General tab. TlsOptDlgGen * ptodg = dynamic_cast<TlsOptDlgGen *>(m_vdlgv[kidlgGeneral].Ptr()); AssertPtr(ptodg); ptodg->SetDialogValues(m_vuvs, &m_siwndClientDel); // Update the Custom Fields tab. TlsOptDlgCst * ptodc = dynamic_cast<TlsOptDlgCst *>(m_vdlgv[kidlgCustom].Ptr()); AssertPtr(ptodc); ptodc->SetDialogValues(m_vuvs, &m_siwndClientDel, &m_siCustFldDel); int iv1; // Update the Views tab. TlsOptDlgVw * ptodv = dynamic_cast<TlsOptDlgVw *>(m_vdlgv[kidlgViews].Ptr()); AssertPtr(ptodv); if (m_tgv.itabInitial == kidlgViews && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the current view that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltView), sisel); if (sisel.Size()) iv1 = *sisel.Begin(); else { iv1 = -1; Assert(!qafcrw); } } if (iv1 >= 0) ptodv->SetDialogValues(m_vuvs, &m_siwndClientDel, iv1); // Update the Filters tab. FwFilterDlg * pfltdlg = dynamic_cast<FwFilterDlg *>(m_vdlgv[kidlgFilters].Ptr()); AssertPtr(pfltdlg); if (m_tgv.itabInitial == kidlgFilters && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the current filter that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltFilter), sisel); if (sisel.Size()) iv1 = *sisel.Begin() - 1; // Subtract one for the No Filter item. else { iv1 = -1; Assert(!qafcrw); } } pfltdlg->SetDialogValues(m_qrmw, Max(0, iv1)); // Update the Sort Methods tab. TlsOptDlgSort * psrtdlg = dynamic_cast<TlsOptDlgSort *>(m_vdlgv[kidlgSortMethods].Ptr()); AssertPtr(psrtdlg); if (m_tgv.itabInitial == kidlgSortMethods && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the current sort method that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltSort), sisel); if (sisel.Size()) iv1 = *sisel.Begin() - 1; // Subtract one for the No sort item. else { iv1 = -1; Assert(!qafcrw); } } psrtdlg->SetDialogValues(m_qrmw, Max(0, iv1)); // Update the Overlays tab. TlsOptDlgOvr * ptodo = dynamic_cast<TlsOptDlgOvr *>(m_vdlgv[kidlgOverlays].Ptr()); AssertPtr(ptodo); if (m_tgv.itabInitial == kidlgOverlays && m_tgv.iv1 >= 0) { iv1 = m_tgv.iv1; } else { // Use the first overlay that is selected. Set<int> sisel; pvwbrs->GetSelection(m_qrmw->GetViewbarListIndex(kvbltOverlay), sisel); if (sisel.Size()) iv1 = *sisel.Begin() - 1; // Subtract one for the No Overlay item. else { iv1 = -1; Assert(!qafcrw); } } ptodo->SetDialogValues(plpi, Max(0, iv1), (m_tgv.itabInitial == kidlgOverlays && m_tgv.iv2 >= 0) ? m_tgv.iv2 : 0); // WARNING: If this ever gets changed to anything but a fixed length buffer, make sure // ti.pszText is set after loading each string, since the memory pointed to by strb // could be different each time. StrAppBuf strb; TCITEM ti; ti.mask = TCIF_TEXT; ti.pszText = const_cast<achar *>(strb.Chars()); // Add a tab to the tab control for each dialog view. strb.Load(kstidTlsOptCust); TabCtrl_InsertItem(m_hwndTab, kidlgCustom, &ti); strb.Load(kstidTlsOptView); TabCtrl_InsertItem(m_hwndTab, kidlgViews, &ti); strb.Load(kstidTlsOptFltr); TabCtrl_InsertItem(m_hwndTab, kidlgFilters, &ti); strb.Load(kstidTlsOptSort); TabCtrl_InsertItem(m_hwndTab, kidlgSortMethods, &ti); strb.Load(kstidTlsOptOvr); TabCtrl_InsertItem(m_hwndTab, kidlgOverlays, &ti); strb.Load(kstidTlsOptGen); TabCtrl_InsertItem(m_hwndTab, kidlgGeneral, &ti); // This section must be after at least one tab gets added to the tab control. RECT rcTab; ::GetWindowRect(m_hwndTab, &rcTab); TabCtrl_AdjustRect(m_hwndTab, false, &rcTab); POINT pt = { rcTab.left, rcTab.top }; ::ScreenToClient(m_hwnd, &pt); m_dxsClient = pt.x; m_dysClient = pt.y; // Subclass the Help button. AfButtonPtr qbtn; qbtn.Create(); qbtn->SubclassButton(m_hwnd, kctidHelp, kbtHelp, NULL, 0); ShowChildDlg(m_tgv.itabInitial); m_siwndClientDel.Clear(); m_siCustFldDel.Clear(); AfApp::Papp()->EnableMainWindows(false); SetFocus(::GetDlgItem(m_hwnd, kcidTlsOptDlgTab)); return SuperClass::OnInitDlg(hwndCtrl, lp); }
/*---------------------------------------------------------------------------------------------- Called by the framework to initialize the dialog. All one-time initialization should be done here (that is, all controls have been created and have valid hwnd's, but they need initial values.) See ${AfDialog#FWndProc} @param hwndCtrl (not used) @param lp (not used) @return true if Successful ----------------------------------------------------------------------------------------------*/ bool DetailsPropDlgTab::OnInitDlg(HWND hwndCtrl, LPARAM lp) { HICON hicon = m_ppropd->GetIconHandle(); if (hicon) { ::SendMessage(::GetDlgItem(m_hwnd, kridDetailsPropTabObjIcon), STM_SETICON, (WPARAM)hicon, (LPARAM)0); } m_hfontLarge = AfGdi::CreateFont(16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, _T("MS Sans Serif")); if (m_hfontLarge) { ::SendMessage(::GetDlgItem(m_hwnd, kridDetailsPropTabBigName), WM_SETFONT, (WPARAM)m_hfontLarge, false); } ::SetWindowText(::GetDlgItem(m_hwnd, kridDetailsPropTabBigName), m_ppropd->GetName()); ::SetWindowText(::GetDlgItem(m_hwnd, kctidDetailsPropTabAbbr), m_ppropd->GetAbbr()); ::SetWindowText(::GetDlgItem(m_hwnd, kctidDetailsPropTabHelpF), m_ppropd->GetHelpFile()); ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabSort, BM_SETCHECK, m_ppropd->GetSorted(), 0); ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabDup, BM_SETCHECK, m_ppropd->GetDuplicates(), 0); if (m_ppropd->GetDepth() > 1) ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabHeir, BM_SETCHECK, BST_CHECKED, 0); else ::SendDlgItemMessage(m_hwnd, kctidDetailsPropTabHeir, BM_SETCHECK, BST_UNCHECKED, 0); // Initialize values for the Display combo box. HWND hwndCbo = ::GetDlgItem(m_hwnd, kctidDetailsPropTabDisp); StrAppBuf strb; strb.Load(kstidListsDetailsName); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidListsDetailsAN); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidListsDetailsAbbr); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); ::SendMessage(hwndCbo, CB_SETCURSEL , (WPARAM)m_ppropd->GetDispOpt(), 0); // Load "Writing System" Combo Box hwndCbo = ::GetDlgItem(m_hwnd, kctidDetailsPropTabWS); strb.Load(kstidWSAnals); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidWSVerns); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidWSAnalVerns); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); strb.Load(kstidWSVernAnals); ::SendMessage(hwndCbo, CB_ADDSTRING, 0, (LPARAM)strb.Chars()); int iWSCboSel; int ws = m_ppropd->GetWs(); switch (ws) { case kwsAnals: iWSCboSel = 0; break; case kwsVerns: iWSCboSel = 1; break; case kwsAnalVerns: iWSCboSel = 2; break; case kwsVernAnals: iWSCboSel = 3; break; } ::SendMessage(hwndCbo, CB_SETCURSEL , (WPARAM)iWSCboSel, 0); m_fInitialized = true; return SuperClass::OnInitDlg(hwndCtrl, lp); }
/*---------------------------------------------------------------------------------------------- The hwnd has been attached. ----------------------------------------------------------------------------------------------*/ void HwMainWnd::PostAttach(void) { StrAppBuf strbT; // Holds temp string // Set the default caption text. strbT.Load(kstidHelloWorld); ::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)strbT.Chars()); // This creates the main frame window and sets it as the current window. It also // creates the rebar and status bar. SuperClass::PostAttach(); const int rgrid[] = { kridTBarStd, kridHwTBarIns, kridHwTBarTools, kridHwTBarWnd, }; GetMenuMgr()->LoadToolBars(rgrid, SizeOfArray(rgrid)); // Create the menu bar. AfMenuBarPtr qmnbr; qmnbr.Create(); qmnbr->Initialize(m_hwnd, kridAppMenu, kridAppMenu, "Menu Bar"); m_vqtlbr.Push(qmnbr.Ptr()); // Create the toolbars. AfToolBarPtr qtlbr; qtlbr.Create(); qtlbr->Initialize(kridTBarStd, kridTBarStd, "Standard"); m_vqtlbr.Push(qtlbr); qtlbr.Create(); qtlbr->Initialize(kridHwTBarIns, kridHwTBarIns, "Insert"); m_vqtlbr.Push(qtlbr); qtlbr.Create(); qtlbr->Initialize(kridHwTBarTools, kridHwTBarTools, "Tools"); m_vqtlbr.Push(qtlbr); qtlbr.Create(); qtlbr->Initialize(kridHwTBarWnd, kridHwTBarWnd, "Window"); m_vqtlbr.Push(qtlbr); // Load window settings. LoadSettings(NULL, false); g_app.AddCmdHandler(this, 1); m_qstbr->RestoreStatusText(); // Create the client window. const int kwidChild = 1000; WndCreateStruct wcs; wcs.InitChild("STATIC", m_hwnd, kwidChild); m_qwndHost.Create(); m_qwndHost->CreateAndSubclassHwnd(wcs); Assert(memcmp(&CLSID_SaCtrlEvent, &DIID__DSAEvents, isizeof(GUID)) == 0); CComCoClass<SaCtrlEvent>::CreateInstance(&m_qsce); IUnknownPtr qunk; CheckHr(AtlAxCreateControlEx(L"SA.SACtrl.1", m_qwndHost->Hwnd(), NULL, NULL, &qunk, DIID__DSAEvents, (IUnknown *)m_qsce.Ptr())); CheckHr(qunk->QueryInterface(DIID__DSA, (void **)&m_qctrl)); m_qsce->Init(this, m_qctrl); StrUni stu(L"baluchi.wav"); CheckHr(m_qctrl->put_WaveFile(stu.Bstr())); CheckHr(m_qctrl->raw_SetGraphs(GRAPH_MAGNITUDE, GRAPH_MAGNITUDE)); CheckHr(m_qctrl->put_ShowContextMenu(false)); CheckHr(m_qctrl->put_ShowCursorContextMenu(false)); ::ShowWindow(m_qwndHost->Hwnd(), SW_SHOW); g_app.AddCmdHandler(this, 1); }