Solved

How to get CHotKeyCtrl text?

Posted on 1998-10-15
6
242 Views
Last Modified: 2013-11-20
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
Comment
Question by:mikle081198
6 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1323326
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
 

Author Comment

by:mikle081198
ID: 1323327
Unfortunately neither GetWindowText nor DetDlgItemText does not work. :(
0
 
LVL 2

Expert Comment

by:prasanth
ID: 1323328
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:mikle081198
ID: 1323329
Yes i can do it but i'm searching more direct method, without interpreting hotkey value.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1323330
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
 

Author Comment

by:mikle081198
ID: 1323331
As I see there is no direct way to get this text so I have to accept this answer.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question