我想以编程方式在我正在修补的 C++ outlook 插件中获取选定的日历日期。 这可能涉及使用 CalendarView 对象的 SelectedStartTime 和 SelectedEndTime 属性。
我搜索了 SO(和网络)并在 VB 和 C# 中找到了解决方案,但我无法将实现迁移到 C++。我能够获取 View 对象 - 但我不知道如何获取 calendarView 对象。
这是 C# 中的原始 SO 问题: Outlook Addin - Get current selected calendar date
这是我(到目前为止)在 C++ 中的实现。请注意,它是不完整的:
CComPtr<Outlook::_Explorer> spExplorer;
Outlook::MAPIFolder * pFolder;
CComPtr<Outlook::View> view;
hr = m_pHostApp->ActiveExplorer(&spExplorer);
if (SUCCEEDED(hr) && spExplorer)
{
hr = spExplorer->get_CurrentFolder(&pFolder);
if ((SUCCEEDED(hr)) && pFolder)
{
hr = pFolder->get_CurrentView(&view);
if (SUCCEEDED(hr))
{
Outlook::OlViewType viewType;
hr = view->get_ViewType(&viewType);
if (SUCCEEDED(hr))
{
if (viewType == Outlook::olCalendarView)
{
//the vb/C# solutions suggest that I need a calendar
//view object here and somehow get its
//SelectedStartTime and SelectedEndTime.
//However I suspect there's no such object.. so I must be doing
//something wrong.
}
}
}
}
}
最佳答案
在 View 变量上调用 QueryInterface 以查询 CalendarView 接口(interface),然后使用 CalendarView::SelectedStartTime/SelectedEndTime 属性。
关于c++ - Outlook 插件 - 在 C++ 中获取当前选定的日历日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25472797/