Solved

Don't forget about me :)

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

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

636 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