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
---------------------------------------------------
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.
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...
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...
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...
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...
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...