本文整理汇总了C++中CComPtr::AddPushButton方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::AddPushButton方法的具体用法?C++ CComPtr::AddPushButton怎么用?C++ CComPtr::AddPushButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComPtr
的用法示例。
在下文中一共展示了CComPtr::AddPushButton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitInstance
//.........这里部分代码省略.........
DWORD dwOptions;
if (SUCCEEDED(hr = pfd->GetOptions(&dwOptions)))
{
hr = pfd->SetOptions(dwOptions | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
}
// Set a title
if (SUCCEEDED(hr))
{
CString temp;
temp.LoadString(IDS_OPENDIFFFILETITLE);
pfd->SetTitle(temp);
}
CSelectFileFilter fileFilter(IDS_PATCHFILEFILTER);
hr = pfd->SetFileTypes(fileFilter.GetCount(), fileFilter);
bool bAdvised = false;
DWORD dwCookie = 0;
CComObjectStackEx<PatchOpenDlgEventHandler> cbk;
CComQIPtr<IFileDialogEvents> pEvents = cbk.GetUnknown();
{
CComPtr<IFileDialogCustomize> pfdCustomize;
hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdCustomize));
if (SUCCEEDED(hr))
{
// check if there's a unified diff on the clipboard and
// add a button to the fileopen dialog if there is.
UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF"));
if ((cFormat)&&(OpenClipboard(NULL)))
{
HGLOBAL hglb = GetClipboardData(cFormat);
if (hglb)
{
pfdCustomize->AddPushButton(101, CString(MAKEINTRESOURCE(IDS_PATCH_COPYFROMCLIPBOARD)));
hr = pfd->Advise(pEvents, &dwCookie);
bAdvised = SUCCEEDED(hr);
}
CloseClipboard();
}
}
}
// Show the save file dialog
if (SUCCEEDED(hr) && SUCCEEDED(hr = pfd->Show(pFrame->m_hWnd)))
{
// Get the selection from the user
CComPtr<IShellItem> psiResult = NULL;
hr = pfd->GetResult(&psiResult);
if (bAdvised)
pfd->Unadvise(dwCookie);
if (SUCCEEDED(hr))
{
PWSTR pszPath = NULL;
hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
if (SUCCEEDED(hr))
{
pFrame->m_Data.m_sDiffFile = pszPath;
CoTaskMemFree(pszPath);
}
}
else
{
// no result, which means we closed the dialog in our button handler
std::wstring sTempFile;
if (TrySavePatchFromClipboard(sTempFile))
pFrame->m_Data.m_sDiffFile = sTempFile.c_str();