Article View: borland.public.cppbuilder.nativeapi
Article #4186Re: Continuing problem with SendMessage and WM_CCOPYDATA
From: JD
Date: Tue, 28 Feb 2006 19:34
Date: Tue, 28 Feb 2006 19:34
44 lines
2550 bytes
2550 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>> ::GetClassName( FParentForm->Handle, ThisClassName, 255 );
>> hMutex = ::CreateMutex( NULL, TRUE, ThisClassName );
>
> That will only be reliable if the TForm class name is unique
> across all applications.
Yeah. That's not too bad though. We've been living with it.
> A better approach would be to append some kind of process-
> specific data to the mutex name to ensure its uniqueness,
> such as the process ID. Then the TForm class name becomes
> irrelevant and is not needed at all:
>
> char MutexName[32] = {0};
> ::wsprintf(MutexName, "TSingleInstance.%0.10u", GetCurrentProcessId());
> hMutex = ::CreateMutex(NULL, TRUE, MutexName);
But the point is to have the same mutex name for both
processes. Won't that break it?
> [...] but a better approach would be to not track two
> variables at all. You can check the HWND provided by the
> callback to see if it matches the TForm::Handle before
> assuming whether it is the first or second instance.
Good point.
> When did I ever tell you that the TApplication window was
> not important?
Never. My point was that no one thought to use it to get the
window state of the main form.
> If you hook the TApplication window, it could greatly
> simplify your code, since you won't have to hook into any
> particular TForm objects anymore.
I was originally hooking into that but that one line of code
from Dennis means that the component doesn't need to anymore.
~ JD
Technical Details
Message-ID:
<4404b3dc$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44021981$1@newsgroups.borland.com> <44024219$1@newsgroups.borland.com> <44046dac$1@newsgroups.borland.com> <4404a191$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6afbc9bf5041d787 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Continuing problem with SendMessage and WM_CCOPYDATA Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 152.163.100.201 X-Forwarded-For: 172.150.204.143 References: <44021981$1@newsgroups.borland.com> <44024219$1@newsgroups.borland.com> <44046dac$1@newsgroups.borland.com> <4404a191$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <4404b3dc$1@newsgroups.borland.com> Date: 28 Feb 2006 12:34:36 -0700 X-Trace: newsgroups.borland.com 1141158876 207.105.83.66 (28 Feb 2006 12:34:36 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail