* use TPM_RETURNCMD instead of IDDYNAMIC

* fixed memory leak

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3001 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2010-03-30 11:15:53 +00:00
parent 2327000b9b
commit ae84363b1f
3 changed files with 52 additions and 18 deletions
+25 -18
View File
@@ -216,6 +216,12 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
SendMessage(GetDlgItem(hwndDlg, IDOK), BCM_SETSHIELD, 0, TRUE);
}
break;
case WM_DESTROY:
{
if (context->SessionIdList)
PhDereferenceObject(context->SessionIdList);
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
@@ -352,6 +358,7 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
ULONG i;
RECT buttonRect;
POINT point;
UINT selectedItem;
sessionsMenu = CreatePopupMenu();
@@ -415,7 +422,7 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
menuString = PhFormatString(L"%u", sessions[i].SessionId);
}
AppendMenu(sessionsMenu, MF_STRING, IDDYNAMIC + i, menuString->Buffer);
AppendMenu(sessionsMenu, MF_STRING, 1 + i, menuString->Buffer);
PhDereferenceObject(menuString);
PhAddListItem(context->SessionIdList, (PVOID)sessions[i].SessionId);
@@ -426,28 +433,28 @@ INT_PTR CALLBACK PhpRunAsDlgProc(
GetClientRect(GetDlgItem(hwndDlg, IDC_SESSIONS), &buttonRect);
point.x = buttonRect.right;
point.y = 0;
PhShowContextMenu(hwndDlg, GetDlgItem(hwndDlg, IDC_SESSIONS), sessionsMenu, point);
selectedItem = PhShowContextMenu2(
hwndDlg,
GetDlgItem(hwndDlg, IDC_SESSIONS),
sessionsMenu,
point
);
if (selectedItem != 0)
{
SetDlgItemInt(
hwndDlg,
IDC_SESSIONID,
(ULONG)context->SessionIdList->Items[selectedItem - 1],
FALSE
);
}
DestroyMenu(sessionsMenu);
}
}
break;
default:
{
if (LOWORD(wParam) >= IDDYNAMIC)
{
ULONG index = LOWORD(wParam) - IDDYNAMIC;
if (context->SessionIdList && index < context->SessionIdList->Count)
{
ULONG sessionId;
sessionId = (ULONG)context->SessionIdList->Items[index];
SetDlgItemInt(hwndDlg, IDC_SESSIONID, sessionId, FALSE);
}
}
}
break;
}
}
break;
+20
View File
@@ -349,6 +349,26 @@ VOID PhShowContextMenu(
);
}
UINT PhShowContextMenu2(
__in HWND hwnd,
__in HWND subHwnd,
__in HMENU menu,
__in POINT point
)
{
ClientToScreen(subHwnd, &point);
return (UINT)TrackPopupMenu(
menu,
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
point.x,
point.y,
0,
hwnd,
NULL
);
}
VOID PhSetRadioCheckMenuItem(
__in HMENU Menu,
__in ULONG Id,
+7
View File
@@ -273,6 +273,13 @@ VOID PhShowContextMenu(
__in POINT point
);
UINT PhShowContextMenu2(
__in HWND hwnd,
__in HWND subHwnd,
__in HMENU menu,
__in POINT point
);
VOID PhSetRadioCheckMenuItem(
__in HMENU Menu,
__in ULONG Id,