Link to home
Start Free TrialLog in
Avatar of herr_apfelschnitt
herr_apfelschnitt

asked on

Additional button on ShBrowseForFolder dialog

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?)
Avatar of Cesario Lababidi
Cesario Lababidi
Flag of Germany image

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
Avatar of herr_apfelschnitt
herr_apfelschnitt

ASKER

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
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
const
  BIF_USENEWUI = 28;
Sorry, this doesn't solve anything. The dialog just looks a bit different, but the button keeps ignoring clicks...
ASKER CERTIFIED SOLUTION
Avatar of Cynna
Cynna

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi everyone,

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

https://www.experts-exchange.com/questions/20319670/Don't-forget-about-me.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