Solved

Appending the system menu of other windows

Posted on 2009-05-15
2
595 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 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