Solved

Appending the system menu of other windows

Posted on 2009-05-15
2
592 Views
Last Modified: 2012-05-07
I'm writing a program that allows the user to change the priority of the process from the system menu of any window owned by that process. I can add the menu item easily using the AppendMenu or InsertMenuItem APIs from user32, but the WndProc method doesn't catch anything with windows outside my own application
 If I click my menu item that was added to my program's form's system menu, then it raises the event properly. I'm guessing I need to use subclassing (I've seen someone use GetWindowLong) to do this properly, but I can't figure it out.

Any ideas?
Thanks in advance,
Graham
0
Comment
Question by:burningmace
2 Comments
 
LVL 11

Accepted Solution

by:
PlatoConsultant earned 500 total points
ID: 24405382
normally windows get the messages for the current windows only. Here is a sample at code project that will tell you how to catch all messages from other windows...

 

Using Window Messages to Implement Global System Hooks in C#


http://www.codeproject.com/KB/system/WilsonSystemGlobalHooks.aspx



if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_CBT") != NULL)

{

  SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), 

      "WILSON_HOOK_HWND_CBT"), 

      RegisterWindowMessage("WILSON_HOOK_CBT_REPLACED"), 0, 0);

}
 

SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_CBT", destination);

Open in new window

0
 
LVL 5

Author Comment

by:burningmace
ID: 24405405
Thanks. I'll try it out tonight when I get home from work.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

912 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

15 Experts available now in Live!

Get 1:1 Help Now