void CBookmarkDlg::FillGrid() { CHexEditView *pview; // Active view CHexEditDoc *pdoc = NULL; // Active document (doc of the active view) int first_sel_row = -1; // Row of first bookmark found in the active document if (FALSE && (pview = GetView()) != NULL) pdoc = pview->GetDocument(); // Load all the bookmarks into the grid control CBookmarkList *pbl = theApp.GetBookmarkList(); ASSERT(pbl->name_.size() == pbl->file_.size()); int index, row; for (index = pbl->name_.size()-1, row = grid_.GetFixedRowCount(); index >= 0; index--) { // Don't show empty (deleted) names or those starting with an underscore (internal use) if (!pbl->name_[index].IsEmpty() && pbl->name_[index][0] != '_') { grid_.SetRowCount(row + 1); // If this bookmark is in the currently active document then select it if (pdoc != NULL && std::find(pdoc->bm_index_.begin(), pdoc->bm_index_.end(), index) != pdoc->bm_index_.end()) { if (first_sel_row == -1) first_sel_row = row; UpdateRow(index, row, TRUE); } else UpdateRow(index, row); ++row; } } if (first_sel_row != -1) grid_.EnsureVisible(first_sel_row, 0); }
void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWndEx::OnSetFocus(pOldWnd); CHexEditView *pv = GetHexEditView(); if (pv != NULL) { pv->show_prop(); pv->show_pos(); } }
LRESULT CBookmarkDlg::OnKickIdle(WPARAM, LPARAM lCount) { ASSERT(GetDlgItem(IDOK) != NULL); ASSERT(GetDlgItem(IDC_BOOKMARK_NAME) != NULL); ASSERT(GetDlgItem(IDC_BOOKMARK_ADD) != NULL); ASSERT(GetDlgItem(IDC_GRID_BL) != NULL); ASSERT(GetDlgItem(IDC_BOOKMARK_GOTO) != NULL); ASSERT(GetDlgItem(IDC_BOOKMARK_REMOVE) != NULL); ASSERT(GetDlgItem(IDC_BOOKMARKS_VALIDATE) != NULL); ASSERT(GetDlgItem(IDC_NET_RETAIN) != NULL); ASSERT(GetDlgItem(IDC_BOOKMARKS_HELP) != NULL); if (m_first) { m_first = false; } // If there are no views or no associated files disallow adding of bookmarks CHexEditView *pview = GetView(); if (pview == NULL || pview->GetDocument()->pfile1_ == NULL) { GetDlgItem(IDC_BOOKMARK_NAME)->SetWindowText(""); GetDlgItem(IDC_BOOKMARK_NAME)->EnableWindow(FALSE); } else { GetDlgItem(IDC_BOOKMARK_NAME)->EnableWindow(TRUE); } CString ss; GetDlgItem(IDC_BOOKMARK_NAME)->GetWindowText(ss); GetDlgItem(IDC_BOOKMARK_ADD)->EnableWindow(!ss.IsEmpty()); CCellRange sel = grid_.GetSelectedCellRange(); GetDlgItem(IDC_BOOKMARK_GOTO)->EnableWindow(sel.IsValid() && sel.GetMinRow() == sel.GetMaxRow()); GetDlgItem(IDC_BOOKMARK_REMOVE)->EnableWindow(sel.IsValid()); // Display context help for ctrl set up in OnHelpInfo if (help_hwnd_ != (HWND)0) { theApp.HtmlHelpWmHelp(help_hwnd_, id_pairs); help_hwnd_ = (HWND)0; } return FALSE; }
LRESULT CSimpleGraph::OnMouseHover(WPARAM, LPARAM lp) { CPoint pt(LOWORD(lp), HIWORD(lp)); // client window coords CHexEditView *pv = GetView(); ASSERT(pv != NULL); m_bar = get_bar(pt); if (m_bar > -1 && !m_tip.IsWindowVisible()) { // Update the tip info m_tip.Clear(); CString ss; if (theApp.hex_ucase_) ss.Format("Byte: %d [%02.2Xh] %s", m_bar, m_bar, pv->DescChar(m_bar)); else ss.Format("Byte: %d [%02.2xh] %s", m_bar, m_bar, pv->DescChar(m_bar)); m_tip.AddString(ss); char buf[32]; // used with sprintf (CString::Format can't handle __int64) sprintf(buf, "%I64d", m_val[m_bar]); ss = buf; AddCommas(ss); m_tip.AddString("Count: " +ss); // Work out the tip window display position and move the tip window there CPoint tip_pt = pt + CSize(16, 16); ClientToScreen(&tip_pt); m_tip.Move(tip_pt, false); m_tip.Show(); track_mouse(TME_LEAVE); return 0; // return 0 to say we processed it } return 1; }
void CBookmarkDlg::OnAdd() { int index; // bookmark index of an existing bookmark of same name (or -1) CHexEditView *pview = GetView(); ASSERT(pview != NULL); if (pview == NULL) return; CBookmarkList *pbl = theApp.GetBookmarkList(); ASSERT(GetDlgItem(IDC_BOOKMARK_NAME) != NULL); CString name; GetDlgItem(IDC_BOOKMARK_NAME)->GetWindowText(name); if (name.GetLength() == 0) return; if (name[0] == '_') { AfxMessageBox("Names beginning with an underscore\r" "are reserved for internal use."); return; } if (name.FindOneOf("|") != -1) { AfxMessageBox("Illegal characters in bookmark name"); return; } CString file_name = pview->GetDocument()->pfile1_->GetFilePath(); if ((index = pbl->GetIndex(name, file_name)) != -1) { CString ss; ss.Format("Bookmark \"%s\" already exists\r" "in \"%s\".\r" "Do you want to move it?", name, file_name); if (AfxMessageBox(ss, MB_YESNO) != IDYES) return; #if 0 // moved to CBookmark // Remove overwritten bookmark from doc where it currently is CDocument *pdoc2; if (theApp.m_pDocTemplate->MatchDocType(pbl->file_[index], pdoc2) == CDocTemplate::yesAlreadyOpen) { ((CHexEditDoc *)pdoc2)->RemoveBookmark(index); } #endif } // Add the bookmark to the list (overwrites existing bookmark of same name) int ii = pbl->AddBookmark(name, file_name, pview->GetPos(), NULL, pview->GetDocument()); theApp.SaveToMacro(km_bookmarks_add, name); // Find the new/replaced bookmark and select int row, col = COL_NAME + grid_.GetFixedColumnCount(); for (row = grid_.GetFixedRowCount(); row < grid_.GetRowCount(); ++row) { if (grid_.GetItemData(row, col) == ii) break; } ASSERT(row < grid_.GetRowCount()); // We should have found it grid_.SetSelectedRange(row, grid_.GetFixedColumnCount(), row, grid_.GetColumnCount()-1); grid_.EnsureVisible(row, 0); pbl->GoTo(ii); #if 0 // moved to CBookmark::Add (now calls CBookmarkDlg::UpdateBookmark) // Save sort col (lost when we modify the grid) so we can re-sort later // int sort_col = grid_.GetSortColumn(); int row; if (index == -1) { // Add a new row row = grid_.GetRowCount(); grid_.SetRowCount(row + 1); } else { // Find the overwritten bookmark int col = COL_NAME + grid_.GetFixedColumnCount(); for (row = grid_.GetFixedRowCount(); row < grid_.GetRowCount(); ++row) { if (grid_.GetItemData(row, col) == index) break; } ASSERT(row < grid_.GetRowCount()); // We should have found it } // Add bookmark to doc pview->GetDocument()->AddBookmark(ii, pos); // Update the row found or added and select it UpdateRow(ii, row); grid_.SetSelectedRange(row, grid_.GetFixedColumnCount(), row, grid_.GetColumnCount()-1); grid_.EnsureVisible(row, 0); // Re-sort the grid on the current sort column // if (sort_col != -1) // grid_.SortItems(sort_col, grid_.GetSortAscending()); // // Close dialog // CDialog::OnOK(); #endif }
LRESULT CCompareListDlg::OnKickIdle(WPARAM, LPARAM lCount) { if (m_first) { m_first = false; InitColumnHeadings(); grid_.ExpandColsNice(FALSE); } // Display context help for ctrl set up in OnHelpInfo if (help_hwnd_ != (HWND)0) { theApp.HtmlHelpWmHelp(help_hwnd_, id_pairs); help_hwnd_ = (HWND)0; } CHexEditView * pview = GetView(); // active file's view (or NULL if none) CHexEditDoc * pdoc = NULL; // active file's doc int diffs = -1; // number of diffs, or -2 if bg compare in progress clock_t curr_change = -1; // time that current compare finished int curr_progress = 0; // progress value if background compare in progress if (pview != NULL) { pdoc = pview->GetDocument(); ASSERT(pdoc != NULL); diffs = pdoc->CompareDifferences(); curr_change = pdoc->LastCompareFinishTime(); } // First work out if we have to redraw the list bool redraw = false; if (pview != phev_) { redraw = true; // we have to redraw after switching files phev_ = pview; // track which view we last used } // Check if we have to redraw because the current file status has changed if (!redraw && pview != NULL) { if (diffs == -2) { // Currently comparing (background) - check if we need to update progress static int last_progress; curr_progress = (pdoc->CompareProgress()/5) * 5; // nearest 5% if (curr_progress != last_progress) { last_progress = curr_progress; redraw = true; // need to update progress } } else if (diffs >= 0 && curr_change != 0 && curr_change != last_change_) { redraw = true; // need to redraw the whole list } } if (redraw) { TRACE("]]]] %p %p %d %d %d\n", pview, pdoc, diffs, (int)last_change_, (int)curr_change); if (pview == NULL) { grid_.SetRowCount(grid_.GetFixedRowCount()); // No view so display empty list } else if (diffs >= 0) { last_change_ = curr_change; // Grid needs updating (switched to diff view or compare just finished) grid_.SetRowCount(grid_.GetFixedRowCount()); // Clear grid before refilling FillGrid(pdoc); // fill grid with results } else if (diffs == -2) { grid_.SetRowCount(grid_.GetFixedRowCount()); // Clear grid before adding message RowAdder rowAdder(grid_, pview); CString mess; mess.Format("%d%% ...", curr_progress); rowAdder.AddMessage(mess, IDS_COMPARE_INPROGRESS); } else { grid_.SetRowCount(grid_.GetFixedRowCount()); // clear list if no compare done } } return FALSE; }