BOOL UpdateHighlights(BOOL fAlways) { HWND hwndGridView; if ((hwndGridView = GetDlgItem(GetBookmarkWnd(), IDC_HIGHLIGHT_GRIDVIEW)) == 0) return FALSE; SendMessage(hwndGridView, WM_SETREDRAW, FALSE, 0); if(fAlways) { WIN32_FIND_DATA win32fd; HANDLE hFind; TCHAR szBookPath[MAX_PATH]; TCHAR szFilePath[MAX_PATH]; GetProgramDataPath(szBookPath, MAX_PATH); lstrcat(szBookPath, TEXT("\\Bookmarks\\*")); // enumerate all files in the bookmarks directory if((hFind = FindFirstFile(szBookPath, &win32fd)) != 0) { do { if((win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { GetProgramDataPath(szBookPath, MAX_PATH); wsprintf(szFilePath, TEXT("%s\\Bookmarks\\%s"), szBookPath, win32fd.cFileName); UpdateHighlight(0, szFilePath, TRUE); } } while(FindNextFile(hFind, &win32fd)); FindClose(hFind); } } //else { int i; HWND hwndHexView; // add bookmarks for all open files for(i = 0; (hwndHexView = EnumHexView(g_hwndMain, i)) != 0; i++) { TCHAR szFilePath[MAX_PATH]; HexView_GetFileName(hwndHexView, szFilePath, MAX_PATH); UpdateHighlight(szFilePath, 0, FALSE); } } SendMessage(hwndGridView, WM_SETREDRAW, TRUE, 0); return TRUE; }
void VisWinTools::Stop3DMode() { for(int i = 0; i < numTools; ++i) tools[i]->Start3DMode(); UpdateHighlight(); toolProxy.Render(); }
void VisWinTools::SetHighlightEnabled(bool val) { if(val) { UpdateHighlight(); } else if(highlightAdded) { toolProxy.GetForeground()->RemoveActor2D(highlightActor); highlightAdded = false; } }
void VisWinTools::SetToolEnabled(int i, bool val) { if(i < 0 || i > numTools) EXCEPTION2(BadIndexException, 0, numTools); if(val) tools[i]->Enable(); else { if (toolProxy.GetToolUpdateMode() == UPDATE_ONCLOSE) tools[i]->CallCallback(); tools[i]->Disable(); } UpdateHighlight(); toolProxy.RecalculateRenderOrder(); toolProxy.Render(); }
BOOL HexCloseFile(MAINWND *mainWnd, int iItem) { TCITEM tci = { TCIF_PARAM }; HWND hwndHV; TCHAR szFilePath[MAX_PATH]; if(!TabCtrl_GetItem(mainWnd->hwndTabView, iItem, &tci)) return FALSE; hwndHV = (HWND)tci.lParam; // is this the last tab left? if(TabCtrl_GetItemCount(mainWnd->hwndTabView) == 1) { HexView_Clear((HWND)tci.lParam); tci.mask = TCIF_TEXT; tci.pszText = TEXT("(Untitled)"); TabCtrl_SetItem(mainWnd->hwndTabView, 0, &tci); tci.lParam = 0; } else { // remove the tab TabCtrl_DeleteItem(mainWnd->hwndTabView, iItem); } // set focus to a new tab iItem = TabCtrl_GetCurSel(mainWnd->hwndTabView); HexSetCurFile(mainWnd->hwndMain, iItem, TRUE); // lastly destroy the unwanted hexview SaveHighlights(hwndHV); HexView_GetFileName(hwndHV, szFilePath, MAX_PATH); if(hwndHV == (HWND)tci.lParam) DestroyWindow(hwndHV); UpdateHighlight(szFilePath, 0, TRUE); return TRUE; }
// // Open the specified file // BOOL HexOpenFile(HWND hwndMain, LPCTSTR szFileName, DWORD fHexViewFlags) { HWND hwndHV; TCITEM tci = { TCIF_PARAM, 0, 0, NULL, 0, 0, 0 }; BOOL fReuseTab = FALSE; int i; // is the file already open?! if(HexIsOpen(hwndMain, szFileName, &i)) { return HexSetCurFile(hwndMain, i, TRUE); } // shall we use the (untitled) document or create a new window? if(TabCtrl_GetItemCount(g_hwndTabView) == 1 && TabCtrl_GetItem(g_hwndTabView, 0, &tci)) { hwndHV = (HWND)tci.lParam; // is file (new) and unmodified? if(HexView_GetFileName(hwndHV, 0,0) == 0 && HexView_CanUndo(hwndHV) == FALSE && HexView_CanRedo(hwndHV) == FALSE) { fReuseTab = TRUE; } } if(fReuseTab == FALSE) hwndHV = CreateHexViewCtrl(hwndMain); // if(HexView_OpenFile(hwndHV, szFileName, fHexViewFlags)) { DWORD e = GetLastError(); LoadHighlights(hwndHV); UpdateCurFileName(hwndMain, hwndHV, szFileName, FALSE); if(fReuseTab == FALSE) { tci.mask = TCIF_PARAM | TCIF_TEXT | TCIF_STATE; tci.dwState = TCIS_FILENAME; tci.lParam = (LPARAM)hwndHV; tci.pszText = (WCHAR *)szFileName;//g_szFileTitle; // insert at the end TabCtrl_InsertItem(g_hwndTabView, TabCtrl_GetItemCount(g_hwndTabView), &tci); } UpdateMainTabs(g_hwndTabView); HexSetCurFile(hwndMain, TabCtrl_GetItemCount(g_hwndTabView)-1, TRUE); if(e == ERROR_SHARING_VIOLATION) { HexInfoBox(TEXT("%s\r\nhas been opened as read-only."), g_szFileName); //MessageBox(hwndMain, TEXT("Another "), TEXT("HexEdit"), MB_ICONINFORMATION); } UpdateHighlight(szFileName, 0, TRUE); UpdateTypeView(); return TRUE; } else { DWORD dwError = GetLastError(); DestroyWindow(hwndHV); FmtErrorMsg(hwndMain, MB_OK|MB_ICONWARNING, dwError, TEXT("Error opening \'%s\'\r\n\r\n"), szFileName); return FALSE; } }