Re: Non-Client Area Dead after Form is Subclassed

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Are you returning the value from the default procedure, in those messages
that you're choosing not to process yourself? Without seeing all your code,
guesses are about all that can be offered. For code that's tried-and-true,
no ambiguity there(!), this is what I use:

http://vb.mvps.org/samples/HookMe


--
Working without a .NET?
http://classicvb.org/


Joseph Geretz wrote:
I'm Subclassing a VB6 Form. To eliminate any ambiguity, I'll be
precise: I am replacing the window procedure with my own function.

Here's our function signature. This function is in a BAS module.
(Let's not start *that* discussion, or if you like, fine - but maybe
in a different thread? :-)

Public Function XHookProc(ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long

O'Reilly calls this Subclassing. Call it as you wish :-)

The code I'm using has been tried and tested for about three years
now. However, up until now, we've only placed such hooks on our own
user controls. Again, to focus in on the issue, I'll be very precise.
Up until now we've only used this code to hook those windows which
are comprised of exclusively client area. No border, no title, and no
menus.

Now for the first time, I'm hooking an entire VB Form. I'm finding
that the hook goes into place properly. I'm getting the notification
for all the messages I expect. I'm not suppressing these messages,
I'm forwarding them on to the default message handler which was in
place at the time I set my own hook into place. Here's what I'm
observing:

All client area widgets behave as expected. Buttons get pressed,
Checkboxes get checked, Textboxes accept text, etc, etc. Meanwhile,
I'm using DebugView from SysInternals and I see a bazillion of my own
messages for intercepted Windows messages being output from my
application. Clearly I'm getting the messages and clearly I'm passing
them on.

However, the non-client area of my form seems to be dead. Here's what
I've observed not working:

Title Bar caption vanishes after another window is dragged across it.
Control Boxes are dead.
Windows border is dead - can't be resized. (Mouse doesn't even change
shape when positioned over border area.)
Message Boxes are dead. MsgBox "Click Me!" effectively locks up the
app, since it can't be dismissed.
Top level menus can't be clicked, although they can be accessed with
their Alt-Key combinations.

I've attached two Log files from Microsoft Spy++ which show a mouse
click on the title area of the form. Before being subclassed, the log
shows hits to what is defined as HTCAPTION - OK, makes sense.
However, after being subclassed, the log shows hits to what is
defined as HTNOWHERE. I suspect that this may be a clue to the
problem.

I've been on this for over a day now. If you can help me out with
this, I'll be most grateful for your assistance.

Thanks!

- Joseph Geretz -



.



Relevant Pages

  • Re: Detect Application Launch
    ... > do it more elegantly via a hook if such a method were available. ... 'Register this form with Windows to receive the ShellHook message ... Private Declare Function RegisterShellHookWindow Lib "user32" (ByVal hwnd As ...
    (microsoft.public.vb.winapi)
  • Re: Hooks
    ... Now I have set the hook I am getting those messages. ... Gary Chanson (Windows SDK MVP) ... Is that thread id is possible for these concept (all child windows ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Hooks
    ... Gary Chanson (Windows SDK MVP) ... Which type hook I need to use for this? ... Is that thread id is possible for these concept (all child windows ...
    (microsoft.public.win32.programmer.gdi)
  • Re: MOUSEHOOKSTRUCTEX.mouseData contains garbage on Windows 7 64 bit on 32 bit application
    ... Lucky that Windows loader seems to ignore it. ... FILE HEADER VALUES ... 32 bit word machine ... I had utility which set global WH_MOUSE hook using SetWindowsHookEx. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Layered drawing in a control?
    ... Sure you can put a border. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... be painted always in the same position,even when we are scrolling the ...
    (microsoft.public.dotnet.framework.windowsforms)