🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Paste

#11991
From: Remy Lebeau (TeamB)
Date: Sat, 03 Jan 2004 02:20
31 lines
1904 bytes
"Todd Brylski" <tbrylski@yahoo.com> wrote in message
news:3ff61911$1@newsgroups.borland.com...

>     HWND hWnd = ::FindWindow( 0, "untitled - notepad" );

FindWindow() is case-sensitive, so that should be this instead:

    HWND hWnd = ::FindWindow( 0, "Untitled - Notepad" );

Alternatively, you can do what Jelsma suggested - enumerate the windows,
then you don't need to worry about the window title at all.

>         ::PostMessage( hWnd, WM_COMMAND, WM_PASTE, 0 );

That is not correct.  First, WM_PASTE is its own message, it is not part of
WM_COMMAND:

    ::PostMessage( hWnd, WM_PASTE, 0, 0 );

Second, you are sending the message to the wrong window.  Your code found
the main Notepad window, but you need to post the message to the actual
child edit control inside that window instead.  Use FindWindowEx() to get
that HWND, ie:

    HWND hEdit = FindWindowEx( hWnd, NULL, "Edit", NULL );
    if( hEdit )
        ::PostMessage( hEdit, WM_PASTE, 0, 0 );


Gambit
Technical Details
Message-ID: <3ff625ac$2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3ff5f6bc$2@newsgroups.borland.com> <3ff61911$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,fdb8783d5e192556
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-02 18:39:42 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ff5f6bc$2@newsgroups.borland.com> <3ff61911$1@newsgroups.borland.com>
Subject: Re: Paste
Date: Fri, 2 Jan 2004 18:20:46 -0800
Lines: 33
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.139.199
Message-ID: <3ff625ac$2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1073096108 67.22.139.199 (2 Jan 2004 18:15:08 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail