Пример #1
0
//==============================================================================
BOOL CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
{
	switch(msg)
	{
		case WM_INITDIALOG: 
		{
			LV_COLUMN lvColumn;
				u8	proc = 0;
				u32 address = 0;
				u32 val = 0;

				cheatListView = GetDlgItem(dialog, IDC_LIST1);

				ListView_SetExtendedListViewStyle(cheatListView, LVS_EX_FULLROWSELECT);
				
				memset(&lvColumn,0,sizeof(LV_COLUMN));
				lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT;
	
				lvColumn.fmt=LVCFMT_CENTER;
				lvColumn.cx=20;
				lvColumn.pszText="X";
				ListView_InsertColumn(cheatListView, 0, &lvColumn);

				lvColumn.fmt=LVCFMT_LEFT;
				lvColumn.cx=84;
				lvColumn.pszText="Address";
				ListView_InsertColumn(cheatListView, 1, &lvColumn);
				lvColumn.cx=100;
				lvColumn.pszText="Value";
				ListView_InsertColumn(cheatListView, 2, &lvColumn);
				lvColumn.cx=200;
				lvColumn.pszText="Description";
				ListView_InsertColumn(cheatListView, 3, &lvColumn);
				lvColumn.fmt=LVCFMT_CENTER;
				lvColumn.cx=45;
				lvColumn.pszText="CPU";
				ListView_InsertColumn(cheatListView, 4, &lvColumn);

				LVITEM lvi;
				memset(&lvi,0,sizeof(LVITEM));
				lvi.mask = LVIF_TEXT|LVIF_STATE;
				lvi.iItem = INT_MAX;

				
				cheatsGetListReset();
				SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)FALSE,0);
				while (cheatsGetList(&tempCheat))
				{
					char buf[256];
					if (tempCheat.enabled)
						lvi.pszText= "X";
					else
						lvi.pszText= "";
					u32 row = ListView_InsertItem(cheatListView, &lvi);
					wsprintf(buf, "0x02%06X", tempCheat.hi[0]);
					ListView_SetItemText(cheatListView, row, 1, buf);
					ltoa(tempCheat.lo[0], buf, 10);
					ListView_SetItemText(cheatListView, row, 2, buf);
					ListView_SetItemText(cheatListView, row, 3, tempCheat.description);
					ListView_SetItemText(cheatListView, row, 4, NAME_CPUs[tempCheat.proc]);
				}
				SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)TRUE,0);

				ListView_SetItemState(searchListView,0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
				SetFocus(searchListView);
			return TRUE;
		}
	
		case WM_COMMAND:
		{
			switch (LOWORD(wparam))
			{
				case IDOK:
				case IDCANCEL:
					EndDialog(dialog, FALSE);
				return TRUE;

				case IDC_BADD:
				{
					searchAddProc = 0;
					searchAddAddress = 0;;
					searchAddValue = 0;
					searchAddMode = 0;
					searchAddFreeze = 1;
					if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsAddProc))
					{
						LVITEM lvi;
						char buf[256];

						memset(&lvi,0,sizeof(LVITEM));
						lvi.mask = LVIF_TEXT|LVIF_STATE;
						lvi.iItem = INT_MAX;

						if (searchAddFreeze)
							lvi.pszText= "X";
						else
							lvi.pszText= " ";
						u32 row = ListView_InsertItem(cheatListView, &lvi);
						wsprintf(buf, "0x02%06X", searchAddAddress);
						ListView_SetItemText(cheatListView, row, 1, buf);
						ltoa(searchAddValue, buf, 10);
						ListView_SetItemText(cheatListView, row, 2, buf);
						ListView_SetItemText(cheatListView, row, 3, editBuf[2]);
						ListView_SetItemText(cheatListView, row, 4, NAME_CPUs[searchAddProc]);

						EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
					}
				}
				return TRUE;
			}
			break;
		}
	}
	return FALSE;
}
Пример #2
0
//==============================================================================
BOOL CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
{
	switch(msg)
	{
		case WM_INITDIALOG: 
		{
			LV_COLUMN lvColumn;
			u32 address = 0;
			u32 val = 0;

			cheatListView = GetDlgItem(dialog, IDC_LIST1);

			ListView_SetExtendedListViewStyle(cheatListView, LVS_EX_FULLROWSELECT | LVS_EX_TWOCLICKACTIVATE);
			
			memset(&lvColumn,0,sizeof(LV_COLUMN));
			lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT;

			lvColumn.fmt=LVCFMT_CENTER;
			lvColumn.cx=20;
			lvColumn.pszText="X";
			ListView_InsertColumn(cheatListView, 0, &lvColumn);

			lvColumn.fmt=LVCFMT_LEFT;
			lvColumn.cx=84;
			lvColumn.pszText="Address";
			ListView_InsertColumn(cheatListView, 1, &lvColumn);
			lvColumn.cx=100;
			lvColumn.pszText="Value";
			ListView_InsertColumn(cheatListView, 2, &lvColumn);
			lvColumn.cx=245;
			lvColumn.pszText="Description";
			ListView_InsertColumn(cheatListView, 3, &lvColumn);
			lvColumn.fmt=LVCFMT_CENTER;

			LVITEM lvi;
			memset(&lvi,0,sizeof(LVITEM));
			lvi.mask = LVIF_TEXT|LVIF_STATE;
			lvi.iItem = INT_MAX;

			cheatsGetListReset();
			SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)FALSE,0);
			while (cheatsGetList(&tempCheat))
			{
				char buf[256];
				if (tempCheat.enabled)
					lvi.pszText= "X";
				else
					lvi.pszText= "";
				switch (tempCheat.type)
				{
					case 0:					// Internal
					{
						u32 row = ListView_InsertItem(cheatListView, &lvi);
						wsprintf(buf, "0x02%06X", tempCheat.hi[0]);
						ListView_SetItemText(cheatListView, row, 1, buf);
						ltoa(tempCheat.lo[0], buf, 10);
						ListView_SetItemText(cheatListView, row, 2, buf);
						ListView_SetItemText(cheatListView, row, 3, tempCheat.description);
						break;
					}

					case 1:					// Action Replay
					{
						u32 row = ListView_InsertItem(cheatListView, &lvi);
						ListView_SetItemText(cheatListView, row, 1, "Action");
						ListView_SetItemText(cheatListView, row, 2, "Replay");
						ListView_SetItemText(cheatListView, row, 3, tempCheat.description);
						break;
					}

					case 2:					// Codebreaker
					{
						u32 row = ListView_InsertItem(cheatListView, &lvi);
						ListView_SetItemText(cheatListView, row, 1, "Code");
						ListView_SetItemText(cheatListView, row, 2, "breaker");
						ListView_SetItemText(cheatListView, row, 3, tempCheat.description);
						break;
					}
				}
			}
			SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)TRUE,0);

			ListView_SetItemState(searchListView,0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
			SetFocus(searchListView);
			return TRUE;
		}

		case WM_NOTIFY:
			if (wparam == IDC_LIST1)
			{
				LPNMHDR tmp_msg = (LPNMHDR)lparam;
				if ( tmp_msg->code == LVN_ITEMACTIVATE )
				{
					cheatEditPos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED);
					cheatsGet(&tempCheat, cheatEditPos);
					tempCheat.enabled = !tempCheat.enabled;
					switch (tempCheat.type)
					{
						case 0:		// internal
							cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos);
						break;

						case 1:		// Action Replay
							cheatsUpdate_AR(NULL, NULL, tempCheat.enabled, cheatEditPos);
						break;

						case 2:		// Codebreaker
							cheatsUpdate_CB(NULL, NULL, tempCheat.enabled, cheatEditPos);
						break;
					}


					if (tempCheat.enabled)
						ListView_SetItemText(cheatListView, cheatEditPos, 0, "X")
					else
						ListView_SetItemText(cheatListView, cheatEditPos, 0, "");
					EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
				}

				if ( tmp_msg->code == NM_CLICK )
				{
					if (ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED) != -1)
					{
						EnableWindow(GetDlgItem(dialog, IDC_BEDIT), TRUE);
						EnableWindow(GetDlgItem(dialog, IDC_BREMOVE), TRUE);
					}
					else
					{
						EnableWindow(GetDlgItem(dialog, IDC_BEDIT), FALSE);
						EnableWindow(GetDlgItem(dialog, IDC_BREMOVE), FALSE);
					}
				}

				return TRUE;
			}