示例#1
0
LOCAL BOOL FullScreenView_OnInitDialog(HWND hDlg, HWND hWndFocus, LPARAM lParam)
{
	CPPMDIChildWnd *pMDIChild;
	HWND hMDIWnd;
	RECT ClientRect;
	int npix, nlin, cx, cy, dx, dy;
	HWND hControl, hMDIChild, hView;
	LPOBJECT lpBase;
	LPFRAME lpFrame;

	// Make the window as big as the screen
	dx = GetSystemMetrics( SM_CXSCREEN );
	dy = GetSystemMetrics( SM_CYSCREEN );
	MoveWindow( hDlg, 0, 0, dx, dy, NO );

	// Compute the center of the window
	GetClientRect( hDlg, &ClientRect );
	cx = ( ClientRect.right + ClientRect.left ) / 2;
	cy = ( ClientRect.bottom + ClientRect.top ) / 2;

	// Link all of the images to image controls
	hControl = GetDlgItem( hDlg, IDC_VIEWFULL );

	CServerView *pView = PictPubApp.GetActiveView();
	BOOL bInplaceActive = (pView && pView->GetDocument()->IsInPlaceActive());
	if (bInplaceActive)
	{
		hMDIChild = pView->GetParentFrame()->GetSafeHwnd();
		hView = pView->GetSafeHwnd();
	}
	else
	{
		pMDIChild = (CPPMDIChildWnd*)((CMDIFrame*)PictPubApp.m_pMainWnd)->MDIGetActive();
		hMDIWnd = pMDIChild->GetSafeHwnd();
		if (hMDIWnd)
			hView = pMDIChild->GetActiveView()->GetSafeHwnd();
		else
			hView = NULL;
	}

	while ( hView )
 	{
		lpBase = ImgGetBase((LPIMAGE)GetImagePtr(hView));
		if ( !lpBase || !hControl )
			break;
		lpFrame = ObjGetEditFrame(lpBase);

		// Link the frame to the image control
		SetWindowLong( hControl, GWL_IMAGE, (long)lpBase );
			
		// The destination size can be no bigger the the screen
		npix = FrameXSize(lpFrame);
		nlin = FrameYSize(lpFrame);
		if ( npix > dx || nlin > dy )
 		{
			npix = dx;
			nlin = dy;
			ScaleToFit( &npix, &nlin,
				FrameXSize(lpFrame), FrameYSize(lpFrame));
 		}

		// Position the control in the center of the window
		ClientRect.left = cx - npix/2;
		ClientRect.right = ClientRect.left + npix;
		ClientRect.top = cy - nlin/2;
		ClientRect.bottom = ClientRect.top + nlin;
		MoveWindow( hControl,
			ClientRect.left, ClientRect.top, // New position
			RectWidth( &ClientRect ),
			RectHeight( &ClientRect ), // New size
			NO /* No repaint*/ );

		if (bInplaceActive)
			break;

		// Check to see if these get destroyed when the window does
		do	
		{
			hView = NULL;
			if (hMDIWnd = GetWindow( hMDIWnd, GW_HWNDNEXT ))
			{
				if ((CWnd::FromHandle(hMDIWnd))->
					IsKindOf(RUNTIME_CLASS(CPPMDIChildWnd)))
					hView = ((CPPMDIChildWnd*)CWnd::FromHandle(hMDIWnd))->
						GetActiveView()->GetSafeHwnd();
			}

		} while (hMDIWnd && !hView);

		if (!hView)
			break;

		// Get another image control				 
		hControl = CopyWindow( hControl );
	}

	return TRUE;
}
示例#2
0
LOCAL LPCMDLIST ProgActivateWindow(LPACTIVATEWINDOW_PARMS lpParms)
/***********************************************************************/
{
int iOffset, nDocs;
CWnd *pActiveWnd, *pNextWnd, *pChild;
CMDIFrameWnd *pMainWnd;
	
pNextWnd = NULL;

pMainWnd = (CMDIFrameWnd *)PictPubApp.m_pMainWnd;

// first look for the filename
CServerDoc *pDoc = PictPubApp.GetDocument(lpParms->szFileName);
if (pDoc)
	{
	// ignore if we are in place
	if (pDoc->IsInPlaceActive())
		return(NULL);

	POSITION ViewPos = pDoc->GetFirstViewPosition();
	if (ViewPos)
		{
	    CView* pView = pDoc->GetNextView( ViewPos );
		if (pView)
			pNextWnd = pView->GetParent();
		}
	}

// if not found, try using windows offsets
if (!pNextWnd && lpParms->iOffset)
	{
	nDocs = 0;
	pChild = pActiveWnd = pMainWnd->MDIGetActive();
	while (pChild)
		{
		++nDocs;
		pChild = pChild->GetWindow(GW_HWNDNEXT);
		}

	if (nDocs)
		{
		iOffset = lpParms->iOffset;
		pNextWnd = pActiveWnd;
		if (iOffset > 0)
			{
			if (iOffset >= nDocs)
				iOffset = nDocs - 1;
			while(pNextWnd && (--iOffset >= 0))
				pNextWnd = pNextWnd->GetWindow(GW_HWNDNEXT);
			}
		else
			{
			if (iOffset <= (-nDocs))
				iOffset = (-nDocs) + 1;
			while(pNextWnd && (++iOffset <= 0))
				pNextWnd = pNextWnd->GetWindow(GW_HWNDPREV);
			}
		}
	}

if (pNextWnd)
	{
	CPPMDIChildWnd *pMDIChild = (CPPMDIChildWnd *)pNextWnd;
	CServerView *pView = (CServerView*)pMDIChild->GetActiveView();
	if (pView)
		{
        CServerDoc *pDoc = pView->GetDocument();
       	ASSERT(pDoc && pDoc->m_lpImage);
		if (pDoc && pDoc->m_lpImage && !pDoc->IsInPlaceActive())
			{
			pMainWnd->MDIActivate(pNextWnd);
			return(pDoc->m_lpImage->lpCmdList);
			}
		}
	}
return(NULL);
}