Article View: borland.public.cppbuilder.database.ado
Article #402Re: Getting ADO events in a DLL???
From: s.kenwrick
Date: Wed, 18 Oct 2006 20:34
Date: Wed, 18 Oct 2006 20:34
42 lines
2645 bytes
2645 bytes
Solved it!
I fixed the problem by creating an invisible FORM from the
initialization code when the DLL is loaded from the main VCL thread.
In this form I added a message handler by adding code in the public
section like this:
#define TM_ADOCONN (WM_APP + 401)
class TForm1 : public TForm
{
public: // User declarations
__fastcall TForm1(TComponent* Owner);
void __fastcall F_ADOConn(TMessage & WMsg);
void __fastcall ADOpConnectComplete(TADOConnection* Connection,
const _di_Error Error, TEventStatus &EventStatus);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(TM_ADOCONN, TMessage, F_ADOConn);
END_MESSAGE_MAP(TForm)
};
Then from my background thread I set up a structure with all the
appropriate information and send a message to the F_ADOConn() function
with the LParam as a pointer to this structure using the PostMessage()
function. The F_ADOConn() message handler then gets called from the
main VCL thread and I can create the ADOConnection object, Override the
OnConnectComplete event handler, setup the parameters and open the
connections.
The ADOConnection Event handlers are then triggered as expected from
the main VCL thread.
Its simply a matter now of ensuring that everything is thread safe....
Thanks
Sean
Technical Details
Message-ID:
<1161203648.551624.297660@k70g2000cwa.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mailReferences:
<1161099090.459997.102700@m7g2000cwm.googlegroups.com> <453501c8$1@newsgroups.borland.com> <1161161044.174215.269230@k70g2000cwa.googlegroups.com> <45364862$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,b68f8160aec90a52 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail From: s.kenwrick@btinternet.com Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Getting ADO events in a DLL??? Date: 18 Oct 2006 13:34:08 -0700 Organization: http://groups.google.com Lines: 43 Message-ID: <1161203648.551624.297660@k70g2000cwa.googlegroups.com> References: <1161099090.459997.102700@m7g2000cwm.googlegroups.com> <453501c8$1@newsgroups.borland.com> <1161161044.174215.269230@k70g2000cwa.googlegroups.com> <45364862$1@newsgroups.borland.com> NNTP-Posting-Host: 86.146.221.59 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1161203654 7590 127.0.0.1 (18 Oct 2006 20:34:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 18 Oct 2006 20:34:14 +0000 (UTC) In-Reply-To: <45364862$1@newsgroups.borland.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; YPC 3.0.2; FDM),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: k70g2000cwa.googlegroups.com; posting-host=86.146.221.59; posting-account=yWLP7w0AAACaPihRkBtT0_EvcWbbMTaJ