• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

How to get CHotKeyCtrl text?

I want to show in my app title hotkey text (for example "Ctrl+F12") but could not obtain it from CHotKeyCtrl. How can i do this?
0
mikle081198
Asked:
mikle081198
1 Solution
 
Answers2000Commented:
CHotKeyCtrl lets the user select a hot key - it isn't to find out background info for your app (e.g. hot key used to start it) - it sounds a bit like you may have misunderstood what this class is for ?

to get the text from a hot key control using the GetWindowText member

CString strText ;
m_hotKey.GetWindowText( strText ) ;

CHotKeyCtrl derives off CWnd, so all the CWnd members exist for it too...(such as GetWindowText)
0
 
mikle081198Author Commented:
Unfortunately neither GetWindowText nor DetDlgItemText does not work. :(
0
 
prasanthCommented:
If GetWindowText doesn't work, then probably you can't get the text from it (HotKey is probably using an internal variable to store the text rather then the window text). But what you can do is get the virtual key code using GetHotKey and interpret it yourself to generate the caption text.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
mikle081198Author Commented:
Yes i can do it but i'm searching more direct method, without interpreting hotkey value.
0
 
mikeblasCommented:
The hot key control doesn't support directly getting the window text. GetWindowText() (or its pal, WM_GETWINDOWTEXT) wosn't work.

However, you can use the GetKeyNameText() API to translate from a scan code to a localized representation of they key name. You can get the virtual code off the control by calling the GetHotKey() member, and you can translate to a virtual key by calling MapVirtualKey().

B ekiM
0
 
mikle081198Author Commented:
As I see there is no direct way to get this text so I have to accept this answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now