HexEdit/AerialView.cpp
void CAerialView::invalidate_addr_range(FILE_ADDRESS start_addr, FILE_ADDRESS end_addr, bool no_border /*=false*/)
{
	CHexEditDoc *pDoc = GetDocument();
	int width = GetDocument()->GetBpe() * cols_;

	// Restrict to just what is in the display then convert to window device coords
	if (start_addr < scrollpos_) start_addr = scrollpos_;
	if (end_addr > scrollpos_ + width*rows_) end_addr = scrollpos_ + width*rows_;

	// Work out the elts we are invalidating offset from the elt at the top-left
	int start_elt = int((start_addr - scrollpos_)/GetDocument()->GetBpe());
	int end_elt   = int((end_addr - 1 - scrollpos_)/GetDocument()->GetBpe() + 1);
	if (start_elt >= end_elt)
		return;                         // Nothing to invalidate or all outside display

	// Work out line range that needs invalidating
	int start_line = int(start_elt/cols_);
	int end_line   = int(end_elt/cols_);

	CRect rct;

	// If start and end on the same line just invalidate between them
	if (start_line == end_line)
	{
		rct.left   = bdr_left_ + (start_elt%cols_)*actual_dpix_;
		rct.right  = bdr_left_ + (end_elt%cols_)*actual_dpix_;
		rct.top    = bdr_top_ + start_line*actual_dpix_;
		rct.bottom = rct.top + actual_dpix_;
		InvalidateRect(&rct);
		if (!no_border)
		{
			rct.left = 0; rct.right = bdr_left_;    // Do left border too
			InvalidateRect(&rct);
		}
		return;
	}
	// Invalidate partial lines at each end
	rct.left   = bdr_left_ + (start_elt%cols_)*actual_dpix_;
	rct.right  = bdr_left_ + cols_*actual_dpix_;
	rct.top    = bdr_top_ + start_line*actual_dpix_;
	rct.bottom = rct.top + actual_dpix_;
	InvalidateRect(&rct);
	if (!no_border)
	{
		rct.left = 0; rct.right = bdr_left_;        // Do left border too
		InvalidateRect(&rct);
	}

	rct.left   = bdr_left_;
	rct.right  = bdr_left_ + (end_elt%cols_)*actual_dpix_;
	rct.top    = bdr_top_ + end_line*actual_dpix_;
	rct.bottom = rct.top + actual_dpix_;
	InvalidateRect(&rct);
	if (!no_border)
	{
		rct.left = 0; rct.right = bdr_left_;  // Do left border too
		InvalidateRect(&rct);
	}

	// If more than one line between start and end then invalidate that block too
	if (start_line + 1 < end_line)
	{
		rct.left   = bdr_left_;
		rct.right  = bdr_left_ + cols_*actual_dpix_;
		rct.top    = bdr_top_ + start_line*actual_dpix_;
		rct.bottom = bdr_top_ + end_line*actual_dpix_;
		InvalidateRect(&rct);
		if (!no_border)
		{
			rct.left = 0; rct.right = bdr_left_;
			InvalidateRect(&rct);
		}
	}
}
// Given a range of addresses in the file, then rectangles that cover all displayed
// addresses are invalidated which (sooner or later) causes those areas to be redrawn.
// Note that this invalidates the inside which is slow for a large area and 
// not necessary for marching ants (see invalidate_addr_range_boundary below).
// Note: We have now uncovered another flaw in Windows invalidation.  When we BLT
//       part of the bitmap we don't want to erase the background as there is no point
//       (since none shows through) but mainly because it causes annoying flashing.
//       But we do want to erase the background for the left border as we just draw
//       indicators as required and the bacground will show through.  However,
//       mixing calls to InvalidateRect with the bErase parameter set to TRUE and
//       FALSE in different calls does not work - all areas have their background
//       erased.  What I think Windows is doing is combining invalidation areas
//       into one bounding rect and if any of the areas is to have the background
//       erased then the whole rect is erased.  This has now been solved by not
//       erasing the bitmap area - just the borders in OnEraseBkgnd.

Given a range of addresses in the file, then rectangles that cover all displayed
addresses are invalidated which (sooner or later) causes those areas to be redrawn.
Note that this invalidates the inside which is slow for a large area and
not necessary for marching ants .
Note: We have now uncovered another flaw in Windows invalidation.  When we BLT
part of the bitmap we don't want to erase the background as there is no point
(since none shows through) but mainly because it causes annoying flashing.
But we do want to erase the background for the left border as we just draw
indicators as required and the bacground will show through.  However,
mixing calls to InvalidateRect with the bErase parameter set to TRUE and
FALSE in different calls does not work - all areas have their background
erased.  What I think Windows is doing is combining invalidation areas
into one bounding rect and if any of the areas is to have the background
erased then the whole rect is erased.  This has now been solved by not
erasing the bitmap area - just the borders in OnEraseBkgnd.
Given a range of addresses in the file then rectangles that cover all displayed addresses are invalidated which ( sooner or later ) causes those areas to be redrawn . Note that this invalidates the inside which is slow for a large area and not necessary for marching ants . Note : We have now uncovered another flaw in Windows invalidation . When we BLT part of the bitmap we don ' t want to erase the background as there is no point ( since none shows through ) but mainly because it causes annoying flashing . But we do want to erase the background for the left border as we just draw indicators as required and the bacground will show through . However mixing calls to InvalidateRect with the bErase parameter set to TRUE and FALSE in different calls does not work - all areas have their background erased . What I think Windows is doing is combining invalidation areas into one bounding rect and if any of the areas is to have the background erased then the whole rect is erased . This has now been solved by not erasing the bitmap area - just the borders in OnEraseBkgnd .
void CAerialView::invalidate_addr_range(FILE_ADDRESS start_addr, FILE_ADDRESS end_addr, bool no_border )
{
	CHexEditDoc *pDoc = GetDocument();
	int width = GetDocument()->GetBpe() * cols_;
	if (start_addr < scrollpos_) start_addr = scrollpos_;
	if (end_addr > scrollpos_ + width*rows_) end_addr = scrollpos_ + width*rows_;
	int start_elt = int((start_addr - scrollpos_)/GetDocument()->GetBpe());
	int end_elt   = int((end_addr - 1 - scrollpos_)/GetDocument()->GetBpe() + 1);
	if (start_elt >= end_elt)
		return;                         
	int start_line = int(start_elt/cols_);
	int end_line   = int(end_elt/cols_);
	CRect rct;
	if (start_line == end_line)
	{
		rct.left   = bdr_left_ + (start_elt%cols_)*actual_dpix_;
		rct.right  = bdr_left_ + (end_elt%cols_)*actual_dpix_;
		rct.top    = bdr_top_ + start_line*actual_dpix_;
		rct.bottom = rct.top + actual_dpix_;
		InvalidateRect(&rct);
		if (!no_border)
		{
			rct.left = 0; rct.right = bdr_left_;    
			InvalidateRect(&rct);
		}
		return;
	}
	rct.left   = bdr_left_ + (start_elt%cols_)*actual_dpix_;
	rct.right  = bdr_left_ + cols_*actual_dpix_;
	rct.top    = bdr_top_ + start_line*actual_dpix_;
	rct.bottom = rct.top + actual_dpix_;
	InvalidateRect(&rct);
	if (!no_border)
	{
		rct.left = 0; rct.right = bdr_left_;        
		InvalidateRect(&rct);
	}
	rct.left   = bdr_left_;
	rct.right  = bdr_left_ + (end_elt%cols_)*actual_dpix_;
	rct.top    = bdr_top_ + end_line*actual_dpix_;
	rct.bottom = rct.top + actual_dpix_;
	InvalidateRect(&rct);
	if (!no_border)
	{
		rct.left = 0; rct.right = bdr_left_;  
		InvalidateRect(&rct);
	}
	if (start_line + 1 < end_line)
	{
		rct.left   = bdr_left_;
		rct.right  = bdr_left_ + cols_*actual_dpix_;
		rct.top    = bdr_top_ + start_line*actual_dpix_;
		rct.bottom = bdr_top_ + end_line*actual_dpix_;
		InvalidateRect(&rct);
		if (!no_border)
		{
			rct.left = 0; rct.right = bdr_left_;
			InvalidateRect(&rct);
		}
	}
}
void CAerialView :: invalidate_addr_range ( FILE_ADDRESS start_addr , FILE_ADDRESS end_addr , bool no_border ) { CHexEditDoc * pDoc = GetDocument ( ) ; int width = GetDocument ( ) -> GetBpe ( ) * cols_ ; if ( start_addr < scrollpos_ ) start_addr = scrollpos_ ; if ( end_addr > scrollpos_ + width * rows_ ) end_addr = scrollpos_ + width * rows_ ; int start_elt = int ( ( start_addr - scrollpos_ ) / GetDocument ( ) -> GetBpe ( ) ) ; int end_elt = int ( ( end_addr - 1 - scrollpos_ ) / GetDocument ( ) -> GetBpe ( ) + 1 ) ; if ( start_elt >= end_elt ) return ; int start_line = int ( start_elt / cols_ ) ; int end_line = int ( end_elt / cols_ ) ; CRect rct ; if ( start_line == end_line ) { rct . left = bdr_left_ + ( start_elt % cols_ ) * actual_dpix_ ; rct . right = bdr_left_ + ( end_elt % cols_ ) * actual_dpix_ ; rct . top = bdr_top_ + start_line * actual_dpix_ ; rct . bottom = rct . top + actual_dpix_ ; InvalidateRect ( & rct ) ; if ( ! no_border ) { rct . left = 0 ; rct . right = bdr_left_ ; InvalidateRect ( & rct ) ; } return ; } rct . left = bdr_left_ + ( start_elt % cols_ ) * actual_dpix_ ; rct . right = bdr_left_ + cols_ * actual_dpix_ ; rct . top = bdr_top_ + start_line * actual_dpix_ ; rct . bottom = rct . top + actual_dpix_ ; InvalidateRect ( & rct ) ; if ( ! no_border ) { rct . left = 0 ; rct . right = bdr_left_ ; InvalidateRect ( & rct ) ; } rct . left = bdr_left_ ; rct . right = bdr_left_ + ( end_elt % cols_ ) * actual_dpix_ ; rct . top = bdr_top_ + end_line * actual_dpix_ ; rct . bottom = rct . top + actual_dpix_ ; InvalidateRect ( & rct ) ; if ( ! no_border ) { rct . left = 0 ; rct . right = bdr_left_ ; InvalidateRect ( & rct ) ; } if ( start_line + 1 < end_line ) { rct . left = bdr_left_ ; rct . right = bdr_left_ + cols_ * actual_dpix_ ; rct . top = bdr_top_ + start_line * actual_dpix_ ; rct . bottom = bdr_top_ + end_line * actual_dpix_ ; InvalidateRect ( & rct ) ; if ( ! no_border ) { rct . left = 0 ; rct . right = bdr_left_ ; InvalidateRect ( & rct ) ; } } }
Given a range of addresses in the file, then rectangles that cover all displayed
addresses are invalidated which (sooner or later) causes those areas to be redrawn.
Given a range of addresses in the file then rectangles that cover all displayed addresses are invalidated which ( sooner or later ) causes those areas to be redrawn .
/*=false*/ // Restrict to just what is in the display then convert to window device coords
 // Work out the elts we are invalidating offset from the elt at the top-left
 // Nothing to invalidate or all outside display
 // Work out line range that needs invalidating
 // If start and end on the same line just invalidate between them
 // Do left border too
 // Invalidate partial lines at each end
 // Do left border too
 // Do left border too
 // If more than one line between start and end then invalidate that block too
