In order to use the following HotKey class in your own projects, simply copy and paste the two files and save as HotKey.cpp and HotKey.h, include both files in your project, and add a #include "HotKey.h" line in your main.cpp program.

I apologize for the need to copy and paste this, but unfortunately GeoCities won't allow me to upload .cpp files. An alternative solution would have been to put this in a .zip file, however since this is such a short program segment, I thought that was overkill...

If you have any questions/comments, please send me an email at: wkrawec@hotmail.com

HotKey.cpp:
#include "StdAfx.h"
#include "HotKeys.h"

// default constructer... add code here if you like, but not needed really
HotKeys::HotKeys(void)
{
}

HotKeys::~HotKeys(void)
{
}

// This function will call the necessary code needed to allow a user program to trap the hotkeys on a PPC
BOOL HotKeys::SetupHotKeys(HWND hWnd)
{
	HINSTANCE hCoreDLL;
	UnregisterFunc1Proc procUndergisterFunc;
	hCoreDLL = LoadLibrary (_T("coredll.dll"));
	ASSERT(hCoreDLL);

	procUndergisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDLL, _T("UnregisterFunc1"));

	ASSERT(procUndergisterFunc);
	
	for(int i=0xc1; i<0xcf; i++)
	{
		procUndergisterFunc(MOD_WIN, i);
		RegisterHotKey(hWnd, i, MOD_WIN, i);
	}

	FreeLibrary(hCoreDLL);

	return TRUE;
}

HotKey.h:
// HotKeys.h written by Walter O. Krawec, with thanks to the following site for their excellent article on hot key control:
// http://www.pocketpcdn.com/
//
// USAGE: at start of your program(in InitInstance() for example), add the following:
// HotKeys hk;
// hk.SetupHotKeys(hWnd);
//
// later on in your message handler (WndProc()), add this under the 'switch(message) {' line:
//
// case WM_HOTKEY:
//   if(LOWORD(wParam) == LEFT1)
//     // left most button was pressed
//   else if(LOWORD(wParam) == LEFT2)
//     // 2nd button from left was pressed
//   else if(LOWORD(wParam) == RIGHT2)
//     // 3rd button from left was pressed
//   else if(LOWORD(wParam) == RIGHT1)
//     // 4th button from left was pressed
//   break;
//


#pragma once

#include <commctrl.h>
#include <aygshell.h>
#include <sipapi.h>

// The following #define statements define the return values that will be given to your program
// when a hotkey is pressed 
#define LEFT1 193
#define LEFT2 194
#define RIGHT2 195
#define RIGHT1 196

typedef BOOL (__stdcall *UnregisterFunc1Proc)(UINT, UINT);

class HotKeys
{
public:
	HotKeys(void);
	~HotKeys(void);

	BOOL SetupHotKeys(HWND hWnd);
};