|
| I've got the DivideByZero error handled but I'd like to explain what was
causing it.
A CBT Hook was placed as a global hook from my VB program using a
PowerBasic DLL I wrote. The purpose of the hook is (at this time) only to
notify me that a window is about to be minimized.
This is a desktop replacement app. There is no taskbar. Windows are
minimized to a thumbnail of the window hDc directly on the desktop, tiled
top-to-bottom & left to right.
I receive the notification that a window is about to be minimized. One of
the params is a handle to the window about to be minimized. I then add a
picturebox (as part of a control array) to 'my' desktop of the
predetermined thumbnail size, call GetWindowRect of the hwnd passed to
me, and then StretchBlt from the desktop hDC using the rect struct as
the source coordinates.
So I would receive the /0 error when trying to minimize XNews, with no
child windows opened it would only be the MDI parent. After examining the
rect structure, even though XNews was maximized at the time, it would
ALWAYS return a top & bottom of 512 and a left & right of 384 (?) maybe,
whatever it doesn't matter. The issus was the return always had the same
top & bottom, and the same left & right no matter what state the window
was in, even minimized.
Adding a GetWindowText debug.print call of the param passed, it always
printed the correct title as well, 'Xnews'. I was dumbfounded. Using
Spy++ and looking at the XNews window always gave me the correct
coordinates, but a different handle to the XNews window than what I was
getting in the call from the hook.
What I did to solve this was calculate the height and width of the rect
returned, and if either was 0 (which it shouldn't since if I can click
the minimize button then window should be at least the height and width
of a button), I call FindWindow(null,WindowText) using the window text
retrieved by calling GetWindowText on the hwnd I was passed from the
hook. This returns a completely different handle than from the hook and
appears to be the actual handle to the GUI window.
(I guess there is a question in here afterall) XNews is written in
Delphi, does anyone know if Delphi use some type of hidden parent window
that all messages are received and dispatched from ? Or could this be a
one-off design of the author of XNews ?
Regards,
DanS
|
|