Link to home
Start Free TrialLog in
Avatar of Arrummzen
Arrummzen

asked on

Add a button to ALL Windows...

As you know Windows on Microsoft Windows and some other popular OSs have a 'X' button in the uper right hand corrner, how can I add an extra button of that type to all the Windows?

Thank you for your time,
Arrummzen
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arrummzen
Arrummzen

ASKER

Must I set up a hook for each Window? Can I somehow set up a hook that will capture ALL messages that go through Windows?

This is the code I have -
LRESULT WINAPI CALLBACK MyProc( int nCode, WPARAM wParam, LPARAM lParam )
{
      PCWPSTRUCT myData = (PCWPSTRUCT)lParam;

      if ( ctr < 10 )
      {      
            if( myData->message == WM_NCLBUTTONDBLCLK )
            {
                  ::Beep(3000,500);
                  ctr++;
            }
      }

      return CallNextHookEx( g_hHook, nCode, wParam, lParam );
}

Its capturing messages, but I never recieve the WM_NCLBUTTONDBLCLK message.
A: Why don't I recieve this message?
B: What must I do to recive this message?

Thank you for your time,
Arrummzen
I read this code long time ago and don't remember details. I remember only general idea: program installs WH_CBT hook to catch every new window. For each new window program installs WH_CALLWNDPROC hook to handle non-client messages.
But if that is the case the program only works on newly created windows... I would like it to work on all Windows. I suppose I could look through all the open Windows and install the hook, but there should be a better way to do this...

Are you telling me that I must install a WH_CALLWNDPROC hook for each Window? I can't just install one hook for all Windows?

Thank you for your time,
Arrummzen
Well, now I see that code was changed from the time I read it. It doesn't use CBT hook.
If you are trying to catch WM_NCLBUTTONDBLCLK message for all windows, MyProc function should be placed in Dll - this is general requirement for all global hooks. This Dll is attached to every running process and executed in this process context. SetWindowsHookEx and UnhookWindowsHookEx should be called from this Dll.