Article View: borland.public.cppbuilder.nativeapi
Article #17086Re: Sending VK_CONTROL/VK_HOME to a TStringGrid
From: nicolasr
Date: Tue, 08 Apr 2003 20:43
Date: Tue, 08 Apr 2003 20:43
33 lines
1897 bytes
1897 bytes
thanks for your reply! I tried your first suggestion and it works well now. I post the code below in case anyone is interested. I have not tried the second way but I read many posts about issues with SetForegroundWindow() under Win98 and up. The first way seems to be more reliable. thanks again, Nick //assuming hwnd is the window handle of a TStringGrid //in another application DWORD threadId = GetWindowThreadProcessId(hwnd, NULL); DWORD ourThreadId = GetCurrentThreadId(); AttachThreadInput(threadId, ourThreadId, TRUE); unsigned char keyboardState[256]; GetKeyboardState(keyboardState); keyboardState[VK_CONTROL] |= 0x80; SetKeyboardState(keyboardState); SendMessage(hwnd, WM_KEYDOWN, VK_HOME, 0); SendMessage(hwnd, WM_KEYUP, VK_HOME, 0); GetKeyboardState(keyboardState); keyboardState[VK_CONTROL] &= ~0x80; SetKeyboardState(keyboardState); AttachThreadInput(threadId, ourThreadId, FALSE);
Technical Details
Message-ID:
<3e93346e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e921bff$1@newsgroups.borland.com> <3e922c32$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,298cd03bd48ea3ec X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-08 13:48:49 PST From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <3e921bff$1@newsgroups.borland.com> <3e922c32$1@newsgroups.borland.com> Subject: Re: Sending VK_CONTROL/VK_HOME to a TStringGrid Date: Tue, 8 Apr 2003 22:43:51 +0200 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 80.133.172.44 Message-ID: <3e93346e@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049834606 80.133.172.44 (8 Apr 2003 13:43:26 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail