|
-
August 15th, 2005, 05:12 PM
#1
How to detect ctrl-c pressed?
I created a new dialog based project and added OnKeyDown() message handler, but no matter what I pressed, it never got called?
-
August 15th, 2005, 05:22 PM
#2
Re: How to detect ctrl-c pressed?
override PreTranslateMessage and do:
Code:
BOOL CDlg::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN && pMsg->wParam == 0x43 && GetKeyState( VK_CONTROL ) < 0 ) {
_asm int 3
}
return CDialog::PreTranslateMessage(pMsg);
}
regards
Last edited by neo_the_1; August 15th, 2005 at 05:31 PM.
-
August 15th, 2005, 05:28 PM
#3
Re: How to detect ctrl-c pressed?
when I used your code and press ctrl-c, the code inside got executed when the "ctrl" key was hold, and nothing happened after "c" pressed.
-
August 15th, 2005, 05:32 PM
#4
Re: How to detect ctrl-c pressed?
try again i have made a change.
-
August 15th, 2005, 05:41 PM
#5
Re: How to detect ctrl-c pressed?
Thanks that works. so 0x43 is the virtual key code for ctrl-c? how about ctrl-v? where did you find the table?
-
August 15th, 2005, 05:43 PM
#6
Re: How to detect ctrl-c pressed?
Virtual-Key Codes from MSDN.
Enjoy.
-
August 15th, 2005, 11:22 PM
#7
Re: How to detect ctrl-c pressed?
This approach works for CDialog, I assume it works the same way in CView. However, when I out the CView into ActiveX Control, it never got called. Do you know why?
-
August 16th, 2005, 01:54 AM
#8
Re: How to detect ctrl-c pressed?
 Originally Posted by tangjun
This approach works for CDialog, I assume it works the same way in CView. However, when I out the CView into ActiveX Control, it never got called. Do you know why?
it never get called cause this ActiveX probably not handling Ctrl+C key press. only the the window that Handle it can get it while it in focus of course.
if you want to detect Ctrl+C in all the system no matter what window is active (at the moment ) you can consider using ::SetWindowsHookEx (..) with WH_KEYBOARD parameter to check it out.
Cheers
-
August 16th, 2005, 10:58 AM
#9
Re: How to detect ctrl-c pressed?
However, the OnKeyDown() does get called in activeX control. Can you detect ctrl-c with OnKeyDown()?
I don't want to set it system wide because there are other window than the activex control in the system which is using the contrl-c.
Last edited by tangjun; August 16th, 2005 at 11:10 AM.
-
August 16th, 2005, 02:12 PM
#10
Re: How to detect ctrl-c pressed?
Why don't you just setup an Accelerator to handle Ctrl+C?
-
August 17th, 2005, 09:36 AM
#11
Re: How to detect ctrl-c pressed?
-
August 17th, 2005, 11:16 AM
#12
Re: How to detect ctrl-c pressed?
 Originally Posted by tangjun
However, the OnKeyDown() does get called in activeX control. Can you detect ctrl-c with OnKeyDown()?
I don't want to set it system wide because there are other window than the activex control in the system which is using the contrl-c.
if you want a system wide then OnKeyDown() is not the correct way. i wrote in my post before if you want a system wide keybaord hook you need to use ::SetWindowsHookEx(..) with WH_KEYBOARD.
Cheers
-
August 18th, 2005, 09:07 PM
#13
Re: How to detect ctrl-c pressed?
no, I don't want system wide, my system will have more than one activex control, each one should handle the control-c by itself. so if ctrl-c pressed, the highlighted one should get called.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|