Solved

Additional button on ShBrowseForFolder dialog

Posted on 2002-06-27
7
1,083 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
Printing problem 2 95
How to debug For loops? 3 49
Delphi...Split view - idea? 1 68
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

809 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