Solved

Add a button to ALL Windows...

Posted on 2004-09-18
7
232 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Arrummzen
  • 3
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
Comment Utility
0
 
LVL 1

Author Comment

by:Arrummzen
Comment Utility
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
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
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.
0
 
LVL 1

Author Comment

by:Arrummzen
Comment Utility
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
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
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.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now