Found a way around an inefficient comparison method I was using.

This commit is contained in:
ugetab 2010-05-10 23:06:25 +00:00
parent ef4af2ff0e
commit 3a750d276e
2 changed files with 20 additions and 35 deletions

View File

@ -351,35 +351,28 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
break;
case WM_CONTEXTMENU:
{
// Handle certain subborn context menus for nearly incapable controls.
// Convert wParam to a string
sprintf(str,"%08x",wParam);
// Convert HWND of IDC_LIST_CHEATS to a string
sprintf(str2,"%08x",GetDlgItem(hwndDlg,IDC_LIST_CHEATS));
// Compare the now-compatible data with strcmp.
if (!strcmp(str, str2)) {
// Only open the menu if a cheat is selected
if (selcheat >= 0) {
// Open IDC_LIST_CHEATS Context Menu
hCheatcontextsub = GetSubMenu(hCheatcontext,0);
if (lParam != -1)
TrackPopupMenu(hCheatcontextsub,0,LOWORD(lParam),HIWORD(lParam),TPM_RIGHTBUTTON,hwndDlg,0); //Create menu
else { // Handle the context menu keyboard key
GetWindowRect(GetDlgItem(hwndDlg,IDC_LIST_CHEATS), &wrect);
TrackPopupMenu(hCheatcontextsub,0,wrect.left + int((wrect.right - wrect.left) / 3),wrect.top + int((wrect.bottom - wrect.top) / 3),TPM_RIGHTBUTTON,hwndDlg,0); //Create menu
}
case WM_CONTEXTMENU:
{
// Handle certain subborn context menus for nearly incapable controls.
if (wParam == (uint32)GetDlgItem(hwndDlg,IDC_LIST_CHEATS)) {
// Only open the menu if a cheat is selected
if (selcheat >= 0) {
// Open IDC_LIST_CHEATS Context Menu
hCheatcontextsub = GetSubMenu(hCheatcontext,0);
if (lParam != -1)
TrackPopupMenu(hCheatcontextsub,0,LOWORD(lParam),HIWORD(lParam),TPM_RIGHTBUTTON,hwndDlg,0); //Create menu
else { // Handle the context menu keyboard key
GetWindowRect(GetDlgItem(hwndDlg,IDC_LIST_CHEATS), &wrect);
TrackPopupMenu(hCheatcontextsub,0,wrect.left + int((wrect.right - wrect.left) / 3),wrect.top + int((wrect.bottom - wrect.top) / 3),TPM_RIGHTBUTTON,hwndDlg,0); //Create menu
}
}
}
break;
}
break;
case WM_COMMAND:
switch (HIWORD(wParam)) {

View File

@ -1001,7 +1001,7 @@ void LoadGameDebuggerData(HWND hwndDlg = hDebug) {
BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
RECT wrect;
char str[256]={0},str2[256]={0},*ptr,dotdot[4];
char str[256]={0},*ptr,dotdot[4];
int tmp,tmp2;
int mouse_x,mouse_y;
int ret,i;
@ -1171,14 +1171,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
{
// Handle certain subborn context menus for nearly incapable controls.
// Convert wParam to a string
sprintf(str,"%08x",wParam);
// Convert HWND of IDC_LIST_CHEATS to a string
sprintf(str2,"%08x",GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_LIST));
// Compare the now-compatible data with strcmp.
if (!strcmp(str, str2)) {
if (wParam == (uint32)GetDlgItem(hwndDlg,IDC_DEBUGGER_BP_LIST)) {
// Only open the menu if a cheat is selected
if (SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0) >= 0) {
// Open IDC_LIST_CHEATS Context Menu
@ -1191,7 +1184,6 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
TrackPopupMenu(hDebugcontextsub,0,wrect.left + int((wrect.right - wrect.left) / 3),wrect.top + int((wrect.bottom - wrect.top) / 3),TPM_RIGHTBUTTON,hwndDlg,0); //Create menu
}
}
}