Solved

Appending the system menu of other windows

Posted on 2009-05-15
2
593 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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