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
Solved

Don't forget about me :)

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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