Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SHBrowseForFolder ? ... ja schon wieder!!!

Empfohlene Antworten

Veröffentlicht

Ok,

folgeden Fragestellung ist zu der Shellfunktion hier wohl noch nicht erörtert worden:

Kann man einen Aufgeklappten Baum vorbelegen? Soll heissen, gibt es eine

Möglichkeit den Dialog zu öffnen, so dass er einen Pfad ausgeklappt hat.

z.B. soll c:\winnt\system32 vorbelegt sein.

Ich meine nicht das Wurzelverzeichnis, dass mit

LPCITEMIDLIST pidlRoot;

aus BROWSEINFO vorbelegtwerdenkann.

Ich hoffe ich habe mich nicht zu kompiziert ausgedrückt.

Ciao TinTin

Du musst in der BROWSEINFO-Struktor dem Member lpfn eine Callbackfunktion zuweisen. In dieser kannst du dann auf die Nachricht BFFM_INITIALIZED reagieren und dem Dialog eine BFFM_SETSELECTION-Nachricht schicken.

Den Pfad kannst du z.B. über den lParam-Member der BROWSEINFO-Struktur in die Callbackfunktion bekommen, wie in diesem Beispiel:

int CALLBACK BrowseForFolderCallback(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM pData) 
{
if(BFFM_INITIALIZED == uMsg)
{
SendMessage(hWnd, BFFM_SETSELECTION, TRUE, pData);
}
return 0;
}[/code]

Beachte, dass pData hier auf einen Unicode-String zeigen muss.

http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp

Beachte, dass pData hier auf einen Unicode-String zeigen muss.

Der Faulheit Willen:

Wie bastel ich mir 'nen UNICODE-String???

Ciao TinTin

Vielen Dank!

  • 2 Wochen später...

ich habe meine Callback Funktion jetzt so aufgebaut, aber da tut sich nichts.

Will meinen es wird nichts vorbelegt, bzw. aufgeklappt.

int CALLBACK BrowseCallbackProc(

    HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)

{

	WCHAR pChar[MAX_PATH] = L"d:\\temp\0";


    	if(BFFM_INITIALIZED == uMsg)

	{

			AfxMessageBox("BFFM_INITIALIZED");

			SendMessage(hWnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(pChar));

	}

	return 0;



}

int CALLBACK BrowseCallbackProc(

    HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)

{

    	if(BFFM_INITIALIZED == uMsg)

	{        

			TCHAR szText[MAX_PATH] = {0};

			GetCurrentDirectory(sizeof(szText),szText);


          SendMessage(hWnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(szText));


	}

	return 0;



}

OK, so gehts jetzt. Stelltsich nur abschliesend die Frage, wie übergebe ich am

besten dynamisch einen Pfad über den lParam in die BROWSEINFO?

Wie Übergebe ich das am besten?

TinTin

Der Vollständigkeit halber, so hab ich 's gelöst:


void CMyDlg::OnBuFolder() 

{


    char szBuffer[MAX_PATH];

    LPMALLOC pMalloc = NULL;

    LPITEMIDLIST pidl = NULL;

    BROWSEINFO bi;



    CoInitialize(NULL);

    ZeroMemory(&bi, sizeof(BROWSEINFO));


    bi.hwndOwner = m_hWnd;


    bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_USENEWUI | BIF_EDITBOX | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;

    bi.lpfn = (BFFCALLBACK)&BrowseCallbackProc;

    bi.lParam = (LPARAM)this;


    pidl = SHBrowseForFolder(&bi);

    if (pidl != NULL)

	{

		SHGetPathFromIDList(pidl,szBuffer);


		if (szBuffer[0] == '\0') 

			GetCurrentDirectory(sizeof(szBuffer),szBuffer);

		m_csFolder = szBuffer;


		if (m_csFolder.ReverseFind('\\') != m_csFolder.GetLength()-1)

		{

			m_csFolder += "\\";

		}

	}


	if(SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc)

	{

        pMalloc->Free(pidl);  

        pMalloc->Release(); 

	}

    CoUninitialize();


	UpdateData(FALSE);

}


int CALLBACK CMyDlg::BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)

{

	CName2TagVvDlg* pThis = (CName2TagVvDlg*)lpData;

	ASSERT( pThis != NULL );


    switch(uMsg)

    {

    case BFFM_INITIALIZED:

        {

			TCHAR szText[MAX_PATH] = {0};

			if (!pThis->m_csFolder.IsEmpty())

			{

				strcpy(szText,pThis->m_csFolder);

			}

			else GetCurrentDirectory(sizeof(szText),szText);

			::SendMessage( hWnd,BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(szText));


        }

        break;


    case BFFM_SELCHANGED:

        {

            TCHAR szText[MAX_PATH] = {0};

            SHGetPathFromIDList(reinterpret_cast<LPITEMIDLIST>(lParam), szText);

            ::SendMessage(hWnd, BFFM_SETSTATUSTEXT, 0,reinterpret_cast<LPARAM>(szText));

        }

        break;

    }


    return 0;


}

TinTin

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.