Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RegisterHotKey examples ?

Posted on 2000-03-07
7
Medium Priority
?
904 Views
Last Modified: 2008-02-20
Anyone know where there are any full RegisterHotKey example's ??

Thanks !
0
Comment
Question by:KAbbott
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 2595234
Hi KAbbott,

Do not know where you can find examples, but it's use is easy, i.e.:

// registering a hotkey, i.e. ALT-F6 as hot key
ATOM hotKeyAtom = AddGlobalAtom( "MyApp_Hotkey_F6" ); // MSDN suggest using of this to avoid conflicts with hot-key identifiers defined by other shared DLLs
if ( !RegisterHotKey( m_hWnd, hotKeyAtom, MOD_ALT, VK_F6 ) )
{
 TRACE( "Error occured with RegisterHotKey: %i\n", GetLastError() );
}


then you just have to handle the WM_HOTKEY message within you application and do there what you need...

hope that helps,

ZOPPO
0
 
LVL 2

Author Comment

by:KAbbott
ID: 2599713
Is it safe just to handle the message like this:

ON_MESSAGE(WM_HOTKEY, OnHotKey)

then in OnHotKey:

OnHotKey()
{
MessaageBox("HotKey Working...")
}

Is this the right why of doing this ?
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 40 total points
ID: 2599778
Hi KAbbott,

you should pass the message's lParam and wParam to your function somehow like this:


// in class declaration (.h)
BEGIN_MESAGE_MAP(...)
....
afx_msg void OnHotKey( WPARAM wParam, LPARAM lParam );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

// in implementation (.cpp)
BEGIN_MESSAGE_MAP(...)
....
ON_MESSAGE( WM_HOTKEY, OnHotKey )
END_MESSAGE_MAP()

void
CAboutDlg::OnHotKey( WPARAM wParam, LPARAM lParam )
{
 UINT iHotKeyId = (UINT)wParam;
 UINT iOptions = (UINT)HIWORD( lParam );
 UINT iVKeyCode = (UINT)LOWORD( lParam );

 CString t;
 t.Format( "HotKey #%i pressed, (%i+%i)", iHotKeyId, iOptions, iVKeyCode );
 AfxMessageBox( t );
}


hope that helps,

ZOPPO
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:KAbbott
ID: 2604424
Adjusted points to 10
0
 
LVL 2

Author Comment

by:KAbbott
ID: 2604425
Thanks for your help ZOPPO, and as I am called Zippy in the Half-Clan world, nice mame too.
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2604441
no problem      :)

what's a 'half-clan world'? Never heard that...

ZOPPO
0
 
LVL 2

Author Comment

by:KAbbott
ID: 2605721
Oops' I meant Half-Life (game) clan
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

688 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