Article View: borland.public.cppbuilder.nativeapi
Article #6677Re: Avoiding multiple programinstances and restore the firstone
From: Vladimir Stefanovic
Date: Fri, 22 Apr 2005 15:57
Date: Fri, 22 Apr 2005 15:57
64 lines
2846 bytes
2846 bytes
> I meant 'the first'.
>
> Example:
> Q: About which instance are you speaking ?
> Possible answers:
> A: The one which started first.
> A: The first one.
> A: The firstone.
> A: The first.
He, he - I overlooked that, and that was easy to understand: first-one.
Somehow I imagined that it was something with: fir(e)stone - fire stone.
Also thank's for the code comments.
--
Best regards,
Vladimir Stefanovic
>
>>>The use of a mutex and after that searching for windows
>>>would be doing twice nearly the same.
>>
>> Yes. I use this, but not sure if that's the best way:
>>
>> bool StartNewInstance( AnsiString NAME, AnsiString MUTEX )
>
> You did not set back the original Title. That is needed
> in case it is the first instance.
>
> What I meant was that you can omit the mutex: (untested)
>
> bool StartNewInstance( AnsiString NAME, AnsiString MUTEX )
> {
> AnsiString OldTitle = Application->Title;
>
> Application->Title = "Something different";
> HWND FirstWnd;
> FirstWnd = ::FindWindow( "TApplication", NAME.c_str() );
> // TApplication ???
>
> if ( FirstWnd )
> {
> if ( ::IsIconic( FirstWnd ) ) ::ShowWindow( FirstWnd,
> SW_SHOWDEFAULT );
> ::SetForegroundWindow( FirstWnd );
> Application->Title = OldTitle;
>
> return ( false );
> }
>
> Application->Title = OldTitle;
>
> return ( true );
> }
>
> But my code comes in handy when the Title is not know.
> And it does not require changing of stringcontents for
> different projects.
>
>
> Hans.
Technical Details
Message-ID:
<42691ee9@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!feeder.xsnews.nl!feeder.news-service.com!tudelft.nl!transit0.news.tiscali.nl!tiscali!newsfeed2.ip.tiscali.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4268dde6$1@newsgroups.borland.com> <4268ff3a$1@newsgroups.borland.com> <42690325$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fd5c6cb9a40ec609 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu> Newsgroups: borland.public.cppbuilder.nativeapi References: <4268dde6$1@newsgroups.borland.com> <4268ff3a$1@newsgroups.borland.com> <42690325$1@newsgroups.borland.com> Subject: Re: Avoiding multiple programinstances and restore the firstone Date: Fri, 22 Apr 2005 17:57:39 +0200 Lines: 66 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 82.117.212.65 Message-ID: <42691ee9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1114185449 82.117.212.65 (22 Apr 2005 08:57:29 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!feeder.xsnews.nl!feeder.news-service.com!tudelft.nl!transit0.news.tiscali.nl!tiscali!newsfeed2.ip.tiscali.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail