473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how catch combination of key??

Hi,

I am working on SDI base application using vs2k5. I need to perform
some task on combination of keys (link ctrl+v). I wrote WM_KEYDOWN
message in my view for control command keys (like Delete, Insert, etc)
but unable to catch combination of keys in WM_KEYDOWN message. I tried
to use GetKeyStatus function in WM_KEYDOWN message but not gets any
positive results. Please guide me, how I can control combination of
keys in WM_KEYDOWN message, like, if I wants to perform some task on
ctrl+v for this, what I do for it??

Regards,

-aims

Apr 9 '07 #1
13 2561
>I am working on SDI base application using vs2k5. I need to perform
>some task on combination of keys (link ctrl+v). I wrote WM_KEYDOWN
message in my view for control command keys (like Delete, Insert, etc)
but unable to catch combination of keys in WM_KEYDOWN message.
For the situation you mentioned you'd normally create an accelerator
entry for the key combination in the application's resource.

Dave
Apr 9 '07 #2

"David Lowndes" <Da****@example.invalidwrote in message
news:3u********************************@4ax.com...
I am working on SDI base application using vs2k5. I need to perform
some task on combination of keys (link ctrl+v). I wrote WM_KEYDOWN
message in my view for control command keys (like Delete, Insert, etc)
but unable to catch combination of keys in WM_KEYDOWN message.

For the situation you mentioned you'd normally create an accelerator
entry for the key combination in the application's resource.
And be sure to call TranslateMessage from your message loop.
>
Dave

Apr 9 '07 #3
For the situation you mentioned you'd normally create an accelerator
entry for the key combination in the application's resource.
It will not work for me because I need to perform some actions on ctrl
+v. I tried following code in WM_KEYDOWN which work on ctrl+shift+v
but not working on ctrl+v.

if(nChar == 'V' && (0x8000 & GetKeyState(VK_CONTROL)))
{
//do some thing
...
}

can you please guide me how i can fix this problem??

Regards,
-aims

Apr 9 '07 #4
>For the situation you mentioned you'd normally create an accelerator
>entry for the key combination in the application's resource.

It will not work for me because I need to perform some actions on ctrl
+v.
What do you mean? That's what accelerators are intended for.
>I tried following code in WM_KEYDOWN which work on ctrl+shift+v
but not working on ctrl+v.

if(nChar == 'V' && (0x8000 & GetKeyState(VK_CONTROL)))
{
//do some thing
...
}
I can't see any apparent reason why that shouldn't work - what code do
you have for the Ctrl+Shift+V case?

Dave
Apr 9 '07 #5
if(nChar == 'V' && (0x8000 & GetKeyState(VK_CONTROL)))
{
//do some thing
...
}
Hi Dave!

This code works when I removed all combination related to Ctrl and
Shift keys from Accelerated. The following entries was in my
accelerated file.
Shift+Insert
Ctrl+C
Ctrl+X
But I am not able to understand why it was not working. I was trying
to control Ctrl+V key combination which was not in my accelerated keys
list. Accelerated key has high priority and then pass to messages??

Apr 10 '07 #6
>if(nChar == 'V' && (0x8000 & GetKeyState(VK_CONTROL)))
>{
//do some thing
...
}

Hi Dave!

This code works when I removed all combination related to Ctrl and
Shift keys from Accelerated.
Can you explain in more detail what you removed?
>The following entries was in my
accelerated file.
Shift+Insert
Ctrl+C
Ctrl+X
By "accelerated file", do you mean the accelerator table resource for
your application - or something else?
>But I am not able to understand why it was not working. I was trying
to control Ctrl+V key combination which was not in my accelerated keys
list.
Which (and what type of) window are you trying to catch these
accelerator key combinations for?

Dave
Apr 10 '07 #7
Dave,
Can you explain in more detail what you removed?
I was making SDI base application and by that time following
information I seen, which includes Ctrl+V as well.

IDR_MAINFRAME ACCELERATORS
BEGIN
"N", ID_FILE_NEW, VIRTKEY,CONTROL
"O", ID_FILE_OPEN, VIRTKEY,CONTROL
"S", ID_FILE_SAVE, VIRTKEY,CONTROL
"P", ID_FILE_PRINT, VIRTKEY,CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY,CONTROL
"X", ID_EDIT_CUT, VIRTKEY,CONTROL
"C", ID_EDIT_COPY, VIRTKEY,CONTROL
"V", ID_EDIT_PASTE, VIRTKEY,CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT
END

After that I was removed ID_EDIT_PASTE resource ID from accelerator
table and try to capture Ctrl+V by code but it was not working.. One
by One I removed all entries from accelerator but WM_KEYDOWN message
start working on when no entry left in accelerator table..
By "accelerated file", do you mean the accelerator table resource for
your application - or something else?
I wrote "accelerator file" by mistaken that is accelerator table..

Regards,
-aims

Apr 10 '07 #8
>Can you explain in more detail what you removed?
>
I was making SDI base application and by that time following
information I seen, which includes Ctrl+V as well.

IDR_MAINFRAME ACCELERATORS
BEGIN
...
END

After that I was removed ID_EDIT_PASTE resource ID from accelerator
table and try to capture Ctrl+V by code but it was not working.
OK, I just wanted to be clear that it was the resource accelerator
table you were referring to.
>One
by One I removed all entries from accelerator but WM_KEYDOWN message
start working on when no entry left in accelerator table.
I don't immediately know why that should be - are you saying that you
don't receive *any* WM_KEYDOWN messages, or just the ones that had
accelerators defined?

Why do you want to do the key detection in code rather than relying on
the existing accelerator & command messages they will create?

Dave
Apr 10 '07 #9
I don't immediately know why that should be - are you saying that you
don't receive *any* WM_KEYDOWN messages, or just the ones that had
accelerators defined?

Why do you want to do the key detection in code rather than relying on
the existing accelerator & command messages they will create?
some how accelerators was not working.. thats why, i was write
WM_KEYDOWN message..

Regards,
-aims

Apr 15 '07 #10
>I don't immediately know why that should be - are you saying that you
>don't receive *any* WM_KEYDOWN messages, or just the ones that had
accelerators defined?

Why do you want to do the key detection in code rather than relying on
the existing accelerator & command messages they will create?

some how accelerators was not working.. thats why, i was write
WM_KEYDOWN message..
I think you should find out why they're (apparently) not working for
you - try using Spy++ to see where the command messages for the
accelerator keystrokes are going.

Dave
Apr 15 '07 #11
I think you should find out why they're (apparently) not working for
you - try using Spy++ to see where the command messages for the
accelerator keystrokes are going.
Hi Dave,

Please guide me, how to use Spy++ to see where the command messages
for the accelerator keystrokes are going?
Will I use "Find Window tool", select Messages Radio button Under
"Show Label" and using Finder Tool check all messages. Is this right
procedure?? Please guide me, In case of wrong.

Regards,

-aims
Apr 15 '07 #12
>Please guide me, how to use Spy++ to see where the command messages
>for the accelerator keystrokes are going?
Will I use "Find Window tool", select Messages Radio button Under
"Show Label" and using Finder Tool check all messages. Is this right
procedure?
Use Log Messages, and its Finder tool to select the top level window
of your application. You can also set the Child Windows check box. In
the messages pane, just select WM_COMMAND. Then try the accelerator
keys and check you do see the command messages being generated.

Assuming you do, then that's proof that the accelerator is working and
you should be able to handle those command messages in your
application.

Dave
Apr 16 '07 #13
Hi,

Right, Thanks Dave.. :)

Regards,
-aims
Apr 16 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
3
by: John | last post by:
Hi, I have to catch the "back" browser's functionality from the menu. I already can catch the key-stroke combination for IE + NS/Firefox and inactivate the mouse right-button, but I still have to...
4
by: lauch2 | last post by:
In a default MFC - dialog based application (VC6.0 or VC7.1), the following try-catch code does not be catched in Release mode, but it is OK for Debug mode. Any compiler/link option is required to...
10
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
2
by: Matthew | last post by:
I want to create a program that runs in the system tray and watches for key combinations (Ctrl. + Shift + 1, for example) and performs an action associated with that combination. The catch is...
6
by: aka_eu | last post by:
I have this problem. I'm trying to get all the valid combination C(N,K) that pass one condition. For example C(5,3) can use in any combination this numbers {1,2,3,4,5} But let's say that I...
2
by: calderara | last post by:
Dear all, What is the best way to catch the user prressig the CTRL- C key combination.. I have try the keypress ans key down event but I am able only to catch one key at a time .. Amy idea ?...
12
by: reycri | last post by:
While the following is allowed: if (a == b) SomeFunction(); else OtherFunction(); The following is not: try
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.