Solved

Additional button on ShBrowseForFolder dialog

Posted on 2002-06-27
7
1,080 Views
Last Modified: 2007-12-19
I managed to place an extra button ('Create new directory') on the ShBrowseForFolder dialog, but when it doesn't seem to do anything if you click it. The event handler procedure in the parent form isn't called.

Could this have anything to do with the fact that ShBrowseForFolder pauses the execution of the calling program? If not, why doesn't this work? (and of course, how do I fix it?)
0
Comment
Question by:herr_apfelschnitt
7 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 7114059
Hi herr apfelschnitt, ( cooler name )

The April MSDN implies all you need in addition to the standard use of SHBrowseForFolder is this:

    bi.ulFlags = BIF_USENEWUI;

Best Regards

Cesario
0
 
LVL 1

Author Comment

by:herr_apfelschnitt
ID: 7115130
Hi Cesario

I tried that but it won't compile: it says BIF_USENEWUI is undeclared. (btw i'm using Delphi 3 if that has anything to do with it). ShellAPI and ShlObj are both in the 'uses' clause, and BIF_RETURNONLYFSDIRS isn't a problem.

Maybe you can just give me the value it stands for?

Thx,

herr_apfelschnitt
0
 
LVL 1

Author Comment

by:herr_apfelschnitt
ID: 7115139
Hi Cesario

I tried that but it won't compile: it says BIF_USENEWUI is undeclared. (btw i'm using Delphi 3 if that has anything to do with it). ShellAPI and ShlObj are both in the 'uses' clause, and BIF_RETURNONLYFSDIRS isn't a problem.

Maybe you can just give me the value it stands for?

Thx,

herr_apfelschnitt
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:Tasomia
ID: 7115754
const
  BIF_USENEWUI = 28;
0
 
LVL 1

Author Comment

by:herr_apfelschnitt
ID: 7115935
Sorry, this doesn't solve anything. The dialog just looks a bit different, but the button keeps ignoring clicks...
0
 
LVL 7

Accepted Solution

by:
Cynna earned 200 total points
ID: 7131609
Unfortunatly, there is no practical way to refresh
SHBrowseForFolder.
There is one thing, but I don't quite see how is it going
to be of any help....
If you delete folder while parent folder is collapsed,
when you expand parent folder, it will force its refresh.
So you could do a kinf of a hack: create folder, delete
it, and then create it again. *BUT* this has to be done while parent folder is collapsed, which in effect renders
this uselless... just an info.

Also, I don't know what you want to do exactly, but
you might consider using new feature (problem is,
it's introduced only in IE5 and after, so older systems
won't support it). Anyway, if you add flag BIF_NEWDIALOGSTYLE, New Folder feature will be added for you automatically:

const
BIF_NEWDIALOGSTYLE=$0040; // Will create automatically "New Folder" button

use  "... or BIF_NEWDIALOGSTYLE" in your ulFlags.


0
 
LVL 3

Expert Comment

by:darinw
ID: 7132036
Hi everyone,

Cynna provided the answer in a second post from herr_apfelschnitt here:

http://www.experts-exchange.com/delphi/Q_20319670.html

and the answer was:
--begin--

Accepted Answer

From: Cynna
Date: 07/04/2002 05:43PM PST

herr_apfelschnitt,

You are creating a TButton on a non-VCL control, and trying to
use its OnClick event. Generally, using CreateParented() is a
bad idea for anything other then ActiveX.
You should tackle your problem by directly creating button
on foreign window through raw API functions. Message should
be handled by your own window procedure.

Since you offered 300 points, I took time to code your
problem ;-), so you could just Copy/Paste it, it should work
right away...


const
 BUTTON_ID = 255;

var
 browseNewDirBtn : Hwnd; // <-- not TButton any more !

// (....)


function browseNewDirBtn_Clicked(HWindow: HWND; Msg: UINT;
                                wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
 Result:=0;
 if (Msg=WM_COMMAND) and (Lo(wParam)=BUTTON_ID) then begin
   Form1.Caption:='Button Clicked!';
   ShowMessage('Look at the form caption...');
   // ------------------------------
   // ...do your stuff here....
   // ------------------------------
 end
 else Result:=DefDlgProc(HWindow,Msg,wParam,lParam);
end;


function BrowseCallBackProc(H: Hwnd; UMsg: UINT; lParam: lParam; lpData: lParam): Integer; stdcall;
begin
case UMsg of
   BFFM_INITIALIZED: begin // This is only change - no VCL button!
                         browseNewDirBtn := CreateWindow('BUTTON', 'Into new dir...',
                                                      WS_CHILD or WS_VISIBLE,
                                                      10, 269, 100, 30,
                                                      H, BUTTON_ID, HInstance, nil);
                         SendMessage(browseNewDirBtn, WM_SETFONT,
                                     WPARAM(Form1.Font.Handle), 1);
                         SetWindowLong(H,GWL_WNDPROC,Longint(@browseNewDirBtn_Clicked));
                     end;

   BFFM_SELCHANGED:  begin
                     if (lpData <> 0) then
                     begin
                     ShGetPathFromIDList(PItemIDList(lpData), currSelectedFolder);
                     end else
                         currSelectedFolder := '';
                     end;
end;
Result := 0;
end;

--end--

darinw
Former EE CS Guy
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A short film showing how OnPage and Connectwise integration works.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now