CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2005
    Posts
    27

    SHBrowseForFolder with BIF_NEWDIA******** problem

    I'm using SHBrowseForFolder to allow the user to pick a folder and I want to use the new dialog style (BIF_NEWDIA********). When I add this flag, the status text of the dialog will not display. If I don't use this flag, it displays correctly. Is there something I need to do in addition to adding this flag?

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: SHBrowseForFolder with BIF_NEWDIA******** problem

    Quote Originally Posted by SkidMark75
    I'm using SHBrowseForFolder to allow the user to pick a folder and I want to use the new dialog style (BIF_NEWDIA********). When I add this flag, the status text of the dialog will not display. If I don't use this flag, it displays correctly. Is there something I need to do in addition to adding this flag?
    according to MSDN you need to call ::OleInitialize(..) or CoInitialize(...) if you use this flag.

    Quote Originally Posted by MSDN
    To use this flag, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.
    did you do it?

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Aug 2005
    Posts
    27

    Re: SHBrowseForFolder with BIF_NEWDIA******** problem

    Yes, I am calling CoInitialize() prior to calling SHBrowseForFolder(). I just noticed in MSDN that the BIF_STATUSTEXT flag is not supported when BIF_NEWDIA******** is specified.

    http://msdn.microsoft.com/library/de...browseinfo.asp

    Does this mean that setting the status text is not supported or that the flag is just ignored? That probably sounds like a stupid question, but I'm not thinking too clearly after banging my head into the wall for the past few hours.

  4. #4
    Join Date
    Aug 2005
    Posts
    27

    Re: SHBrowseForFolder with BIF_NEWDIA******** problem

    I solved my problem somewhat...

    I added the FindWindowEx and following SendMessage functions:

    Code:
    int CALLBACK BrowseCallbackProc (HWND hWnd, UINT msg,
    							   LPARAM lParam, LPARAM lpData)
    {
    	LPCTSTR pszRootDir = (LPCTSTR)lpData;
    
    	switch(msg)
    	{
    	case BFFM_INITIALIZED:
    		{
    			SendMessage(hWnd,BFFM_SETSELECTION,TRUE,(LPARAM)pszRootDir);
    			HWND hEdit = FindWindowEx(hWnd, NULL, "Edit", NULL);
    			if(hEdit)
    			{
    				SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)pszRootDir);
    			}
    			break;
    		}
    	case BFFM_SELCHANGED:
    		{
    			TCHAR szDir[MAX_PATH];
    			if( SHGetPathFromIDList((LPITEMIDLIST)lParam, szDir))
    			{
    				//				SendMessage(hWnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir);
    				HWND hEdit = FindWindowEx(hWnd, NULL, "Edit", NULL);
    				if(hEdit)
    				{
    					SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)szDir);
    				}
    			}
    			break;
    		}
    	}
    	
    	return 0;
    }
    Last edited by SkidMark75; November 14th, 2005 at 04:37 PM. Reason: attachment

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured