Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 29 May 2008 19:22:11 +0200,    group: microsoft.public.win32.programmer.ui        back       


SHBrowseForFolder with initial UNC path and no context menu?   
I use SHBrowseForFolder() for selecting folders, but I don't want the 
context menu because it makes it too easy for novice users to rename folders 
etc.

1: SHBrowseForFolder() without BIF_NEWDIALOGSTYLE don't have a context menu, 
but doesn't  work well with an initial UNC-path (see:
http://www.eggheadcafe.com/software/aspnet/29634013/shbrowseforfolder-questio.aspx)
2: SHBrowseForFolder() with BIF_NEWDIALOGSTYLE have the not wanted context 
menu but works well with initial UNC-path.

Is there a way to either:
A) Make "1:SHBrowseForFolder() without BIF_NEWDIALOGSTYLE" work well with 
initial UNC-path, or
B) Hide/disable the context menu from "2: SHBrowseForFolder() with 
BIF_NEWDIALOGSTYLE"

Best regards from Gaute
date: Thu, 29 May 2008 19:22:11 +0200   author:   Gaute am

Re: SHBrowseForFolder with initial UNC path and no context menu?   
Gaute wrote:
> I use SHBrowseForFolder() for selecting folders, but I don't want the 
> context menu because it makes it too easy for novice users to rename folders 
> etc.
> 
> 1: SHBrowseForFolder() without BIF_NEWDIALOGSTYLE don't have a context menu, 
> but doesn't  work well with an initial UNC-path (see:
> http://www.eggheadcafe.com/software/aspnet/29634013/shbrowseforfolder-questio.aspx)
> 2: SHBrowseForFolder() with BIF_NEWDIALOGSTYLE have the not wanted context 
> menu but works well with initial UNC-path.
> 
> Is there a way to either:
> A) Make "1:SHBrowseForFolder() without BIF_NEWDIALOGSTYLE" work well with 
> initial UNC-path, or
> B) Hide/disable the context menu from "2: SHBrowseForFolder() with 
> BIF_NEWDIALOGSTYLE"

see win32 api newsgroup where it's a classic question.
date: Thu, 29 May 2008 21:00:40 +0200   author:   David

Re: SHBrowseForFolder with initial UNC path and no context menu?   
I cannot find this group on news.microsoft.com using OE.  Where can I find 
it...
Best regards from Gaute



"David"  skrev i melding 
news:g1muel$k5m$1@news.albasani.net...

> see win32 api newsgroup where it's a classic question.
date: Thu, 29 May 2008 21:24:19 +0200   author:   Gaute am

Re: SHBrowseForFolder with initial UNC path and no context menu?   
Gaute wrote:
> I cannot find this group on news.microsoft.com using OE.  Where can I find 
> it...

It's Usenet, not MS
Use any free news server (194.177.96.26, provider one, ...)
date: Thu, 29 May 2008 22:34:31 +0200   author:   David

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"Gaute" wrote:
> I use SHBrowseForFolder() for selecting folders, but I don't 
> want the context menu because it makes it too easy for novice 
> users to rename folders etc.

The correct way to solve it is to give a user appropriate access 
rights. So, if a user shouldn't be changing some of folders, then 
create read-only user. Crippling standard UI because you decided 
that someone is "novice" is rude. Personally, I would be 
disappointed if the program I use imposed its own limitations to 
perfectly valid standard UI.

Now, if you really need this, then you should do following:

1. Provide a hook procedure for "Browse for folder" dialog.
2. On initialization event find the tree-view control that 
displays folders.
3. Subclass the tree-view control.
4. When user right-clicks on a tree-view item, then handle the 
click and do whatever you deem necessary.

HTH
Alex
date: Fri, 30 May 2008 09:38:54 +0300   author:   Alex Blekhman

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"David"  wrote in message 
news:g1muel$k5m$1@news.albasani.net...
> Gaute wrote:
>> I use SHBrowseForFolder() for selecting folders, but I don't want the 
>> context menu because it makes it too easy for novice users to rename 
>> folders etc.
>>
>> 1: SHBrowseForFolder() without BIF_NEWDIALOGSTYLE don't have a context 
>> menu, but doesn't  work well with an initial UNC-path (see:
>> http://www.eggheadcafe.com/software/aspnet/29634013/shbrowseforfolder-questio.aspx)
>> 2: SHBrowseForFolder() with BIF_NEWDIALOGSTYLE have the not wanted 
>> context menu but works well with initial UNC-path.
>>
>> Is there a way to either:
>> A) Make "1:SHBrowseForFolder() without BIF_NEWDIALOGSTYLE" work well with 
>> initial UNC-path, or
>> B) Hide/disable the context menu from "2: SHBrowseForFolder() with 
>> BIF_NEWDIALOGSTYLE"
>
> see win32 api newsgroup where it's a classic question.


It is however a UI question and therefore the answer should be here. Then 
when people search the correct newsgroup (this one) for an answer they get a 
previous answer, instead of being redirected to another newsgroup to search.
date: Fri, 30 May 2008 00:25:22 -0700   author:   Sam Hobbs _change_social_to_socal

Re: SHBrowseForFolder with initial UNC path and no context menu?   
Hi Guate,
This is a quick note to let you know that we are performing research on 
this issue and may need more time to get back to you. I appreciate your 
patience.

Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your 
comments and suggestions about how we can improve the 
support we provide to you. Please feel free to let my manager 
know what you think of the level of service provided. You can 
send feedback directly to my manager at: msdnmg@microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for 
non-urgent issues where an initial response from the community 
or a Microsoft Support Engineer within 1 business day is acceptable. 
Please note that each follow up response may take approximately 
2 business days as the support professional working with you may 
need further investigation to reach the most efficient resolution. 
The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by 
contacting Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
date: Fri, 30 May 2008 08:03:24 GMT   author:   (Charles Wang [MSFT])

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"Alex Blekhman"  skrev i melding 
news:%23FSgl%23hwIHA.516@TK2MSFTNGP04.phx.gbl...
> "Gaute" wrote:
>> I use SHBrowseForFolder() for selecting folders, but I don't want the 
>> context menu because it makes it too easy for novice users to rename 
>> folders etc.
>
> The correct way to solve it is to give a user appropriate access rights. 
> So, if a user shouldn't be changing some of folders, then create read-only 
> user. Crippling standard UI because you decided that someone is "novice" 
> is rude. Personally, I would be disappointed if the program I use imposed 
> its own limitations to perfectly valid standard UI.
>
> Now, if you really need this, then you should do following:
>
> 1. Provide a hook procedure for "Browse for folder" dialog.
> 2. On initialization event find the tree-view control that displays 
> folders.
> 3. Subclass the tree-view control.
> 4. When user right-clicks on a tree-view item, then handle the click and 
> do whatever you deem necessary.
>
> HTH
> Alex

Thanks, you gave me new ideas.  I think this will work (subclassing instead 
of hook):

long CALLBACK BFF_TreeView_SubclFunc( HWND hWnd, UINT uMsg, WPARAM wParam, 
LPARAM lParam ) {
  if( uMsg==WM_INITMENUPOPUP )  {
     Some code to remove menu
    return 0;
  }
  return CallWindowProc( pfnOriBFFWndProc, hWnd, uMsg, wParam, lParam );
}

int CALLBACK BFFCallbackProc(HWND hWnd,UINT uMsg, LPARAM lp, LPARAM pData) {
  if( uMsg==BFFM_INITIALIZED ) { some code to subclass SysTreeView32 }
  return 0;
}

Best regards from Gaute
date: Fri, 30 May 2008 14:48:42 +0200   author:   Gaute am

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"Gaute" wrote:
> Thanks, you gave me new ideas.

You're welcome. :)

> I think this will work (subclassing instead of hook):
> [...]

Yes, look at item #3 in my list.

Alex
date: Fri, 30 May 2008 16:19:50 +0300   author:   Alex Blekhman

Re: SHBrowseForFolder with initial UNC path and no context menu?   
Sam Hobbs wrote:
> >>
> >> Is there a way to either:
> >> A) Make "1:SHBrowseForFolder() without BIF_NEWDIALOGSTYLE" work well with
> >> initial UNC-path, or
> >> B) Hide/disable the context menu from "2: SHBrowseForFolder() with
> >> BIF_NEWDIALOGSTYLE"
> >
> > see win32 api newsgroup where it's a classic question.
>
> It is however a UI question and therefore the answer should be here. Then
> when people search the correct newsgroup (this one) for an answer they get a
> previous answer, instead of being redirected to another newsgroup to search.

No.
This newsgroup is dying since the 2-3 win32 gurus have been chased by
ms.
See history and archives.
For SHBrowseForFolder(), the method has been posted on win32 newsgroup
for ages, like all questions on winapi...
date: Fri, 30 May 2008 07:05:49 -0700 (PDT)   author:   unknown

Re: SHBrowseForFolder with initial UNC path and no context menu?   
wrote in message 
news:dddd2dac-d412-41bf-bfea-995afe4f25d8@p25g2000hsf.googlegroups.com...
> Sam Hobbs wrote:
>> >>
>> >> Is there a way to either:
>> >> A) Make "1:SHBrowseForFolder() without BIF_NEWDIALOGSTYLE" work well 
>> >> with
>> >> initial UNC-path, or
>> >> B) Hide/disable the context menu from "2: SHBrowseForFolder() with
>> >> BIF_NEWDIALOGSTYLE"
>> >
>> > see win32 api newsgroup where it's a classic question.
>>
>> It is however a UI question and therefore the answer should be here. Then
>> when people search the correct newsgroup (this one) for an answer they 
>> get a
>> previous answer, instead of being redirected to another newsgroup to 
>> search.
>
> No.
> This newsgroup is dying since the 2-3 win32 gurus have been chased by
> ms.
> See history and archives.
> For SHBrowseForFolder(), the method has been posted on win32 newsgroup
> for ages, like all questions on winapi...

I don't know what "2-3 win32" is.

I don't know what you mean by "chased"; do you mean that Microsoft does not 
want us to use these newsgroups?

I don't know where the history is at. Is the "archives" the same as previous 
messages? If so, then it would help to know what to search for. Are there 
announcements from Microsoft that the newsgroups are being eliminated?

I do notice low activity for the Windows programming newsgroups. I do see 
many Windows programming questions in the MSDN VC forums. Microsoft 
officially considers Windows programming questions to be off-topic in the 
MSDN VC forums, yet they provide little support of the newsgroups. If they 
intend to eliminate the newsgroups then that means they are providing no 
official mechanism for developers to help each other with Windows 
programming questions.
date: Fri, 30 May 2008 09:54:04 -0700   author:   Sam Hobbs _change_social_to_socal

Re: SHBrowseForFolder with initial UNC path and no context menu?   
This became my implementation - it is tested on XP and Vista:


static WNDPROC pfnOrigBFFTreeProc  = NULL;

static long CALLBACK
BFFTreeSubclProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
  if( uMsg == WM_INITMENUPOPUP ) {
    CMenu *pMenu = CMenu::FromHandle( HMENU(wParam) );

lblRestart :
    for( int i=0; i<pMenu->GetMenuItemCount(); i++ ) {
      int id = pMenu->GetMenuItemID(i);
      if( id!= 8 /*   XP Expand*/ && id!=9 /*    XP Collapse*/ &&
             id!=19 /*Vista Expand*/ && id!=20 /*Vista Collapse*/)
        if( pMenu->RemoveMenu( i, MF_BYPOSITION ) )
          goto lblRestart;
    }
    return 0;
  }
  return CallWindowProc( pfnOrigBFFTreeProc, hWnd, uMsg, wParam, lParam );
}

int CALLBACK
BrowseCallbackProc(HWND hWnd,UINT uMsg, LPARAM lp, LPARAM pData)
{
  TCHAR szDir[MAX_PATH];

   switch(uMsg) {
      case BFFM_INITIALIZED:
           { HWND hParent = hWnd;
            HWND hCtl = FindWindowEx( hParent, NULL, _T("SHBRowseForFolder 
ShellNameSpace Control"), NULL );
            if( IsWindow(hCtl) ) hParent=hCtl;
            hCtl = FindWindowEx( hParent, NULL, _T("SysTreeView32"), NULL );
            ASSERT( hCtl );
            if( IsWindow(hCtl) && pfnOrigBFFTreeProc != BFFTreeSubclProc ) {
              pfnOrigBFFTreeProc = (WNDPROC) SetWindowLong( hCtl, 
GWL_WNDPROC, (DWORD) BFFTreeSubclProc );
            }
           }
          break;
   }
   return 0;
}

bool MyBrowseForFolder( HWND hParent, CString& sOutPath,  LPCTSTR 
pszInitialDir, LPCTSTR pszTitle )
{
  bool bSelected = false;
    LPMALLOC pMalloc;
    if( SUCCEEDED(::SHGetMalloc(&pMalloc)) ) {
      BROWSEINFO bi;  ZeroMemory(&bi,sizeof(bi));

      bi.hwndOwner = hParent;
      bi.lpszTitle = pszTitle;
      bi.ulFlags = BIF_RETURNFSANCESTORS |
                   BIF_RETURNONLYFSDIRS;

      /*if( IsShellDllVersionAtLeast(5,0) )*/ {
        bi.ulFlags |= BIF_NEWDIALOGSTYLE;
        bi.ulFlags |= BIF_NONEWFOLDERBUTTON;
        bi.ulFlags |= BIF_SHAREABLE;
      }

      bi.lpfn = BrowseCallbackProc;
      bi.lParam = (LPARAM) pszInitialDir;

      LPITEMIDLIST pidl = ::SHBrowseForFolder(&bi);
      if( pidl ) {
        TCHAR szDir[MAX_PATH+1];
        if( ::SHGetPathFromIDList(pidl,szDir) ) {
          sOutPath = szDir;
          bSelected = true;
        }
        pMalloc->Free(pidl); // Free the PIDL allocated by 
SHBrowseForFolder.
      }
      pMalloc->Release(); // Release the shell's allocator.
    }
  return bSelected;
}
date: Sat, 31 May 2008 09:49:16 +0200   author:   Gaute am

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"Gaute" wrote:
> This became my implementation - it is tested on XP and Vista:
>
> [...]
>
> lblRestart :
>    for( ... ) {
>      if( ... )
>        if( ... )
>          goto lblRestart;

Beware of goto jumps across scopes. It may be OK with C but may 
lead to all kind of quirks with C++, since compiler may generate a 
code that should work when execution flow exits a scope.

>  return CallWindowProc( pfnOrigBFFTreeProc, hWnd, uMsg, wParam, 
> lParam );

I'd call `DefSubclassProc'. You may be not alone who sublcass the 
control.

> int CALLBACK
> BrowseCallbackProc(HWND hWnd,UINT uMsg, LPARAM lp, LPARAM pData)
> {
>  TCHAR szDir[MAX_PATH];
         ^^^^^
This variable is a) uninitialized and b) never used in the 
function.

>              pfnOrigBFFTreeProc = (WNDPROC) SetWindowLong( hCtl, 
> GWL_WNDPROC, (DWORD) BFFTreeSubclProc );

If your target system is Windows XP and above, you'd better use 
new subclassing routines available with XP's ComCtl32.dll instead 
of `SetWindowLong'. Read here more about them:

"Subclassing Controls"
http://msdn2.microsoft.com/en-us/library/bb773183(VS.85).aspx

See "Subclassing Controls Using ComCtl32.dll version 6" section. 
Also, don't forget to remove your subclass routine in the end.

HTH
Alex
date: Sat, 31 May 2008 11:16:30 +0300   author:   Alex Blekhman

Re: SHBrowseForFolder with initial UNC path and no context menu?   
I have to target Win2k, but thank you.  I didn't know the new preferred way 
for XP and above.

> Also, don't forget to remove your subclass routine in the end.
Why - doesn't it "go away" when the SysTreeView32 window is destroyed...

Best regards from Gaute
date: Sat, 31 May 2008 14:14:32 +0200   author:   Gaute am

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"Gaute" wrote:
>> Also, don't forget to remove your subclass routine in the end.
> Why - doesn't it "go away" when the SysTreeView32 window is 
> destroyed...

Although I don't know the direct answer to this question, here's 
the quote from MSDN:

<quote>
When an application subclasses a subclassed window, it must remove 
the subclasses in the reverse order they were performed. If the 
removal order is not reversed, an unrecoverable system error may 
occur.
</quote>

It implies that an application may (or should?) remove the 
subclasses. To be on the safe side I prefer to revert back 
everything I did with the system: deallocate allocated memory, 
unhook hooked events, unsubclass subclassed windows etc. etc. 
unless it's explicitly stated that revert action is not necessary.

Alex
date: Sat, 31 May 2008 15:38:15 +0300   author:   Alex Blekhman

Re: SHBrowseForFolder with initial UNC path and no context menu?   
> When an application subclasses a subclassed window, it must remove the 
> subclasses in the reverse order they were performed.

I wonder where it is appropriate to remove the subclassing in this special 
case...  I do the subclassing in the ShBrowseForFolder callback function, 
but this callback is not called when the dialog is about to be destroyed so 
it cannot be done here.

It does not seem to be normal, but is it appropriate to remove the 
subclassing in the subclass procedure at WM_DESTROY before calling 
CallWindowProc()?

Gaute
date: Sun, 1 Jun 2008 16:20:49 +0200   author:   Gaute am

Re: SHBrowseForFolder with initial UNC path and no context menu?   
"Gaute" wrote:
> I wonder where it is appropriate to remove the subclassing in 
> this special case...  I do the subclassing in the 
> ShBrowseForFolder callback function, but this callback is not 
> called when the dialog is about to be destroyed so it cannot be 
> done here.
>
> It does not seem to be normal, but is it appropriate to remove 
> the subclassing in the subclass procedure at WM_DESTROY before 
> calling CallWindowProc()?

Yes, I also thought about WM_DESTROY or even WM_NCDESTROY because 
it is the last message received by a window. However, it's 
pointless to unsabclass it on WM_NCDESTROY, since after that a 
window is destroyed and nobody cares anymore.

Probably you was right by not doing anything about unsubclassing 
after all. :)

Alex
date: Sun, 1 Jun 2008 20:11:34 +0300   author:   Alex Blekhman

Re: SHBrowseForFolder with initial UNC path and no context menu?   
ok, thank you :-)
date: Mon, 2 Jun 2008 08:53:26 +0200   author:   Gaute am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us