🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10844

Re: is the window handle always the window handle?

#10844
From: Remy Lebeau (TeamB)
Date: Wed, 10 Mar 2004 19:23
46 lines
2693 bytes
"Mortz" <rmorteo@hotmail.com> wrote in message
news:404f4eb5$1@newsgroups.borland.com...

> Now I'm trying to post messages or issue commands to those
> apps, however it seems like the window handle referes to
> different objects in the window trought time, how can I make
> sure to post the message to the App window directly?

An HWND always points to the same window at all times.  It does not change
value anytime during the lifetime of the window that it points to.  If your
main code is posting to different windows at different times, then you are
working with multiple HWNDs to begin with.

>      //A TTreeNode is passed to the constructor of the thread,
> it contains information about the spawned app

Why not just pass the NodeInfo* pointer itself directly, and leave the
TreeNode alone altogether?

>      while(!Terminated)
>      {
>           LookForWindowHandle(dataPtr); //this funciton is here
> in order to keep the handle updated (is the only way it worked :S)

You should not be re-retrieving the HWND anew each time, especially since a
HWND never changes anyway.  Also, a program may have multiple windows, your
current code would not be guaranteed to find the same HWND each time due to
Z-order changes and such.  You should only be retreive the desired window
once and then keep it.  Don't go re-looking for the window over and over.
It is unnecessary.

    void __fastcall ProcessWatcher::Execute()
    {
         NodeInfo *dataPtr = ...;
        LookForWindowHandle(dataPtr);
        while( !Terminated )
        {
            if( WaitForSingleObject(dataPtr->HProcess(), 10) !=
WAIT_TIMEOUT )
                break;
        }
    }


Gambit
Technical Details
Message-ID: <404f6927$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <404f4eb5$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,6dc76ae9466e5f5
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-03-10 11:41:01 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <404f4eb5$1@newsgroups.borland.com>
Subject: Re: is the window handle always the window handle?
Date: Wed, 10 Mar 2004 11:23:41 -0800
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <404f6927$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1078946087 67.22.138.253 (10 Mar 2004 11:14:47 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail