Solved

Don't forget about me :)

Posted on 2002-07-04
3
229 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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