HexEdit/HexEditView.cpp
CChildFrame *CHexEditView::comp_window()
{
	CMainFrame *mm = dynamic_cast<CMainFrame *>(AfxGetMainWnd());
	CChildFrame *nextc;         // Loops through all MDI child frames
	CChildFrame *compc = NULL;  // Frame of view available to compare with
	BOOL got_one;               // Have we gound an appropriate view?

	// Get the currently active child MDI window
	nextc = dynamic_cast<CChildFrame *>(mm->MDIGetActive());
	ASSERT(nextc != NULL);
	ASSERT(nextc->GetHexEditView() == this);

	// Search for another (non-iconized) window
	for (got_one = FALSE, nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT));
		 nextc != NULL; nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT)) )
	{
		if (!nextc->IsIconic())
		{
			// More than one found - use which one?
			if (got_one)
			{
// Can't display message when used in OnUpdateEditCompare call
//              AfxMessageBox("Comparison not performed\n"
//                              "- more than two (non-iconized) windows");
				return NULL;
			}
			got_one = TRUE;
			compc = nextc;
		}
	}

	// If we didn't find a non-iconized window search for iconized one
	if (compc == NULL)
	{
		nextc = dynamic_cast<CChildFrame *>(mm->MDIGetActive());

		// Search for an iconized window
		for (got_one = FALSE, nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT));
			 nextc != NULL; nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT)) )
		{
			ASSERT(nextc->IsIconic());          // else compc != NULL
			// If more than one window - use which one?
			if (got_one)
			{
// Can't display message when used in OnUpdateEditCompare call
//              AfxMessageBox("Comparison not performed\n"
//                              "- more than two windows found");
				return NULL;
			}
			got_one = TRUE;
			compc = nextc;
		}
	}
	return compc;
}
// Returns the child frame of another non-minimized window.
// If there is not exactly one such window (not including current window) then returns NULL.
// This is used to find another window to compare with when the use selects Edit/Compare
// (or Alt+C) to compare from the current cursor position in each window.

Returns the child frame of another non-minimized window.
If there is not exactly one such window (not including current window) then returns NULL.
This is used to find another window to compare with when the use selects Edit/Compare
(or Alt+C) to compare from the current cursor position in each window.
Returns the child frame of another non - minimized window . If there is not exactly one such window ( not including current window ) then returns NULL . This is used to find another window to compare with when the use selects Edit / Compare ( or Alt + C ) to compare from the current cursor position in each window .
CChildFrame *CHexEditView::comp_window()
{
	CMainFrame *mm = dynamic_cast<CMainFrame *>(AfxGetMainWnd());
	CChildFrame *nextc;         
	CChildFrame *compc = NULL;  
	BOOL got_one;               
	nextc = dynamic_cast<CChildFrame *>(mm->MDIGetActive());
	ASSERT(nextc != NULL);
	ASSERT(nextc->GetHexEditView() == this);
	for (got_one = FALSE, nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT));
		 nextc != NULL; nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT)) )
	{
		if (!nextc->IsIconic())
		{
			if (got_one)
			{
				return NULL;
			}
			got_one = TRUE;
			compc = nextc;
		}
	}
	if (compc == NULL)
	{
		nextc = dynamic_cast<CChildFrame *>(mm->MDIGetActive());
		for (got_one = FALSE, nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT));
			 nextc != NULL; nextc = dynamic_cast<CChildFrame *>(nextc->GetWindow(GW_HWNDNEXT)) )
		{
			ASSERT(nextc->IsIconic());          
			if (got_one)
			{
				return NULL;
			}
			got_one = TRUE;
			compc = nextc;
		}
	}
	return compc;
}
CChildFrame * CHexEditView :: comp_window ( ) { CMainFrame * mm = dynamic_cast < CMainFrame * > ( AfxGetMainWnd ( ) ) ; CChildFrame * nextc ; CChildFrame * compc = NULL ; BOOL got_one ; nextc = dynamic_cast < CChildFrame * > ( mm -> MDIGetActive ( ) ) ; ASSERT ( nextc != NULL ) ; ASSERT ( nextc -> GetHexEditView ( ) == this ) ; for ( got_one = FALSE , nextc = dynamic_cast < CChildFrame * > ( nextc -> GetWindow ( GW_HWNDNEXT ) ) ; nextc != NULL ; nextc = dynamic_cast < CChildFrame * > ( nextc -> GetWindow ( GW_HWNDNEXT ) ) ) { if ( ! nextc -> IsIconic ( ) ) { if ( got_one ) { return NULL ; } got_one = TRUE ; compc = nextc ; } } if ( compc == NULL ) { nextc = dynamic_cast < CChildFrame * > ( mm -> MDIGetActive ( ) ) ; for ( got_one = FALSE , nextc = dynamic_cast < CChildFrame * > ( nextc -> GetWindow ( GW_HWNDNEXT ) ) ; nextc != NULL ; nextc = dynamic_cast < CChildFrame * > ( nextc -> GetWindow ( GW_HWNDNEXT ) ) ) { ASSERT ( nextc -> IsIconic ( ) ) ; if ( got_one ) { return NULL ; } got_one = TRUE ; compc = nextc ; } } return compc ; }
Returns the child frame of another non-minimized window.
Returns the child frame of another non - minimized window .
// Loops through all MDI child frames
 // Frame of view available to compare with
 // Have we gound an appropriate view?
 // Get the currently active child MDI window
 // Search for another (non-iconized) window
 // More than one found - use which one?
 // Can't display message when used in OnUpdateEditCompare call
 //              AfxMessageBox("Comparison not performed\n"
 //                              "- more than two (non-iconized) windows");
 // If we didn't find a non-iconized window search for iconized one
 // Search for an iconized window
 // else compc != NULL
 // If more than one window - use which one?
 // Can't display message when used in OnUpdateEditCompare call
 //              AfxMessageBox("Comparison not performed\n"
 //                              "- more than two windows found");
