Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PocketPC ScreenSaver (SetWindowsHookEx)

122 views
Skip to first unread message

Patrick Moreau

unread,
Sep 7, 2001, 12:51:41 AM9/7/01
to
Hi,

I want to create my own screen saver that shutdown the
display when my iPaq is in the cradle.

To do this I want to use the SetWindowsHookEx() that is
located in coredll.dll. I got access to the function
using LoadLibrary and GetProcAddress.

When I call SetWindowsHookEx I always get back error code
87 "invalid parameter". Anyone knows why?

Please don't tell me that Microsoft does not support it
because they are using it for turning off the backlight.

Thanks

Patrick Moreau

Vassili Philippov

unread,
Sep 7, 2001, 2:51:18 AM9/7/01
to
Here is an article from Windows CE Developers FAQ from CEGadgers.com. It
could answer your question.

Vassili Philippov

---------------------------------------------------

10.9 SetWindowsHookEx really does work, sort of.

If you believe the Microsoft documentation, SetWindowsHookEx does not work
under Windows CE. However, if you have read this FAQ you know that
SetWindowsHookEx can be found in coredll (2.11 PSPC and HPC Pro versions
only). The question is, what does it do, and is it a full implementation.

I have been wanting to write an ATL control that passes messages (like
WM_HIBERNATE) to VBCE. One way to do this is to create an ATL control,
implement a connection point, and install a windows hook that monitors the
message queue, and whenever a relevant message appears, fires an event off
to VB. Unfortunately, every combination of

gHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC) MyWndProc, gInstance,
0);

returned an error 87 (incorrect parameter). Further searching through the PB
header files reveals only three hook-related defines:

#define WH_JOURNALRECORD 0
#define WH_JOURNALPLAYBACK 1
#define WH_KEYBOARD_LL 20

So I stopped using WH_CALLWNDPROC and tried WH_KEYBOARD_LL, and found that
it worked quite well. I actually implemented a hook callback that watched
for VK_OFF, and when detected, waited 2 seconds before returning. Whenever I
pressed the power button the device would indeed wait before turning off. I
also attempted to abort the power off by returning a non-zero number from
the hook callback. While this does prevent the power button from powering
off the device, it also causes the device to crash. Besides, VK_OFF is only
generated when the off button is pressed, and not when a device time-out
occurs, so the code was of marginal use. However, if you need to trap other
low-level keyboard commands (ctrl-esc, etc) SetWindowsHookEx might be for
you.

While I imagine journal record and playback are implemented as well, I have
not tried them.


Jan Egil Korsvik

unread,
Sep 7, 2001, 3:13:43 PM9/7/01
to
I have tried this function on PPC and it works well with WH_KEYBOARD_LL.
However, when using the other 2 I always get error 87. Has anybody else
successfully used these? The WH_KEYBOARD_LL only returns lowlevel keyboard
messages. So if you need to catch screen touches or other messages it is
useless.

I am not trying to create a screen saver, but in my program I need to play
and record macros. So, it is crucial to my work to catch these other
messages.

Are there any other way to catch these messages?

Jan K.

Vassili Philippov <va...@spbteam.com> wrote in message
news:ul#grm2NBHA.2076@tkmsftngp05...

Patrick Moreau

unread,
Sep 7, 2001, 7:39:41 PM9/7/01
to
Thanks Guys,

I had read the article before but to no avail. Even with WH_KEYBOARD_LL I
get error 87.

Hell I did a loop on SetWindowsHookEx to go thru possible value of 0 thru 50
but no success.

A friend of mine told me today that the hook function should always be in a
separate DLL. I will try it and post my results.

Back to the writing board...

Patrick

"Jan Egil Korsvik" <jan...@frisurf.no> wrote in message
news:939m7.11584$1T5.1...@news1.oke.nextra.no...

Jan Egil Korsvik

unread,
Sep 8, 2001, 5:27:58 AM9/8/01
to
The function does not have to be in a separate dll. It depends on what you
want to do... It should work both ways.

check out this documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/hh/winb
ase/hooks_7vaw.asp


Jan K.

Patrick Moreau <patric...@internet.look.ca> wrote in message
news:eyA8eZ$NBHA.160@tkmsftngp04...

Patrick Moreau

unread,
Sep 11, 2001, 12:35:09 AM9/11/01
to
Well, after many tries I cannot capture the stylus tap outside of my window
area... I managed to do the button hook no problem; I did need to put the
hook functionality in a separate DLL...

I have now discovered the iPaq SDK from Compaq with interrupt handling on
wakeup of something... who knows it might be my answer...

Thanks to all who tried to help, see you next time

Patrick Moreau

"Patrick Moreau" <patric...@hotmail.com> wrote in message
news:801401c13758$c93d92f0$19ef2ecf@tkmsftngxa01...

Daniel Strickland

unread,
Sep 13, 2001, 12:04:46 PM9/13/01
to
I've learned the tough way that using SetWindowsHookEx is not a wise thing
(particularly in PocketPC's). Apparently SetWindowsHookEx,
UnHookWindowsHook..., and CallNextHook... are all included in coredll.dll, but
they're not fully supported (at least in version 3 of the CE OS). If you set a
windows hook to track keyboard/mouse input on a pocketpc, then you'll find out
that the Character Recognizer SIP doesn't work properly. Any characters that
you try to write that require more than one stroke of the stylus don't come out
properly (only the first stroke is recognized). i's, t's, and other characters
with accents are affected by this. That limitation only affects the Char.
Recognizer SIP and none of the others.

If you're trying to write a screensaver app for CE 2.x, then this approach will
work (because I've done it successfully, and have had a screensaver package out
since Dec. using this method), but otherwise, I wouldn't recommend it for CE 3.
Of course with Merlin coming out in less than a week, maybe they've fixed it in
that version of the OS. I've actually tried several other methods since then,
all of which do not work as effectively as the SetWindowsHook one.

For info on using SetWindowsHook successfully, look at:
http://www.cegadgets.com/wincedevfaq.htm#10.9%20SetWindowsHookEx%20really%20does%20work,%20sort%20of.

The trick was looking through the Platform Builder Header Files to get the right
constants to pass that function, because the constants are defined differently
than in the desktop Win32 API.

HTH.

Daniel Strickland
http://www16.brinkster.com/motbe/

In article <eMNJgsnOBHA.236@tkmsftngp05>, Patrick Moreau says...

0 new messages