Page 1 of 1

How to filter the key event

Posted: Thu Nov 08, 2007 2:27 pm
by chattana
Hello all senior C++ Developers

I want my module writtent in C++ to be notified when 'I' key is pressed. How I filter the keyboard event? I know I should use this function:

int __stdcall OnDDEvent(DWORD EventType, void *EventParams)

The EventType must be DDEVENT_ON_KEYBOARD.
I am gettting stuck with *EventParams,
Should it be LWORD(*EventParams)=='I' ???

Here is the function I modified (but not working for me)

int __stdcall OnDDEvent(DWORD EventType, void *EventParams)
{
if (EventType == DDEVENT_ON_KEYBOARD)
{

if (WPARAM(EventParams)=='I')
{
MessageBox(NULL,"You Press I key",NULL,0);

}
}
return FALSE;
}

Thanks in advance.

Chattana.

Posted: Thu Nov 08, 2007 8:50 pm
by chattana
According to this http://www.dvbdream.org/forum/viewtopic.php?t=582

Rel said that EventParams is the pointer, and we must typecast it. I do know typecast in general, but not in this case to get the correct result.

Could anybody help?

Posted: Fri Nov 09, 2007 2:56 am
by rel
yes, it is a pointer to an integer for DDEVENT_ON_KEYBOARD.


one of the following lines should work in C

*(int *)EventParams

*(int *)(EventParams)

*((int *)(EventParams))





if( *(int *)EventParams == 'I' )
{
MessageBox(NULL,"You Press I key",NULL,0);
}


you can fill/clear the Integer with 0 after processing (if you want DD's not to handle that keyboard key, and you will take care of it in the module)

*(int *)EventParams = 0;

Posted: Fri Nov 09, 2007 12:34 pm
by chattana
Thanks Rel.

This works: *((int *)(EventParams))

I have other question: EventParams always return one value (to be exact, the value = 73) when I press I, i, SHIFT+I, SHIFT+i, CTRL+I, CTRL+i....

Is there anyway to recoginze the lower, and upper key, and the combination with CTRL or SHIFT?

Thanks

Posted: Fri Nov 09, 2007 10:54 pm
by rel
Is there anyway to recoginze the lower, and upper key, and the combination with CTRL or SHIFT?
not yet, unfortunately