how they do this ?
| Wed, 2006-03-15 16:37 | |
|
hey
im wondering how they do this: i have an application that works in background (written by some1 else not me ) and this application has key shortcuts for example soft1 + 5... now im making an app that use button '5'. And i return EKeyWasConsumed in my handle key event... even tho i consume key 5 (my app is forgrond) the second app 'know' 5 was hit and do its shortcut stuff... How is it possible ?? and second thing with the same app.. It "says" (play a wav i guess but im not sure) for example "Select" after OK was hit... now i want to say something else (lets say HELLO)... im using MdaAudioPlayerUtility to play my wav and whats happening: i hit OK then this app says SELECT and after it my app says HELLO.. even i give my player highhest priority (SetPriority(...) ![]() How can they be always first ? how can i make that app not saying anything ! i want just my app say something... Hope all is clear... Thanks for reading and answering ![]() BG |
|








Forum posts: 1246
I am sure there could be several ways to achieve that.
But I know of one way to always be "first" to see all keyboard and pen events. (if the device supports a pen)
This is to write a CAnimDll window server plugin.
It is originally ment for animated content, but also has the very usefull feature of being able to listen to all user events, AND can modify them, before they reach any application.
I've used CAnims in a number of unconventional ways... they are very useful
Forum posts: 101
for now i have no idea how to use canimdll to catch key events.. but mabye i v not read enough
BG
Forum posts: 1246
Then read the manual, and note the interface available to your derived class, the MAnimGeneralFunctions. Via that, you can enable raw events to you anim, and then you just implement the OfferRawEvent() function.
The manual actually has quite a lot of information on how to write these. But if you get stuck, feel free to ask.
Forum posts: 723
Thx,
tOtE
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 53
The background app, gets they keys first, and then "recycle" them in the event stack (so that your app will receive them).
Forum posts: 2
Forum posts: 1246
TUint32 h = (TUint32)DummyWindowGroup;
User::LeaveIfError(DummyWindowGroup->Construct(h,EFalse));
DummyWindowGroup->SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront );
RWindow* DummyWindow = new (ELeave) RWindow(WsSession);
User::LeaveIfError(DummyWindow->Construct(*DummyWindowGroup,(TUint32)DummyWindow));
RAnimDll* AnimDll = new (ELeave) RAnimDll(WsSession);
err = AnimDll->Load(KMyAnimDll);
RMyAnim* myAnim = new (ELeave) RMyAnim(*AnimDll,*DummyWindow);
The app/exe in the background could then be written in numerous ways depending on what other requirements you have.
Forum posts: 723
TUint32 h = (TUint32)DummyWindowGroup;
User::LeaveIfError(DummyWindowGroup->Construct(h,EFalse));
DummyWindowGroup->SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront );
RWindow* DummyWindow = new (ELeave) RWindow(WsSession);
User::LeaveIfError(DummyWindow->Construct(*DummyWindowGroup,(TUint32)DummyWindow));
RAnimDll* AnimDll = new (ELeave) RAnimDll(WsSession);
err = AnimDll->Load(KMyAnimDll);
RMyAnim* myAnim = new (ELeave) RMyAnim(*AnimDll,*DummyWindow);
Some optimisation:
- R objects usually don't require too much memory so you can simply put them on the stack. That is, don't use new (ELeave) with R objects, but a simple RAnimDll animDll will always do.
- If you still insist on having R objects allocated on the heap, then don't forget to use the cleanup stack properly. For example, above code is prone to error: if one function leaves then all other, previously created objects that are not on the cleanup stack will be lost resulting in a memory leak.
tOtE
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/
Forum posts: 1246
A thought though, how do you suggest to do the error handling in this case?
Just changeing to stack variables isn't enough to solve it all together is it?
Say that the creation of the DummyWindow fails and leaves.
Wouldn't that leave the DummyWindowGroup open (Close() is never called), resulting in a probable memory leak?
So I see it as.. Either allocate on heap and put on cleanupstack, and use leaveiferror,
or
Use stackvariables, and check all error codes, and call close on anything needing it for every function.
Forum posts: 723
or
Use stackvariables, and check all error codes, and call close on anything needing it for every function.
Correct.
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/