Board index » delphi » Calling a function in main app from a DLL
Alan Hale
![]() Delphi Developer |
Wed, 19 Jun 2002 03:00:00 GMT
|
Alan Hale
![]() Delphi Developer |
Wed, 19 Jun 2002 03:00:00 GMT
Calling a function in main app from a DLL
I need to write a DLL that will show a modeless form with a listbox, and
trigger a function in the calling application when each time an item in the listbox is selected. I know how to set up the modeless form and how to query which item is selected through a function exported from the DLL - but I cant see how to get the next step - i.e. triggering a function in the calling application each time the selected item is changed. I don't know whether it can even be done, but I'd be grateful for any advice. (The DLL would be for use with a non-Delphi application - actually one written in Mapbasic). Happy New Year! Alan Hale |
Finn Tolderlun
![]() Delphi Developer |
Wed, 19 Jun 2002 03:00:00 GMT
Re:Calling a function in main app from a DLLIt is possible. Basically you just call a procedure in your DLL, passing the address in a pointer as a parameter to your call-back function. Now the DLL knows what adress to call and can do so when needed. Look in the help under "pointers, procedure and method". Finn Tolderlund Alan Hale <adh...@clara.net> skrev i en Quote> I need to write a DLL that will show a modeless form with a listbox, and |
Alan Hal
![]() Delphi Developer |
Thu, 20 Jun 2002 03:00:00 GMT
Re:Calling a function in main app from a DLLFinn Many thanks for your reply on this. However, I still have problems I can see (I think!) how one would pass a pointer as a parameter in the This is new territory for me so any further help you (ora nynoe) can offer Many thanks. Alan Hale QuoteFinn Tolderlund wrote: |
Finn Tolderlun
![]() Delphi Developer |
Thu, 20 Jun 2002 03:00:00 GMT
Re:Calling a function in main app from a DLLAlan Hale <adh...@clara.net> skrev i en Quote> Many thanks for your reply on this. However, I still have problems Anyway, I have cooked up a simple example for you using a form in a DLL. Have fun with it. Finn Tolderlund Project1: uses {$R *.RES} begin =====Unit1.pas===== interface uses type var procedure Callback(Number: Integer); implementation {$R *.DFM} uses procedure TForm1.Button1Click(Sender: TObject); procedure Callback(Number: Integer); end. =====Unit2.pas===== interface uses const procedure VisDllFormModal; type var implementation procedure VisDllFormModal; procedure SetCallbackProcedure(Address: pointer); initialization DLL: uses {$R *.RES} begin =====DllUnit1.pas===== interface uses type var procedure VisFormModal; stdcall; exports implementation {$R *.DFM} procedure VisFormModal; stdcall; procedure TDllForm1.Callback_ButtonClick(Sender: TObject); procedure SetCallbackProcedure(CallbackAddress: pointer); stdcall; initialization |
VBDi
![]() Delphi Developer |
Fri, 21 Jun 2002 03:00:00 GMT
Re:Calling a function in main app from a DLLIm Artikel <386E6C85.A8FDE...@clara.net>, Alan Hale <adh...@clara.net> schreibt: Quote>The DLL would be for use with a non-Delphi application - function to the DLL. If not ... :-( DoDi |
Nick Gab
![]() Delphi Developer |
Sat, 22 Jun 2002 03:00:00 GMT
Re:Calling a function in main app from a DLLThe most reliable way is to place the procedure to be called back to in a com object within the app then anything can call it. But it took a few weeks of screaming and tearing my hair out to work it all out. It does work perfectly though. Nick QuoteAlan Hale wrote: |
1. DLL call a function in the calling app?
2. Call function in main from DLL?
3. pass a function called in a dll to the main program
4. Call a function in main from DLL?
5. DLL calling a function in the calling EXE
6. Questions about calling a DLL functions and shellnotifyicon() function
7. Pointer to a function or call a function inside EXE from a DLL
9. dll error from call in Borland app but not Visual C++.NET app