Solved

Don't forget about me :)

Posted on 2002-07-04
3
221 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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Cynna earned 100 total points
Comment Utility
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
Comment Utility
Oops,

sorry,  
 
 Form2.Font.Handle

should, of course, be:

 Form1.Font.Handle
0
 
LVL 1

Author Comment

by:herr_apfelschnitt
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now