Solved

Additional button on ShBrowseForFolder dialog

Posted on 2002-06-27
7
1,078 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:Tasomia
Comment Utility
const
  BIF_USENEWUI = 28;
0
 
LVL 1

Author Comment

by:herr_apfelschnitt
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

15 Experts available now in Live!

Get 1:1 Help Now