Example #1
0
HRESULT CBandSiteMenu::_AddISFBandToMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, IUnknown* pBand, DWORD dwBandID, UINT *newMenuId)
{
    CComPtr<IShellFolderBand> psfb;
    HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
    if (FAILED_UNEXPECTEDLY(hr))
        return hr;

    BANDINFOSFB bi = {ISFB_MASK_IDLIST};
    hr = psfb->GetBandInfoSFB(&bi);
    if (FAILED_UNEXPECTEDLY(hr))
        return hr;

    CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
    if (!pidl)
    {
        ERR("Failed to get the pidl of the CISFBand\n");
        return E_OUTOFMEMORY;
    }

    WCHAR buffer[MAX_PATH];
    hr = ILGetDisplayNameEx(NULL, pidl, buffer, ILGDN_INFOLDER) ? S_OK : E_FAIL;
    if (FAILED_UNEXPECTEDLY(hr))
        return hr;

    UINT id = idCmdFirst + m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID + dwBandID;
    if (id >= idCmdLast)
        return E_FAIL;

    *newMenuId = id;
    InsertMenu(hmenu, indexMenu, MF_BYPOSITION, id, buffer);
    return S_OK;
}
Example #2
0
    // Purpose: Called by the shell/MSF when an item must be renamed.
    LPITEMIDLIST OnSetNameOf(HWND /*hwnd*/, const CVVVItem& item, const wchar_t* szNewName, SHGDNF shgndf)
    {
        RaiseExceptionIf(shgndf != SHGDN_NORMAL && shgndf != SHGDN_INFOLDER); // not supported 'name'.

        CPidl pidl(CVVVItem::CreateItemIdList(item.GetID(), item.GetSize(), item.IsFolder(), szNewName));

        CVVVFile(GetPathFolderFile(), m_strSubFolder).SetItem(CVVVItem(pidl));

        return pidl.Detach();
    }
Example #3
0
int wxDirDialog::ShowSHBrowseForFolder(WXHWND owner)
{
    BROWSEINFO bi;
    bi.hwndOwner      = owner;
    bi.pidlRoot       = NULL;
    bi.pszDisplayName = NULL;
    bi.lpszTitle      = m_message.c_str();
    bi.ulFlags        = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
    bi.lpfn           = BrowseCallbackProc;
    bi.lParam         = wxMSW_CONV_LPARAM(m_path); // param for the callback

    static const int verComCtl32 = wxApp::GetComCtl32Version();

    // we always add the edit box (it doesn't hurt anybody, does it?)
    bi.ulFlags |= BIF_EDITBOX;

    // to have the "New Folder" button we must use the "new" dialog style which
    // is also the only way to have a resizable dialog
    //
    const bool needNewDir = !HasFlag(wxDD_DIR_MUST_EXIST);
    if ( needNewDir || HasFlag(wxRESIZE_BORDER) )
    {
        if (needNewDir)
        {
            bi.ulFlags |= BIF_NEWDIALOGSTYLE;
        }
        else
        {
            // Versions < 600 doesn't support BIF_NONEWFOLDERBUTTON
            // The only way to get rid of the Make New Folder button is use
            // the old dialog style which doesn't have the button thus we
            // simply don't set the New Dialog Style for such comctl versions.
            if (verComCtl32 >= 600)
            {
                bi.ulFlags |= BIF_NEWDIALOGSTYLE;
                bi.ulFlags |= BIF_NONEWFOLDERBUTTON;
            }
        }
    }

    // do show the dialog
    wxItemIdList pidl(SHBrowseForFolder(&bi));

    wxItemIdList::Free((LPITEMIDLIST)bi.pidlRoot);

    if ( !pidl )
    {
        // Cancel button pressed
        return wxID_CANCEL;
    }

    m_path = pidl.GetPath();

    return m_path.empty() ? wxID_CANCEL : wxID_OK;
}
Example #4
0
UINT CBandSiteMenu::_GetMenuIdFromISFBand(IUnknown *pBand)
{
    CComPtr<IShellFolderBand> psfb;
    HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
    if (FAILED_UNEXPECTEDLY(hr))
        return UINT_MAX;

    BANDINFOSFB bi = {ISFB_MASK_IDLIST};
    hr = psfb->GetBandInfoSFB(&bi);
    if (FAILED_UNEXPECTEDLY(hr))
        return UINT_MAX;

    CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
    if (!pidl)
    {
        ERR("Failed to get the pidl of the CISFBand\n");
        return UINT_MAX;
    }

    if (pidl->mkid.cb == 0)
    {
        return IDM_TASKBAR_TOOLBARS_DESKTOP;
    }

    CComPtr<IShellFolder> psfDesktop;
    hr = SHGetDesktopFolder(&psfDesktop);
    if (FAILED_UNEXPECTEDLY(hr))
        return UINT_MAX;

    LPITEMIDLIST _QLaunchPidl = _GetQLaunchPidl(false);
    if (_QLaunchPidl == NULL)
        return UINT_MAX;

    hr = psfDesktop->CompareIDs(0, pidl, _QLaunchPidl);
    if (FAILED_UNEXPECTEDLY(hr))
        return UINT_MAX;

    if (HRESULT_CODE(hr) == 0)
        return IDM_TASKBAR_TOOLBARS_QUICKLAUNCH;

    return UINT_MAX;
}
Example #5
0
/*++
* @name FinalConstruct
*
* Creates an instance of CISFBand, and initializes its Shell Folder Band for enumeration.
*
* @return The error code.
*
*--*/
    HRESULT CQuickLaunchBand::FinalConstruct()
    {
        HRESULT hr = RSHELL_CISFBand_CreateInstance(IID_PPV_ARG(IUnknown, &m_punkISFB));
        if (FAILED_UNEXPECTEDLY(hr))
            return hr;

        CComPtr<IShellFolderBand> pISFB;
        hr = m_punkISFB->QueryInterface(IID_PPV_ARG(IShellFolderBand, &pISFB));
        if (FAILED_UNEXPECTEDLY(hr))
            return hr;

        CComPtr<IShellFolder> pISF;
        hr = SHGetDesktopFolder(&pISF);
        if (FAILED_UNEXPECTEDLY(hr))
            return hr;

        CComHeapPtr<ITEMIDLIST> pidl(PidlBrowse(m_hWndBro, CSIDL_DESKTOP));
        if (pidl == NULL)
            return E_FAIL;
        pISFB->InitializeSFB(pISF, pidl);
        
        return hr;
    }
int SelectDirDialog::ShowModal()
{
    wxWindow *parent = GetParent();

    BROWSEINFO bi;
    bi.hwndOwner      = parent ? GetHwndOf(parent) : NULL;
    bi.pidlRoot       = NULL;
    bi.pszDisplayName = NULL;
    // Please don't change this without checking it compiles
    // with eVC++ first.

    bi.lpszTitle      = m_message.c_str();
    bi.ulFlags        = BIF_RETURNONLYFSDIRS;
    bi.lpfn           = BrowseCallbackProc;
    bi.lParam         = (LPARAM)this;    // param for the callback


//  bi.ulFlags |= BIF_EDITBOX;
    // do show the dialog
    wxItemIdList pidl(SHBrowseForFolder(&bi));
    wxItemIdList::Free((LPITEMIDLIST)bi.pidlRoot);

    if ( !pidl )
    {
        // Cancel button pressed
        return wxID_CANCEL;
    }

    m_path = pidl.GetPath();

    // change current working directory if asked so
    if (HasFlag(wxDD_CHANGE_DIR))
        wxSetWorkingDirectory(m_path);

    return m_path.empty() ? wxID_CANCEL : wxID_OK;
}
Example #7
0
int wxDirDialog::ShowModal()
{
    wxWindow *parent = GetParent();

    BROWSEINFO bi;
    bi.hwndOwner      = parent ? GetHwndOf(parent) : NULL;
    bi.pidlRoot       = NULL;
    bi.pszDisplayName = NULL;
    // Please don't change this without checking it compiles
    // with eVC++ first.
#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
    bi.lpszTitle      = m_message.mb_str();
#else
    bi.lpszTitle      = m_message.c_str();
#endif
    bi.ulFlags        = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
    bi.lpfn           = BrowseCallbackProc;
    bi.lParam         = (LPARAM)m_path.c_str();    // param for the callback

    static const int verComCtl32 = wxApp::GetComCtl32Version();

    // we always add the edit box (it doesn't hurt anybody, does it?) if it is
    // supported by the system
    if ( verComCtl32 >= 471 )
    {
        bi.ulFlags |= BIF_EDITBOX;
    }

    // to have the "New Folder" button we must use the "new" dialog style which
    // is also the only way to have a resizable dialog
    //
    // "new" style is only available in the version 5.0+ of comctl32.dll
    const bool needNewDir = HasFlag(wxDD_NEW_DIR_BUTTON);
    if ( (needNewDir || HasFlag(wxRESIZE_BORDER)) && (verComCtl32 >= 500) )
    {
        if (needNewDir)
        {
            bi.ulFlags |= BIF_NEWDIALOGSTYLE;
        }
        else
        {
            // Versions < 600 doesn't support BIF_NONEWFOLDERBUTTON
            // The only way to get rid of the Make New Folder button is use
            // the old dialog style which doesn't have the button thus we
            // simply don't set the New Dialog Style for such comctl versions.
            if (verComCtl32 >= 600)
            {
                bi.ulFlags |= BIF_NEWDIALOGSTYLE;
                bi.ulFlags |= BIF_NONEWFOLDERBUTTON;
            }
        }
    }

    // do show the dialog
    wxItemIdList pidl(SHBrowseForFolder(&bi));

    wxItemIdList::Free((LPITEMIDLIST)bi.pidlRoot);

    if ( !pidl )
    {
        // Cancel button pressed
        return wxID_CANCEL;
    }

    m_path = pidl.GetPath();

    return m_path.empty() ? wxID_CANCEL : wxID_OK;
}
BOOL OnCommand(HWND hDlg, WORD wID, WORD code)
{
    //DEBUGMESSAGE(("OnCommand"));

    DocumentPropDialogData *data = 
        (DocumentPropDialogData *) GetWindowLongPtr(hDlg, DWL_USER);

    switch (wID)
    {
    case IDC_COMBO_VECTOR_FORMAT:
    case IDC_COMBO_RASTER_FORMAT:
        {
            DEBUGMESSAGE(("OnCommand - combo command"));
            switch (code)
            {
            case CBN_SELCHANGE:
                {
                    DWORD nId = 
                        (wID==IDC_COMBO_VECTOR_FORMAT) ? 
                            IDC_VECTOR_FORMAT_RADIOBOX : 
                            IDC_RASTER_FORMAT_RADIOBOX;

                    // select the radio button next to the combo which changed
                    CheckRadioButton(hDlg, 
                             IDC_VECTOR_FORMAT_RADIOBOX, IDC_RASTER_FORMAT_RADIOBOX,
                             nId);
                }
                break;

            default:
                break;
            }
        }
        break;

    case IDC_BROWSE_BUTTON:
        {
            BROWSEINFO bi;
            bi.hwndOwner      = hDlg;
            bi.pidlRoot       = NULL;
            bi.pszDisplayName = NULL;
            bi.lpszTitle      = TEXT("Choose output folder");
            bi.ulFlags        = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
            bi.lpfn           = BrowseCallbackProc;

            LPTSTR folder = NULL;
            if (!GetEditControlText(&folder, GetDlgItem(hDlg, IDC_OUTPUT_FOLDER))) {
                DEBUGMESSAGE(("DocPropDlgProc - could not get output folder text"));
                return FALSE;
            }

            bi.lParam         = (LPARAM)folder; // param for the callback

            const int verComCtl32 = GetComCtl32Version();

            // we always add the edit box (it doesn't hurt anybody, does it?) if it is
            // supported by the system
            if ( verComCtl32 >= 471 )
            {
                bi.ulFlags |= BIF_EDITBOX;
            }

            // to have the "New Folder" button we must use the "new" dialog style which
            // is also the only way to have a resizable dialog
            if (verComCtl32 >= 500)
            {
                bi.ulFlags |= BIF_NEWDIALOGSTYLE;
            }

            // do show the dialog
            wxItemIdList pidl(SHBrowseForFolder(&bi));

            // cleanup
            wxItemIdList::Free((LPITEMIDLIST)bi.pidlRoot);
            strFree((LPTSTR)bi.lParam);

            if ( !pidl )
            {
                DEBUGMESSAGE(("user hit cancel"));
                return TRUE;
            }

            LPTSTR newPath = pidl.GetPath();
            if (newPath)
            {
                // change the text in the associated control
                SendMessage(GetDlgItem(hDlg, IDC_OUTPUT_FOLDER), 
                            WM_SETTEXT, 0, (LPARAM)newPath);
                strFree(newPath);
            }
        }
        break;

    default:
        break;
    }

    return FALSE;
}
Example #9
0
FolderPathPtr CreateFolderPath(const TCHAR* path)
{
	DWORD attrib= ::GetFileAttributes(path);

	if (attrib == INVALID_FILE_ATTRIBUTES)
		return 0;

	if ((attrib & FILE_ATTRIBUTE_DIRECTORY) == 0)	// a file?
	{
		// determine if it's a link

		IShellLinkWPtr SL;
		if (::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&SL) == S_OK)
		{
			IPersistFilePtr PF;
			if (SL->QueryInterface(IID_IPersistFile, (void**)&PF) == S_OK)
			{
#ifdef _UNICODE
				LPCOLESTR a_path= path;
#else
				_bstr_t path_str= path;
				LPCOLESTR a_path= path_str;
#endif
				if (PF->Load(a_path, SLR_ANY_MATCH | SLR_NOSEARCH | SLR_NO_UI | SLR_UPDATE) == S_OK)
				{
					ITEMIDLIST* idl= 0;
					if (SL->GetIDList(&idl) == S_OK)
					{
						return ::CreateFolderPath(idl);
						//ItemIdList idlPath(idl);
//						Browser(a_path, false);
					}
				}
				else	// not a link
				{
					// check if this is catalog file
					{
						Path p(path);
						if (p.MatchExtension(_T("catalog")) && p.FileExists())
							return new CatalogPath(p);
					}

					const TCHAR* sep= _tcsrchr(path, _T('\\'));
					if (sep == 0)
						sep = _tcsrchr(path, _T('/'));
					if (sep != 0)
					{
						CString dir(path, static_cast<int>(sep - path + 1));	// include '\' at the end or else c: won't be parsed properly
						//FolderSelected(dir);
//						return ::CreateFolderPath(dir);

						// create directory path object passing name of selected file
						ItemIdList pidl(dir);
						return new DirectoryPath(pidl, sep + 1);
					}
				}
			}
		}
	}
	else if (attrib & FILE_ATTRIBUTE_DIRECTORY)
	{
		//ItemIdList idlPath(path);
		//FolderPathPtr path= ::CreateFolderPath(path);
//		Browser(path, true);
		ItemIdList pidl(path);
		return new DirectoryPath(pidl);
	}

	//Path p(path);
	//if (p.MatchExtension(_T("catalog")) && p.FileExists())
	//	return new CatalogPath(p,
	//ItemIdList pidl(path);
	//return new DirectoryPath(pidl);

	return 0;
}