 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Jul 05, 2008 12:01 pm Post subject: WM_CONTEXTMENU problem |
|
|
I'm trying to add a system system tray icon for my program but it won't show the menu. I'm not sure if I'm putting WM_CONTEXTMENU in the wrong place, but it could also be my menu. Here is my code for adding an icon and showing the menu and the message handler part.
| Code: |
void CreateIcon() {
NOTIFYICONDATA nid;
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hWnd;
nid.uID = SYSTRAY;
nid.uFlags = NIF_MESSAGE | NIF_ICON;
nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);
nid.uCallbackMessage = SYSTRAYMSG;
ShowWindow(hWnd, SW_HIDE);
Shell_NotifyIcon(NIM_ADD, &nid);
}
void ShowMenu() {
POINT point;
GetCursorPos(&point);
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, KILLPROCESS, "Kill Process");
AppendMenu(hMenu, MF_SEPARATOR, 1, 0);
AppendMenu(hMenu, MF_STRING, RESTORE, "Restore");
AppendMenu(hMenu, MF_STRING, EXIT, "Exit");
SetForegroundWindow(hWnd);
TrackPopupMenu(hMenu, TPM_BOTTOMALIGN, point.x, point.y, 0, hWnd, NULL);
DestroyMenu(hMenu);
}
|
| Code: |
case SYSTRAYMSG:
switch(LOWORD(lParam)) {
case WM_CONTEXTMENU:
ShowMenu();
break;
}
break;
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jul 05, 2008 12:41 pm Post subject: |
|
|
No the menu is created when the user right clicks the icon. And is filtered through the message defined in his NOTIFYICONDATA
Try filtering for WM_RBUTTONDOWN aswell? _________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Jul 05, 2008 1:42 pm Post subject: |
|
|
Thanks it worked. But I modified my code a little so it would list out the processes. My problem is is that if I right click on my icon it doesn't do the bottom allign that it's supposed to, so it ends up like starting near the top, and you can't see anything. So I was wondering how can I make it not do that, but add a down arrow so you can scroll. Also, how can I make it so that the user can only check one process, and how do I get the process name that the user checked (for killing the process).
| Code: |
void ShowMenu() {
POINT point;
GetCursorPos(&point);
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, KILLPROCESS, "Kill Process");
AppendMenu(hMenu, MF_SEPARATOR, 1, 0);
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
int count = 1;
Process32First(hSnapshot, &pe32);
do {
AppendMenu(hMenu, MF_STRING, count, pe32.szExeFile);
count++;
} while(Process32Next(hSnapshot, &pe32));
AppendMenu(hMenu, MF_SEPARATOR, 1, 0);
AppendMenu(hMenu, MF_STRING, RESTORE, "Restore");
AppendMenu(hMenu, MF_STRING, EXIT, "Exit");
SetForegroundWindow(hWnd);
TrackPopupMenu(hMenu, TPM_BOTTOMALIGN, point.x, point.y, 0, hWnd, NULL);
DestroyMenu(hMenu);
}
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|