예제 #1
0
BOOL CBookmarkDlg::Create(CWnd *pParentWnd)
{
	if (!CDialog::Create(MAKEINTRESOURCE(IDD), pParentWnd)) // IDD_BOOKMARKS
	{
		TRACE0("Failed to create bookmarks dialog\n");
		return FALSE; // failed to create
	}

	// Default to retaining network/removeable drive files when validating
	ASSERT(GetDlgItem(IDC_NET_RETAIN) != NULL);
	((CButton *)GetDlgItem(IDC_NET_RETAIN))->SetCheck(BST_CHECKED);

	ASSERT(GetDlgItem(IDC_GRID_BL) != NULL);
	if (!grid_.SubclassWindow(GetDlgItem(IDC_GRID_BL)->m_hWnd))
	{
		TRACE0("Failed to subclass grid control\n");
		return FALSE;
	}

	// Set up the grid control
	grid_.SetDoubleBuffering();
	grid_.SetAutoFit();
	grid_.SetCompareFunction(&bl_compare);
	grid_.SetGridLines(GVL_BOTH); // GVL_HORZ | GVL_VERT
	grid_.SetTrackFocusCell(FALSE);
	grid_.SetFrameFocusCell(FALSE);
	grid_.SetListMode(TRUE);
	grid_.SetSingleRowSelection(FALSE);
	grid_.SetHeaderSort(TRUE);

	grid_.SetFixedRowCount(1);

	InitColumnHeadings();
	grid_.SetColumnResize();

	grid_.EnableRowHide(FALSE);
	grid_.EnableColumnHide(FALSE);
	grid_.EnableHiddenRowUnhide(FALSE);
	grid_.EnableHiddenColUnhide(FALSE);

	FillGrid();

	grid_.ExpandColsNice(FALSE);

	// Set up resizer control
	// We must set the 4th parameter true else we get a resize border
	// added to the dialog and this really stuffs things up inside a pane.
	m_resizer.Create(GetSafeHwnd(), TRUE, 100, TRUE);

	// It needs an initial size for it's calcs
	CRect rct;
	GetWindowRect(&rct);
	m_resizer.SetInitialSize(rct.Size());
	m_resizer.SetMinimumTrackingSize(rct.Size());

	// This can cause problems if done too early (OnCreate or OnInitDialog)
	m_resizer.Add(IDOK, 100, 0, 0, 0);
	m_resizer.Add(IDC_BOOKMARK_NAME, 0, 0, 100, 0);
	m_resizer.Add(IDC_BOOKMARK_ADD, 100, 0, 0, 0);
	m_resizer.Add(IDC_GRID_BL, 0, 0, 100, 100);
	m_resizer.Add(IDC_BOOKMARK_GOTO, 100, 0, 0, 0);
	m_resizer.Add(IDC_BOOKMARK_REMOVE, 100, 0, 0, 0);
	m_resizer.Add(IDC_BOOKMARKS_VALIDATE, 100, 0, 0, 0);
	m_resizer.Add(IDC_NET_RETAIN, 100, 0, 0, 0);
	m_resizer.Add(IDC_BOOKMARKS_HELP, 100, 0, 0, 0);

	return TRUE;
}
예제 #2
0
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;
}