Article View: borland.public.cppbuilder.nativeapi
Article #16252Re: Make the active program cut/copy/paste
From: Chris
Date: Fri, 23 May 2003 17:59
Date: Fri, 23 May 2003 17:59
85 lines
3917 bytes
3917 bytes
Hello
Thank you for your input, it is much appreciated.
In the win32 developers reference:
An application sends the WM_COPY message to an edit control or combo box to
copy the current selection to the clipboard in CF_TEXT format.
I believe a few weeks back I tried sending WM_COPY messages etc. to programs
like paint shop pro etc. and it didn't work.
Here, take a look at this code...
The problem is the last part.
//ckey is either 'C' 'X' or 'V'
if(ckey)
{
bool vkm, vkc;
//if the user has the key pressed down record it...
//note, we use the most significant bit because we want the current status
of the keys, not if they were pressed before...
vkc = GetAsyncKeyState(VK_CONTROL) & 32768;
vkm = GetAsyncKeyState(VK_MENU) & 32768;
//act like the user lifts up the keys
keybd_event(VK_MENU, 0,KEYEVENTF_KEYUP,NULL);
keybd_event(VK_CONTROL, 0,KEYEVENTF_KEYUP,NULL);
//Act like the user pressed ctrl-C etc.
keybd_event(VK_CONTROL, 0,0,NULL);
keybd_event(ckey, 0,0,NULL);
//have to un-press them for it to take effect
keybd_event(VK_CONTROL, 0,KEYEVENTF_KEYUP,NULL);
keybd_event(ckey, 0,KEYEVENTF_KEYUP,NULL);
//if the keys were down, put them back down
if(vkm)
keybd_event(VK_MENU, 0,0,NULL);
if(vkc)
keybd_event(VK_CONTROL, 0,0,NULL);
}
The problem is the last part.
It puts the keys back down, but many times, after it checked the values and
stored them in vkm and vkc, when the keys were down, the user lifts up the
keys, so by the end of the code its put back down.
I really need the keys to be put back down if the user is still holding
those keys, or up if they are not, and using GetAsyncKeyState etc. doesn't
work because I'm resetting them by using keybd_event.
Thanks again for your help.
----- Original Message -----
From: "Remy Lebeau" <gambit47@yahoo.com>
To: "Chris" <Chris8852@adelphia.net>
Sent: Friday, May 23, 2003 1:36 PM
Subject: Re: Make the active program cut/copy/paste
>
> --- Chris <Chris8852@adelphia.net> wrote:
> > This won't work because WM_COPY etc. is only
> > for CF_TEXT format, I need it for any format.
>
> WM_COPY is not specific to just text. The message
> itself does not perform the actual copying at all. It
> is merely an indication to the recieving window that
> it should copy its contents to the clipboard, it does
> not do anything else. The window itself is
> responsible for copying its own contents to the
> clipboard in response to that message, using whatever
> format(s) it wants (yes plural - the clipboard can
> hold multiple formats at the same time for the same
> data in different representations).
>
>
> Gambit
Technical Details
Message-ID:
<3ece6170@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ecc389a$1@newsgroups.borland.com> <24rpcvkltv996oo0fa80hg4s0p6rlsf009@4ax.com> <3ecd04e5$1@newsgroups.borland.com> <3ecd05c1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,41b72cf95ca3a5fa X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-23 11:10:11 PST From: "Chris" <Chris8852@adelphia.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ecc389a$1@newsgroups.borland.com> <24rpcvkltv996oo0fa80hg4s0p6rlsf009@4ax.com> <3ecd04e5$1@newsgroups.borland.com> <3ecd05c1$1@newsgroups.borland.com> Subject: Re: Make the active program cut/copy/paste Date: Fri, 23 May 2003 13:59:08 -0400 Lines: 87 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: 68.65.164.124 Message-ID: <3ece6170@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1053712752 68.65.164.124 (23 May 2003 10:59:12 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail