Solved

Appending the system menu of other windows

Posted on 2009-05-15
2
590 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
Comment Utility
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
Comment Utility
Thanks. I'll try it out tonight when I get home from work.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

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