int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter & items, unsigned int pos, void **clientData, wxClientDataType type) { const unsigned int count = items.GetCount(); ListView_SetItemCount( GetHwnd(), GetCount() + count ); int n = wxNOT_FOUND; for( unsigned int i = 0; i < count; i++ ) { LVITEM newItem; wxZeroMemory(newItem); newItem.iItem = pos + i; n = ListView_InsertItem( (HWND)GetHWND(), & newItem ); wxCHECK_MSG( n != -1, -1, wxT("Item not added") ); SetString( n, items[i] ); m_itemsClientData.Insert(NULL, n); AssignNewItemClientData(n, clientData, i, type); } return n; }
void TcodecsPage::initLV(const char_t *IthirdCol) { hlv=GetDlgItem(m_hwnd,IDC_LV_INCODECS); ListView_SetExtendedListViewStyleEx(hlv,LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES,LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES); int ncol=0; ListView_AddCol(hlv,ncol,cfgGet(IDFF_lvCodecsWidth0),_(IDC_LV_INCODECS,_l("Format" )),false); ListView_AddCol(hlv,ncol,cfgGet(IDFF_lvCodecsWidth1),_(IDC_LV_INCODECS,_l("Decoder")),false); ListView_AddCol(hlv,ncol,cfgGet(IDFF_lvCodecsWidth2),_(IDC_LV_INCODECS,thirdCol=IthirdCol?IthirdCol:_l("Details")),false); hcbx=GetDlgItem(m_hwnd,IDC_CBX_INCODECS); formats.clear(); fillCodecs(); ListView_SetItemCount(hlv,formats.size()); curitem=cfgGet(IDFF_lvCodecsSelected); lvSetSelItem(IDC_LV_INCODECS,curitem); ListView_EnsureVisible(hlv,curitem,FALSE); options2dlg(curitem); if (setHints!=-1) { enableHints(!!setHints); } }
bool InsertWatch(const AddressWatcher& Watch, char *Comment, int atIndex) { if(!VerifyWatchNotAlreadyAdded(Watch)) return false; if(WatchCount >= MAX_WATCH_COUNT) return false; int i = WatchCount; if(atIndex == -1) {} else { //move watches down i = atIndex; for(int x=WatchCount;x>atIndex;x--) rswatches[x] = rswatches[x-1]; } WatchCount++; AddressWatcher& NewWatch = rswatches[i]; NewWatch = Watch; //if (NewWatch.comment) free(NewWatch.comment); NewWatch.comment = (char *) malloc(strlen(Comment)+2); NewWatch.CurValue = GetCurrentValue(NewWatch); strcpy(NewWatch.comment, Comment); ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; }
void EditorApplication::updateObjectsPaletteGUI(int index) { if (!library) return; current_category_index = index; HWND hPaletteList=GetDlgItem(hLeftDlg, IDL_PALETTE_LIST); // Cleanup old palette if(ListView_GetItemCount(hPaletteList)!=0) { ListView_DeleteAllItems(hPaletteList); while(ListView_DeleteColumn(hPaletteList,0) > 0); ListView_SetItemCount(hPaletteList,0); } // Create new palette LibGens::ObjectCategory *object_category=library->getCategoryByIndex(current_category_index); if (object_category) { vector<LibGens::Object *> objects=object_category->getTemplates(); char temp[128]; for (size_t i=0; i<objects.size(); i++) { LV_ITEM Item; Item.mask = LVIF_TEXT; strcpy(temp, objects[i]->getName().c_str()); Item.pszText = temp; Item.cchTextMax = strlen(temp); Item.iSubItem = 0; Item.lParam = (LPARAM) NULL; Item.iItem = ListView_GetItemCount(hPaletteList); ListView_InsertItem(hPaletteList, &Item); } } }
int Load_Watches(int clear, const char* filename) { const char DELIM = '\t'; FILE* WatchFile = fopen(filename,"rb"); struct AddressWatcher Temp; char mode; int i; int WatchAdd; if (!WatchFile) { MessageBox(MESSAGEBOXPARENT,(LPCWSTR)"Error opening file.",(LPCWSTR)"ERROR",MB_OK); return 0; } if(clear) { if(!ResetWatches()) { fclose(WatchFile); return 0; } } strcpy(currentWatch,filename); RWAddRecentFile(currentWatch); fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%c%*s",&mode); /* if ((mode == '1' && !(SegaCD_Started)) || (mode == '2' && !(_32X_Started))) { char Device[8]; strcpy(Device,(mode > '1')?"32X":"SegaCD"); sprintf(Str_Tmp,"Warning: %s not started. \nWatches for %s addresses will be ignored.",Device,Device); MessageBox(MESSAGEBOXPARENT,Str_Tmp,"Possible Device Mismatch",MB_OK); }*/ fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%d%*s",&WatchAdd); WatchAdd+=WatchCount; for (i = WatchCount; i < WatchAdd; i++) { char *Comment; while (i < 0) i++; do { fgets(Str_Tmp,1024,WatchFile); } while (Str_Tmp[0] == '\n'); sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); Temp.WrongEndian = 0; Comment = strrchr(Str_Tmp,DELIM) + 1; *strrchr(Comment,'\n') = '\0'; InsertWatch(&Temp,Comment); } fclose(WatchFile); if (RamWatchHWnd) ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=0; return 1; }
static void LoadReplacements(HWND hwndDlg) { HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS); ListView_DeleteAllItems(hList); ListView_SetItemCount(hList, 0); int sel = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0); if (sel < 0) return; AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); if (!data->initialized) { data->dict->autoReplace->copyMap(&data->autoReplaceMap); data->initialized = TRUE; } map<tstring,AutoReplacement>::iterator it = data->autoReplaceMap.begin(); for(int i = 0; it != data->autoReplaceMap.end(); it++, i++) { LVITEM item = {0}; item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = i; item.iSubItem = 0; item.pszText = (TCHAR *) it->first.c_str(); item.cchTextMax = (int)it->first.length(); item.lParam = i; ListView_InsertItem(hList, &item); ListView_SetItemText(hList, i, 1, (TCHAR *) it->second.replace.c_str()); } EnableDisableCtrls(hwndDlg); }
/* int i: either the number of existing watches minus 1, or the index of the watch to edit. */ bool InsertWatch(const AddressWatcher& Watch, char *Comment, int i) { if (i == WatchCount) // append new watch { if(!VerifyWatchNotAlreadyAdded(Watch)) return false; if(WatchCount >= MAX_WATCH_COUNT) return false; WatchCount++; } else // replace existing watch { // TODO: minor bug: we have not checked that they haven't changed the address to an already-existing watch. // We can't just use VerifyWatchNotAlreadyAdded because doing so doesn't let us keep the same address but change the comment. free(rswatches[i].comment); } AddressWatcher& NewWatch = rswatches[i]; NewWatch = Watch; NewWatch.comment = (char *) malloc(strlen(Comment)+2); NewWatch.CurValue = GetCurrentValue(NewWatch); strcpy(NewWatch.comment, Comment); ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; }
/// Function name : onArgumentPage_DeleteArgument // Description : Delete the currently selected argument ListView item and the associated ARGUMENT list item // of the ScriptFile of the currently active document. // // SCRIPT_DOCUMENT* pDocument : [in] Active document // HWND hDialog : [in] Window handle of the arguments page // VOID onArgumentPage_DeleteArgument(SCRIPT_DOCUMENT* pDocument, HWND hDialog) { ARGUMENT* pArgument; HWND hListView = GetDlgItem(hDialog, IDC_ARGUMENTS_LIST); INT iItemIndex; // Selected argument index // [TRACK] CONSOLE_COMMAND(); // [DEBUG] Print argument being deleted findArgumentInScriptFileByIndex(pDocument->pScriptFile, ListView_GetSelected(hListView), pArgument); debugArgument(pArgument); /// Delete selected ARGUMENT from ScriptFile removeArgumentFromScriptFileByIndex(pDocument->pScriptFile, iItemIndex = ListView_GetSelected(hListView)); /// Update ListView count ListView_SetItemCount(hListView, getScriptFileArgumentCount(pDocument->pScriptFile)); // Unselected remaining items ListView_SetItemState(hListView, -1, NULL, LVIS_SELECTED); onArgumentPage_ItemChanged(pDocument, hDialog, NULL); // [EVENT] Notify document that a property has changed sendDocumentPropertyUpdated(AW_DOCUMENTS_CTRL, IDC_ARGUMENTS_LIST); }
HRESULT CLAVVideoFormatsProp::OnActivate() { HRESULT hr = S_OK; INITCOMMONCONTROLSEX icc; icc.dwSize = sizeof(INITCOMMONCONTROLSEX); icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES | ICC_LISTVIEW_CLASSES; if (InitCommonControlsEx(&icc) == FALSE) { return E_FAIL; } ASSERT(m_pVideoSettings != NULL); // Setup ListView control for format configuration HWND hlv = GetDlgItem(m_Dlg, IDC_CODECS); ListView_SetExtendedListViewStyle(hlv, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); int nCol = 1; LVCOLUMN lvc = {LVCF_WIDTH, 0, 20, 0}; ListView_InsertColumn(hlv, 0, &lvc); ListView_AddCol(hlv, nCol, 85, L"Codec", false); ListView_AddCol(hlv, nCol, 400, L"Description", false); ListView_DeleteAllItems(hlv); ListView_SetItemCount(hlv, Codec_VideoNB); // Create entries for the formats LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.mask = LVIF_TEXT|LVIF_PARAM; int nItem = 0; for (nItem = 0; nItem < Codec_VideoNB; ++nItem) { const codec_config_t *config = get_codec_config((LAVVideoCodec)nItem); // Create main entry lvi.iItem = nItem + 1; ListView_InsertItem(hlv, &lvi); // Set sub item texts ATL::CA2W name(config->name); ListView_SetItemText(hlv, nItem, 1, (LPWSTR)name); ATL::CA2W desc(config->description); ListView_SetItemText(hlv, nItem, 2, (LPWSTR)desc); } hr = LoadData(); if (SUCCEEDED(hr)) { // Set checked state for (nItem = 0; nItem < ListView_GetItemCount(hlv); nItem++) { ListView_SetCheckState(hlv, nItem, m_bFormats[nItem]); } } SendDlgItemMessage(m_Dlg, IDC_CODECS_MSWMVDMO, BM_SETCHECK, m_bWMVDMO, 0); SendDlgItemMessage(m_Dlg, IDC_DVD_VIDEO, BM_SETCHECK, m_bDVD, 0); return hr; }
bool Load_Watches(bool clear, const char* filename) { const char DELIM = '\t'; FILE* WatchFile = fopen(filename,"rb"); if(!WatchFile) { MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OK); return false; } if(clear) { if(!ResetWatches()) { fclose(WatchFile); return false; } } strcpy(currentWatch,filename); RWAddRecentFile(currentWatch); AddressWatcher Temp = {}; char mode; fgets(Str_Tmp_RW,1024,WatchFile); sscanf(Str_Tmp_RW,"%c%*s",&mode); //if((mode == '1' && !(SegaCD_Started)) || (mode == '2' && !(_32X_Started))) //{ // char Device[8]; // strcpy(Device,(mode > '1')?"32X":"SegaCD"); // sprintf(Str_Tmp_RW,"Warning: %s not started. \nWatches for %s addresses will be ignored.",Device,Device); // MessageBox(MESSAGEBOXPARENT,Str_Tmp_RW,"Possible Device Mismatch",MB_OK); //} int WatchAdd; fgets(Str_Tmp_RW,1024,WatchFile); sscanf(Str_Tmp_RW,"%d%*s",&WatchAdd); WatchAdd += WatchCount; for (int i = WatchCount; i < WatchAdd; i++) { while(i < 0) i++; do { fgets(Str_Tmp_RW,1024,WatchFile); } while(Str_Tmp_RW[0] == '\n'); int dummy_wrong_endian; sscanf(Str_Tmp_RW,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&dummy_wrong_endian); Temp.WrongEndian = false; char* Comment = strrchr(Str_Tmp_RW,DELIM) + 1; if(Comment == (char*)NULL + 1) continue; char* newline = strrchr(Comment,'\n'); if(newline) *newline = '\0'; InsertWatch(Temp,Comment); } fclose(WatchFile); if(RamWatchHWnd) ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=false; return true; }
void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData) { ListView_SetItemCount( GetHwnd(), GetCount() + items.GetCount() ); for( unsigned int i = 0; i < items.GetCount(); i++ ) { int pos = Append(items[i]); if( pos >= 0 && clientData ) DoSetItemClientData(pos, clientData[i]); } }
void TkeysPage::init(void) { keyChanging = -1; ignoreNextKey = false; hlv = GetDlgItem(m_hwnd, IDC_LV_KEYS); int ncol = 0; ListView_AddCol(hlv, ncol, cfgGet(IDFF_lvKeysWidth0), _l("Action"), false); ListView_AddCol(hlv, ncol, cfgGet(IDFF_lvKeysWidth1), _l("Key"), false); ListView_SetExtendedListViewStyle(hlv, ListView_GetExtendedListViewStyle(hlv) | LVS_EX_FULLROWSELECT); ListView_SetItemCount(hlv, deciD->getKeyParamCount2()); }
void TconvolverPage::init(void) { tbrSetRange(IDC_TBR_CONVOLVER_MIXINGSTRENGTH,0,100); tbrSetRange(IDC_TBR_CONVOLVER_LEVELADJUSTDB,-300,300); hlv=GetDlgItem(m_hwnd,IDC_LV_CONVOLVER_FILES); int ncol=0; ListView_AddCol(hlv,ncol,cfgGet(IDFF_lvConvolverWidth0),_(IDC_LV_CONVOLVER_FILES,_l("Channel")),false); ListView_AddCol(hlv,ncol,cfgGet(IDFF_lvConvolverWidth1),_(IDC_LV_CONVOLVER_FILES,_l("File")),false); ListView_AddCol(hlv,ncol,cfgGet(IDFF_lvConvolverWidth2),_(IDC_LV_CONVOLVER_FILES,_l("Format")),false); ListView_SetExtendedListViewStyle(hlv,ListView_GetExtendedListViewStyle(hlv)|LVS_EX_FULLROWSELECT); ListView_SetItemCount(hlv,6); lvSetSelItem(IDC_LV_CONVOLVER_FILES,cfgGet(IDFF_lvConvolverSelected)); }
bool Load_Watches(bool clear, const char* filename) { const char DELIM = '\t'; FILE* WatchFile = fopen(filename,"rb"); if (!WatchFile) { MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OK); return false; } if(clear) { if(!ResetWatches()) { fclose(WatchFile); return false; } } strcpy(currentWatch,filename); RWAddRecentFile(currentWatch); AddressWatcher Temp; char mode; fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%c%*s",&mode); int WatchAdd; fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%d%*s",&WatchAdd); WatchAdd+=WatchCount; for (int i = WatchCount; i < WatchAdd; i++) { while (i < 0) i++; do { fgets(Str_Tmp,1024,WatchFile); } while (Str_Tmp[0] == '\n'); sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); Temp.WrongEndian = 0; char *Comment = strrchr(Str_Tmp,DELIM) + 1; *strrchr(Comment,'\n') = '\0'; InsertWatch(Temp,Comment); } fclose(WatchFile); if (RamWatchHWnd) { ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RefreshWatchListSelectedCountControlStatus(RamWatchHWnd); } RWfileChanged=false; return true; }
static VOID PhpUpdateLogList( VOID ) { ListViewCount = PhLogBuffer.Count; ListView_SetItemCount(ListViewHandle, ListViewCount); if (ListViewCount >= 2 && Button_GetCheck(GetDlgItem(PhLogWindowHandle, IDC_AUTOSCROLL)) == BST_CHECKED) { // This is a real WTF. EnsureVisible doesn't work if IsItemVisible is used and there is // an item selected. //if (ListView_IsItemVisible(ListViewHandle, ListViewCount - 2)) ListView_EnsureVisible(ListViewHandle, ListViewCount - 1, FALSE); } }
/// Function name : updateScriptVariablesPageList // Description : Refresh the list of Variable dependencies // // PROPERTIES_DATA* pSheetData : [in] Properties sheet data // VOID updateScriptVariablesPage_List(PROPERTIES_DATA* pSheetData, HWND hPage) { // [VERBOSE] //CONSOLE("Updating 'Variables' page tree/list"); // Delete existing dependencies tree (if any) if (pSheetData->pVariableDependencies) deleteAVLTree(pSheetData->pVariableDependencies); // Generate new dependencies tree pSheetData->pVariableDependencies = CodeEdit_GetVariableDependencyTree(pSheetData->pScriptDocument->hCodeEdit); // Set new list count ListView_SetItemCount(GetDlgItem(hPage, IDC_VARIABLES_LIST), getTreeNodeCount(pSheetData->pVariableDependencies)); }
/// Function name : onArgumentPage_InsertArgument // Description : Display the 'Insert Argument' dialog and (if the user creates an argument) add the argument // to the document's ScriptFile and the document properties dialog Argument ListView // // SCRIPT_DOCUMENT* pDocument : [in] Active document // HWND hDialog : [in] Window handle of the Arguments property page // VOID onArgumentPage_InsertArgument(SCRIPT_DOCUMENT* pDocument, HWND hDialog) { // [VERBOSE] CONSOLE_COMMAND(); /// Display 'Insert Argument' dialog if (displayInsertArgumentDialog(pDocument->pScriptFile, getAppWindow())) { // [NEW ARGUMENT] Update ListView item count ListView_SetItemCount(GetDlgItem(hDialog, IDC_ARGUMENTS_LIST), getScriptFileArgumentCount(pDocument->pScriptFile)); // [EVENT] Notify document that a property has changed sendDocumentPropertyUpdated(AW_DOCUMENTS_CTRL, IDC_ARGUMENTS_LIST); } }
bool ResetWatches() { if(!AskSave()) return false; for (;WatchCount>=0;WatchCount--) { free(rswatches[WatchCount].comment); rswatches[WatchCount].comment = NULL; } WatchCount++; if (RamWatchHWnd) ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged = false; currentWatch[0] = NULL; return true; }
/// Function name : updateScriptStringsPageList // Description : Refresh the list of GameString dependencies // // PROPERTIES_DATA* pSheetData : [in] Properties sheet data // VOID updateScriptStringsPage_List(PROPERTIES_DATA* pSheetData, HWND hPage) { PROJECT_DOCUMENT* pProject; // [VERBOSE] //CONSOLE("Updating 'Strings' page tree/list"); // Delete existing GameStrings tree (if any) if (pSheetData->pStringDependencies) deleteAVLTree(pSheetData->pStringDependencies); // Get active project (if any) pProject = getActiveProject(); // Generate new GameStrings tree pSheetData->pStringDependencies = CodeEdit_GetStringDependencyTree(pSheetData->pScriptDocument->hCodeEdit, pProject ? pProject->pProjectFile : NULL); // Set new list count ListView_SetItemCount(GetDlgItem(hPage, IDC_STRINGS_LIST), getTreeNodeCount(pSheetData->pStringDependencies)); }
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { // initialize base class fields if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; // create the native control if ( !MSWCreateControl(WC_LISTVIEW, wxEmptyString, pos, size) ) { // control creation failed return false; } ::SendMessage(GetHwnd(), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT ); // insert single column with checkboxes and labels LV_COLUMN col; wxZeroMemory(col); ListView_InsertColumn(GetHwnd(), 0, &col ); ListView_SetItemCount( GetHwnd(), n ); // initialize the contents for ( int i = 0; i < n; i++ ) { Append(choices[i]); } m_itemsClientData.SetCount(n); // now we can compute our best size correctly, so do it if necessary SetInitialSize(size); return true; }
//=================================== TinfoPageDec ======================================= void TinfoPageDec::init(void) { setCheck(IDC_CHB_MMX ,Tconfig::cpu_flags&FF_CPU_MMX ); setCheck(IDC_CHB_MMXEXT ,Tconfig::cpu_flags&FF_CPU_MMXEXT ); setCheck(IDC_CHB_SSE ,Tconfig::cpu_flags&FF_CPU_SSE ); setCheck(IDC_CHB_SSE2 ,Tconfig::cpu_flags&FF_CPU_SSE2 ); setCheck(IDC_CHB_SSE3 ,Tconfig::cpu_flags&FF_CPU_SSE3 ); setCheck(IDC_CHB_SSSE3 ,Tconfig::cpu_flags&FF_CPU_SSSE3 ); setCheck(IDC_CHB_3DNOW ,Tconfig::cpu_flags&FF_CPU_3DNOW ); setCheck(IDC_CHB_3DNOWEXT,Tconfig::cpu_flags&FF_CPU_3DNOWEXT); setCheck(IDC_CHB_SSE41 ,Tconfig::cpu_flags&FF_CPU_SSE41 ); setCheck(IDC_CHB_SSE42 ,Tconfig::cpu_flags&FF_CPU_SSE42 ); setCheck(IDC_CHB_SSE4A ,Tconfig::cpu_flags&FF_CPU_SSE4A ); setCheck(IDC_CHB_SSE5 ,Tconfig::cpu_flags&FF_CPU_SSE5 ); hlv=GetDlgItem(m_hwnd,IDC_LV_INFO); CRect r=getChildRect(IDC_LV_INFO); int ncol=0; ListView_AddCol(hlv,ncol,r.Width(),_l("Property"),false); ListView_SetExtendedListViewStyleEx(hlv,LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP,LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP); infoitems.clear(); const int *infos=getInfos(); for (int i=0;; i++) { Titem it; if (!info->getInfo(i,&it.id,&it.name)) { break; } for (int j=0; infos[j]; j++) if (infos[j]==it.id) { it.index=j; infoitems.push_back(it); } } std::sort(infoitems.begin(),infoitems.end(),TsortItem(infos)); ListView_SetItemCount(hlv,infoitems.size()); SendMessage(hlv,LVM_SETBKCOLOR,0,GetSysColor(COLOR_BTNFACE)); SendMessage(hlv,LVM_SETTEXTBKCOLOR,0,GetSysColor(COLOR_BTNFACE)); setCheck(IDC_CHB_WRITEINFO2DBG, cfgGet(IDFF_allowDPRINTF)); }
bool InsertWatch(const AddressWatcher& Watch, LPCSTR Comment) { if(!VerifyWatchNotAlreadyAdded(Watch)) return false; if(WatchCount >= MAX_WATCH_COUNT) return false; int i = WatchCount++; AddressWatcher& NewWatch = rswatches[i]; NewWatch = Watch; //if(NewWatch.comment) free(NewWatch.comment); NewWatch.comment = (char *) malloc(strlen(Comment)+2); EnterCriticalSection(&g_processMemCS); NewWatch.CurValue = GetCurrentValue(NewWatch); LeaveCriticalSection(&g_processMemCS); strcpy(NewWatch.comment, Comment); ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; }
bool ValidateAndAddWatch(HWND hDlg, unsigned int watchAddress, AddressWatcher &Temp, char *StrTmp, int index) { Temp.Address = watchAddress; if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF) // ? Temp.Address &= 0xFFFFFF; if(IsHardwareRAMAddressValid(Temp.Address)) { InsertWatch(Temp,Str_Tmp, index); if(RamWatchHWnd) { ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); } return true; } else { return false; } }
int InsertWatch(const struct AddressWatcher *Watch, char *Comment) { int i; struct AddressWatcher *NewWatch; if(!VerifyWatchNotAlreadyAdded(Watch)) return 0; if(WatchCount >= MAX_WATCH_COUNT) return 0; i = WatchCount++; NewWatch = &rswatches[i]; // NewWatch = Watch; // if (NewWatch->comment) free(NewWatch->comment); NewWatch->comment = (char *) malloc(strlen(Comment)+2); NewWatch->CurValue = GetCurrentValue((AddressWatcher*)Watch);;//Watch->CurValue;//GetCurrentValue(NewWatch); NewWatch->Address = Watch->Address; NewWatch->Size = Watch->Size; NewWatch->Type = Watch->Type; strcpy(NewWatch->comment, Comment); ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=1; /* NewWatch = rswatches[i]; NewWatch = Watch; //if (NewWatch.comment) free(NewWatch.comment); NewWatch->comment = (char *) malloc(strlen(Comment)+2); NewWatch->CurValue = GetCurrentValue(NewWatch); strcpy(NewWatch->comment, Comment); ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=1; */ return 1; }
void TableViewImpl::setRows(int r) { if( r > rowCount ) { ListView_SetItemCount(hWnd,r); ItemProperties emptyText; int rowsAdded = 0; for( int i = rowCount; i < r; ++i ) { rowsAdded += addItem(i+1,emptyText); } rowCount += rowsAdded; } else if( r < rowCount ) { int rowsDeleted = 0; for( int i = r; i <= rowCount; ++i ) { if( ListView_DeleteItem(hWnd,r) == FALSE ) { log::error("ListView_DeleteItem returned FALSE for hWnd ",hWnd); } else { ++rowsDeleted; } } rowCount -= rowsDeleted; } }
BOOL WINAPI UIProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { static GPtr globals = NULL; // need to be static switch (wMsg) { case WM_INITDIALOG: { LV_ITEM LvItem; LV_COLUMN LstColVal, LstColProp; int i; CenterDialog(hDlg); // set up globals globals = (GPtr) lParam; gList = GetDlgItem(hDlg,1011); // get the ID of the ListView LVProcPrev = (WNDPROC)SetWindowLong(gList, GWL_WNDPROC, (DWORD)LVProc); // Here we put the info on the Column headers // this is not data, only name of each header we like memset(&LstColVal,0,sizeof(LstColVal)); // Reset Column LstColVal.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_ORDER; // Type of mask LstColVal.cx = 0x64; // width between each coloum LstColVal.pszText = "Value"; // LstColVal.iOrder = 1; // put editable field on right side LstColProp = LstColVal; LstColProp.pszText = "Property"; LstColProp.iOrder = 0; // Inserting Columns as much as we want ListView_InsertColumn(gList, 0, &LstColVal); ListView_InsertColumn(gList, 1, &LstColProp); // Setting common properties Of Items: memset(&LvItem,0,sizeof(LvItem)); // Reset Item Struct LvItem.mask = LVIF_TEXT|LVCF_WIDTH|LVCF_SUBITEM; // Text Style LvItem.cchTextMax = 256; // Max size of test // allocate mem for items ListView_SetItemCount(gList, PI_MAX); // insert items for(i=0; i<PI_MAX; i++) { ListView_SetPair(gList, LvItem, i,its(gIntProps[i].value), gIntProps[i].name ); } ShowWindow(hDlg,SW_NORMAL); UpdateWindow(hDlg); return FALSE; } case WM_NOTIFY: { switch( ((LPNMHDR)lParam)->code ) { case LVN_BEGINLABELEDIT: { break; } case LVN_ENDLABELEDIT: { int iIndex; char tempstr[255]=""; HWND hEdit; iIndex = ListView_GetNextItem(gList,-1,LVNI_FOCUSED); if( iIndex != - 1 ) { //save to list hEdit = ListView_GetEditControl(gList); GetWindowText(hEdit, tempstr, sizeof(tempstr)); ListView_SetItemText(gList, iIndex,0,tempstr); //save to globals gIntProps[iIndex].value = ListView_ReadInt(gList, iIndex, 0); } break; } } break; } case WM_COMMAND: { int item; int cmd; item = COMMANDID (wParam); // WIN32 Change cmd = HIWORD(wParam); switch (item) { case ok: if (cmd == BN_CLICKED) state = STATE_AGAIN; break; case cancel: if (cmd == BN_CLICKED) state = STATE_CANCEL; break; } return FALSE; } } return FALSE; }
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT r; RECT r2; int dx1, dy1, dx2, dy2; static int watchIndex=0; Update_RAM_Watch(); switch(uMsg) { case WM_MOVE: { RECT wrect; GetWindowRect(hDlg,&wrect); ramw_x = wrect.left; ramw_y = wrect.top; break; }; case WM_INITDIALOG: { GetWindowRect(MainWindow->getHWnd(), &r); //Ramwatch window dx1 = (r.right - r.left) / 2; dy1 = (r.bottom - r.top) / 2; GetWindowRect(hDlg, &r2); // Gens window dx2 = (r2.right - r2.left) / 2; dy2 = (r2.bottom - r2.top) / 2; // push it away from the main window if we can const int width = (r.right-r.left); const int height = (r.bottom - r.top); const int width2 = (r2.right-r2.left); if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) { r.right += width; r.left += width; } else if((int)r.left - (int)width2 > 0) { r.right -= width2; r.left -= width2; } //----------------------------------------------------------------------------------- //If user has Save Window Pos selected, override default positioning if (RWSaveWindowPos) { //If ramwindow is for some reason completely off screen, use default instead if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN)) ) r.left = ramw_x; //This also ignores cases of windows -32000 error codes //If ramwindow is for some reason completely off screen, use default instead if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN)) ) r.top = ramw_y; //This also ignores cases of windows -32000 error codes } //------------------------------------------------------------------------------------- SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); ramwatchmenu=GetMenu(hDlg); rwrecentmenu=CreateMenu(); UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); const char* names[3] = {"Address","Value","Notes"}; int widths[3] = {62,64,64+51+53}; init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths); /* if (!ResultCount) //TODO what do these do reset_address_info(); else signal_new_frame();*/ ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); // if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); // if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); RamWatchAccels = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR1)); // due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE); Update_RAM_Watch(); DragAcceptFiles(hDlg, TRUE); return true; break; } case WM_INITMENU: CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); break; case WM_MENUSELECT: case WM_ENTERSIZEMOVE: break; case WM_NOTIFY: { switch(wParam) { case ID_WATCHES_UPDOWN: { switch(((LPNMUPDOWN)lParam)->hdr.code) { case UDN_DELTAPOS: int delta = ((LPNMUPDOWN)lParam)->iDelta; SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0); break; } } default: { LPNMHDR lP = (LPNMHDR) lParam; switch (lP->code) { case LVN_GETDISPINFO: { LV_DISPINFO *Item = (LV_DISPINFO *)lParam; Item->item.mask = LVIF_TEXT; Item->item.state = 0; Item->item.iImage = 0; const unsigned int iNum = Item->item.iItem; static char num[11]; switch (Item->item.iSubItem) { case 0: sprintf(num,"%08X",rswatches[iNum].Address); Item->item.pszText = num; return true; case 1: { int i = rswatches[iNum].CurValue; int t = rswatches[iNum].Type; int size = rswatches[iNum].Size; const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X")); switch (size) { case 'b': default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; } Item->item.pszText = num; } return true; case 2: Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : ""; return true; default: return false; } } case LVN_ODFINDITEM: { // disable search by keyboard typing, // because it interferes with some of the accelerators // and it isn't very useful here anyway SetWindowLong(hDlg, DWL_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST))); return 1; } } } } break; } case WM_COMMAND: switch(LOWORD(wParam)) { case RAMMENU_FILE_SAVE: QuickSaveWatches(); break; case RAMMENU_FILE_SAVEAS: return Save_Watches(); case RAMMENU_FILE_OPEN: return Load_Watches(true); case RAMMENU_FILE_APPEND: return Load_Watches(false); case RAMMENU_FILE_NEW: ResetWatches(); return true; case IDC_C_WATCH_REMOVE: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); RemoveWatch(watchIndex); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_EDIT: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH: rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0; rswatches[WatchCount].Size = 'b'; rswatches[WatchCount].Type = 's'; DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_DUPLICATE: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); rswatches[WatchCount].Address = rswatches[watchIndex].Address; rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; rswatches[WatchCount].Size = rswatches[watchIndex].Size; rswatches[WatchCount].Type = rswatches[watchIndex].Type; DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_UP: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if (watchIndex == 0 || watchIndex == -1) return true; void *tmp = malloc(sizeof(AddressWatcher)); memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher)); free(tmp); ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; } case IDC_C_WATCH_DOWN: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if (watchIndex >= WatchCount - 1 || watchIndex == -1) return true; void *tmp = malloc(sizeof(AddressWatcher)); memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher)); free(tmp); ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; } case RAMMENU_FILE_AUTOLOAD: { AutoRWLoad ^= 1; CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); break; } case RAMMENU_FILE_SAVEWINDOW: { RWSaveWindowPos ^=1; CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); break; } case IDC_C_ADDCHEAT: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)) | (1 << 24); // DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) searchIndex); //TODO: made a IDD_EDITCHEAT dialog, and EditCheatProc (are they in GENS?) and integrate into cheats system break; } case IDCANCEL: RamWatchHWnd = NULL; DragAcceptFiles(hDlg, FALSE); EndDialog(hDlg, true); return true; default: if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES) OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE); } break; case WM_KEYDOWN: // handle accelerator keys { SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); MSG msg; msg.hwnd = hDlg; msg.message = uMsg; msg.wParam = wParam; msg.lParam = lParam; if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg)) return true; } break; case WM_CLOSE: RamWatchHWnd = NULL; DragAcceptFiles(hDlg, FALSE); EndDialog(hDlg, true); return true; case WM_DROPFILES: { HDROP hDrop = (HDROP)wParam; DragQueryFile(hDrop, 0, Str_Tmp, 1024); DragFinish(hDrop); return Load_Watches(true, Str_Tmp); } break; } return false; }
LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List { RECT r; RECT r2; int dx1, dy1, dx2, dy2; static int index; static char s,t = s = 0; switch(uMsg) { case WM_INITDIALOG: GetWindowRect(MainWindow->getHWnd(), &r); dx1 = (r.right - r.left) / 2; dy1 = (r.bottom - r.top) / 2; GetWindowRect(hDlg, &r2); dx2 = (r2.right - r2.left) / 2; dy2 = (r2.bottom - r2.top) / 2; SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); index = (int)lParam; sprintf(Str_Tmp,"%08X",rswatches[index].Address); SetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp); if (rswatches[index].comment != NULL) SetDlgItemText(hDlg,IDC_PROMPT_EDIT,rswatches[index].comment); s = rswatches[index].Size; t = rswatches[index].Type; switch (s) { case 'b': SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0); break; case 'w': SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0); break; case 'd': SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0); break; default: s = 0; break; } switch (t) { case 's': SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0); break; case 'u': SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0); break; case 'h': SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0); break; default: t = 0; break; } return true; break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_SIGNED: t='s'; return true; case IDC_UNSIGNED: t='u'; return true; case IDC_HEX: t='h'; return true; case IDC_1_BYTE: s = 'b'; return true; case IDC_2_BYTES: s = 'w'; return true; case IDC_4_BYTES: s = 'd'; return true; case IDOK: { if (s && t) { AddressWatcher Temp; Temp.Size = s; Temp.Type = t; Temp.WrongEndian = false; //replace this when I get little endian working properly GetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp,1024); char *addrstr = Str_Tmp; if (strlen(Str_Tmp) > 8) addrstr = &(Str_Tmp[strlen(Str_Tmp) - 9]); for(int i = 0; addrstr[i]; i++) {if(toupper(addrstr[i]) == 'O') addrstr[i] = '0';} sscanf(addrstr,"%08X",&(Temp.Address)); if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF) Temp.Address &= 0xFFFFFF; if(IsHardwareRAMAddressValid(Temp.Address)) { GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80); if (index < WatchCount) RemoveWatch(index); InsertWatch(Temp,Str_Tmp); if(RamWatchHWnd) { ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); } EndDialog(hDlg, true); } else { MessageBox(hDlg,"Invalid Address","ERROR",MB_OK); } } else { strcpy(Str_Tmp,"Error:"); if (!s) strcat(Str_Tmp," Size must be specified."); if (!t) strcat(Str_Tmp," Type must be specified."); MessageBox(hDlg,Str_Tmp,"ERROR",MB_OK); } RWfileChanged=true; return true; break; } case IDCANCEL: EndDialog(hDlg, false); return false; break; } break; case WM_CLOSE: EndDialog(hDlg, false); return false; break; } return false; }
void OpenRWRecentFile(int memwRFileNumber) { if(!ResetWatches()) return; int rnum = memwRFileNumber; if ((unsigned int)rnum >= MAX_RECENT_WATCHES) return; //just in case char* x; while(true) { x = rw_recent_files[rnum]; if (!*x) return; //If no recent files exist just return. Useful for Load last file on startup (or if something goes screwy) if (rnum) //Change order of recent files if not most recent { RWAddRecentFile(x); rnum = 0; } else { break; } } strcpy(currentWatch,x); strcpy(Str_Tmp,currentWatch); //loadwatches here FILE *WatchFile = fopen(Str_Tmp,"rb"); if (!WatchFile) { int answer = MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OKCANCEL); if (answer == IDOK) { rw_recent_files[rnum][0] = '\0'; //Clear file from list if (rnum) //Update the ramwatch list RWAddRecentFile(rw_recent_files[0]); else RWAddRecentFile(rw_recent_files[1]); } return; } const char DELIM = '\t'; AddressWatcher Temp; char mode; fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%c%*s",&mode); int WatchAdd; fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%d%*s",&WatchAdd); WatchAdd+=WatchCount; for (int i = WatchCount; i < WatchAdd; i++) { while (i < 0) i++; do { fgets(Str_Tmp,1024,WatchFile); } while (Str_Tmp[0] == '\n'); sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); Temp.WrongEndian = 0; char *Comment = strrchr(Str_Tmp,DELIM) + 1; *strrchr(Comment,'\n') = '\0'; InsertWatch(Temp,Comment); } fclose(WatchFile); if (RamWatchHWnd) ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=false; return; }
void OpenRWRecentFile(int memwRFileNumber) { const char DELIM = '\t'; struct AddressWatcher Temp; char mode; int i; int WatchAdd; FILE *WatchFile; char* x; int rnum; if(!ResetWatches()) return; rnum = memwRFileNumber; if ((unsigned int)rnum >= MAX_RECENT_WATCHES) return; //just in case while(1) { x = rw_recent_files[rnum]; if (!*x) return; //If no recent files exist just return. Useful for Load last file on startup (or if something goes screwy) if (rnum) //Change order of recent files if not most recent { RWAddRecentFile(x); rnum = 0; } else { break; } } strcpy(currentWatch,x); strcpy(Str_Tmp,currentWatch); //loadwatches here WatchFile = fopen(Str_Tmp,"rb"); if (!WatchFile) { int answer = MessageBox(MESSAGEBOXPARENT,(LPCWSTR)"Error opening file.",(LPCWSTR)"ERROR",MB_OKCANCEL); if (answer == IDOK) { rw_recent_files[rnum][0] = '\0'; //Clear file from list if (rnum) //Update the ramwatch list RWAddRecentFile(rw_recent_files[0]); else RWAddRecentFile(rw_recent_files[1]); } return; } fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%c%*s",&mode); /* if ((mode == '1' && !(SegaCD_Started)) || (mode == '2' && !(_32X_Started))) { char Device[8]; strcpy(Device,(mode > '1')?"32X":"SegaCD"); sprintf(Str_Tmp,"Warning: %s not started. \nWatches for %s addresses will be ignored.",Device,Device); MessageBox(MESSAGEBOXPARENT,Str_Tmp,"Possible Device Mismatch",MB_OK); }*/ fgets(Str_Tmp,1024,WatchFile); sscanf(Str_Tmp,"%d%*s",&WatchAdd); WatchAdd+=WatchCount; for (i = WatchCount; i < WatchAdd; i++) { char *Comment; while (i < 0) i++; do { fgets(Str_Tmp,1024,WatchFile); } while (Str_Tmp[0] == '\n'); sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); Temp.WrongEndian = 0; Comment = strrchr(Str_Tmp,DELIM) + 1; *strrchr(Comment,'\n') = '\0'; InsertWatch(&Temp,Comment); } fclose(WatchFile); if (RamWatchHWnd) ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); RWfileChanged=0; return; }