Solved

RegisterHotKey examples ?

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

Thanks !
0
Comment
Question by:KAbbott
  • 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 10 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 114
Socket Programming (Unix) 8 119
Better understanding on C++ Class serialization and formats 9 61
Beginner to Unreal Engine 4 5 62
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now