?
Solved

Don't forget about me :)

Posted on 2002-07-04
3
Medium Priority
?
236 Views
Last Modified: 2010-04-04
Please take another look at this question (about adding controls to a ShBrowseForFolder dialog):

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20316902

If you can help me you'll now get 300pts!

Please :) Everyone seems to forget about a question after a couple of days (or give up?).

I'll give some extra information:

This is the Callback function:

===begin of code===

function BrowseCallBackProc(Hwnd: Hwnd; UMsg: UINT; lParam: lParam; lpData: lParam): Integer; stdcall;
begin
case UMsg of
     BFFM_INITIALIZED: begin
                       browseNewDirBtn := TButton.CreateParented(Hwnd);
                       browseNewDirBtn.Caption := 'Into new dir...';
                       browseNewDirBtn.Top := 269;
                       browseNewDirBtn.Left := 10;
                       browseNewDirBtn.Visible := true;
                       ShowWindow(browseNewDirBtn.Handle, SW_SHOWNORMAL);
                       browseNewDirBtn.OnClick := Form1.MakeNewSubDir;
                       browseHandle := Hwnd;
                       end;
     BFFM_SELCHANGED:  begin
                       if (lpData <> 0) then
                       begin
                       ShGetPathFromIDList(PItemIDList(lpData), currSelectedFolder);
                       end else
                           currSelectedFolder := '';
                       end;
end;
Result := 0;
end;

===end of code===

To try things out first, the Form1.MakeNewSubdir procedures simply shows a MessageBox (that doesn't matter much, because the procedures isn't even called). So, nothing happens if you click it.
0
Comment
Question by:herr_apfelschnitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Cynna earned 400 total points
ID: 7130813
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(Form2.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;
0
 
LVL 7

Expert Comment

by:Cynna
ID: 7130817
Oops,

sorry,  
 
 Form2.Font.Handle

should, of course, be:

 Form1.Font.Handle
0
 
LVL 1

Author Comment

by:herr_apfelschnitt
ID: 7131355
Great! It works now :)

Thanks!!!

Could you please post a comment on my previous question (see link above) so I can accept it as an answer?
(and IF possible, tell me if you can "update" the ShBrowseForFolder dialog, or you just have to close it and call ShBrowseForFolder again). You've earned the points anyway, it's just that this would be convenient to now and I'm kind of running out of points, you see :)
I'll give you these 100 already and the remaining 200 after you posted a comment on

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20316902

Thanks again!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

719 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