예제 #1
0
BOOL CDlgResLib::PreTranslateMessage(MSG* pMsg)
{
	ASSERT_VALID(this);
	ASSERT(m_hWnd != NULL);

	CWnd* pOwner = GetOwner();

	// don't translate dialog messages when in Shift+F1 help mode
	CFrameWnd* pFrameWnd = GetTopLevelFrame();
	if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
		return FALSE;

	// since 'IsDialogMessage' will eat frame window accelerators,
	//   we call all frame windows' PreTranslateMessage first
	while (pOwner != NULL)
	{
		// allow owner & frames to translate before IsDialogMessage does
		if (pOwner->PreTranslateMessage(pMsg))
			return TRUE;

		// try parent frames until there are no parent frames
		if (IsWindow (pOwner->GetSafeHwnd ()))
		{
			pOwner = pOwner->GetParentFrame();
		}
		else
		{
			break;
		}
	}

	return CDialogEx::PreTranslateMessage(pMsg);
}
예제 #2
0
BOOL CControlBar::PreTranslateMessage(MSG* pMsg)
{
	ASSERT_VALID(this);
	ASSERT(m_hWnd != NULL);

	// handle mouse messages for tooltip support
	if (m_dwStyle & (CBRS_FLYBY|CBRS_TOOLTIPS))
		FilterToolTipMsg(pMsg->message, pMsg->pt);

	// don't translate dialog messages when in Shift+F1 help mode
	CFrameWnd* pFrameWnd = GetTopLevelFrame();
	if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
		return FALSE;

	// since 'IsDialogMessage' will eat frame window accelerators,
	//   we call all frame windows' PreTranslateMessage first
	CWnd* pOwner = GetOwner();  // always use owner first
	while (pOwner != NULL)
	{
		// allow owner & frames to translate before IsDialogMessage does
		if (pOwner->PreTranslateMessage(pMsg))
			return TRUE;

		// try parent frames until there are no parent frames
		pOwner = pOwner->GetParentFrame();
	}

	// filter both messages to dialog and from children
	return PreTranslateInput(pMsg);
}
예제 #3
0
void FullViewWindow( HWND hWindow, int x, int y, int cx, int cy,
                     BOOL fClipToImage )
/************************************************************************/
{
RECT NewWindowRect;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWindow;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

// if window is iconic, do nothing here
if (IsIconic(hMDIWindow))
    return;

lpImage = GetImagePtr(hWindow);
lpDisplay = GetDisplayPtr(hWindow);

// if window is maximized, do not change the size of the window
if ( !IsZoomed(hMDIWindow) )
    {
    // get the difference between the client area and the window area
    // not including scrollbars (i.e. - pretend scrollbars aren't there)
    // this is so we know how much extra size is needed for caption,
    // borders, etc. when we size the window
    CalcFullViewWindowSize( &NewWindowRect, &lpDisplay->FileRect,
        lpDisplay->FileRate, lpImage->npix, lpImage->nlin,
        x, y, lpDisplay->HasRulers, fClipToImage );
    // now actually size the window, it's possible nothing will happen here
    ASSERT(pWnd->IsKindOf(RUNTIME_CLASS(CServerView)));        
    pWnd->GetParentFrame()->MoveWindow(NewWindowRect.left, NewWindowRect.top,
        RectWidth(&NewWindowRect), RectHeight(&NewWindowRect), TRUE);
    }

// recompute DispRect and FileRect for cx and cy
// and also it's possible there was no WM_SIZE
ComputeDispRect(hWindow);
ComputeFileRect(hWindow, cx, cy, lpDisplay->FileRate );
SetupRulers(hWindow);
InvalidateRect(hWindow, NULL, TRUE);
}
예제 #4
0
void ViewAll(HWND hWnd)
/************************************************************************/
{
int x, y, width, height, rs, left, top;
RECT rClient;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

GetClientRect(hWnd, &rClient);
width = rClient.right - rClient.left;
height = rClient.bottom - rClient.top;
if (lpDisplay->HasRulers)
    {
    rs = GetRulerSize();
    width -= rs;
    height -= rs;
    }
if ((width <= 0 || height <= 0) && !View.ZoomWindow)
    return;

SaveLastView(hWnd);
lpDisplay->FileRect.top = 0;
lpDisplay->FileRect.left = 0;
lpDisplay->FileRect.bottom = lpImage->nlin - 1;
lpDisplay->FileRect.right = lpImage->npix - 1;
lpDisplay->FileRate = TINYRATE;
lpDisplay->ViewPercentage = 0;
x = ( lpDisplay->FileRect.left 
    + lpDisplay->FileRect.right+1 ) / 2;
y = ( lpDisplay->FileRect.top 
    + lpDisplay->FileRect.bottom+1 ) / 2;
if (View.ZoomWindow)
    {
	GetWinXY(hMDIWindow, &left, &top);
    FullViewWindow(hWnd, left, top, x, y, YES);
    }
else
    {
    ComputeDispRect(hWnd);
    ComputeFileRect(hWnd, x, y, lpDisplay->FileRate);
    SetupRulers(hWnd);
    InvalidateRect(hWnd, NULL, TRUE);
    }
}
예제 #5
0
BOOL ZoomEnable( HWND hWnd, int value, BOOL fIncremental)
/************************************************************************/
{
LFIXED FileRate;
int Percentage;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return(FALSE);
		 
return(ComputeZoom(hWnd,0,0,value,fIncremental, &FileRate, &Percentage));
}
예제 #6
0
void ViewRect(HWND hWnd, LPRECT lpRect,  BOOL fResizeWindow)
/************************************************************************/
{
int x, y, left, top;
RECT rMax;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

lpDisplay = GetDisplayPtr(hWnd);

if (fResizeWindow) // if allowed to change size use a max size
    GetClientRect(PictPubApp.Get_hClientAstral(), &rMax);
else // if window size will not change use current DispRect
    rMax = lpDisplay->DispRect;
if (!CanZoom(hWnd, 0L, lpRect, &rMax))
    return;
SaveLastView(hWnd);
lpDisplay->FileRect = *lpRect;
lpDisplay->FileRate = 0;
lpDisplay->ViewPercentage = 0;
x = (lpDisplay->FileRect.left 
    + lpDisplay->FileRect.right+1) / 2;
y = ( lpDisplay->FileRect.top 
    + lpDisplay->FileRect.bottom+1) / 2;
if (fResizeWindow)
    {
    GetWinXY(hMDIWindow, &left, &top);
    FullViewWindow(hWnd, left, top, x, y, NO);
    }
else
    {
    ComputeDispRect(hWnd);
    ComputeFileRect(hWnd, x, y, lpDisplay->FileRate);
    SetupRulers(hWnd);
    InvalidateRect(hWnd, NULL, TRUE);
    }
ZoomMainViewChanged(hWnd);
}
예제 #7
0
void Zoom( HWND hWnd, int x, int y, int value, BOOL fIncremental,
            BOOL fAllowSizeChange )
/************************************************************************/
{
LFIXED FileRate;
int Percentage, left, top;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return;

if (!ComputeZoom(hWnd,x,y,value,fIncremental, &FileRate, &Percentage))
    {
    Message( IDS_BADZOOM );
    return;
    }

SaveLastView(hWnd);
lpDisplay = GetDisplayPtr(hWnd);
lpDisplay->ViewPercentage = Percentage;
lpDisplay->FileRate = FileRate;
if (fAllowSizeChange)
    {
	 GetWinXY(hMDIWindow, &left, &top);
    FullViewWindow(hWnd, left, top, x, y, YES);
    }
else
    {
    ComputeDispRect(hWnd);
    // Change the FileRect to accomodate
    ComputeFileRect( hWnd, x, y, FileRate);
    SetupRulers(hWnd);
    InvalidateRect( hWnd, NULL, TRUE );
    }
ZoomMainViewChanged(hWnd);      // update the 'zoom window'
}
예제 #8
0
void RevertLastView(HWND hWnd)
/************************************************************************/
{
int iWidth, iHeight, i;
RECT FileRect, WindowRect,r;
LFIXED FileRate;
int ViewPercentage;
POINT UpperLeft;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;
HWND hMDIWindow = hWnd;
HWND  hClient;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return;

FileRect = lpDisplay->FileRect;
lpDisplay->FileRect = lpDisplay->LastFileRect;
lpDisplay->LastFileRect = FileRect;
FileRate = lpDisplay->FileRate;
lpDisplay->FileRate = lpDisplay->LastFileRate;
lpDisplay->LastFileRate = FileRate;
ViewPercentage = lpDisplay->ViewPercentage;
lpDisplay->ViewPercentage = lpDisplay->LastViewPercentage;
lpDisplay->LastViewPercentage = ViewPercentage;
ComputeDispRect(hWnd);
ComputeFileRect(hWnd, -1, -1, lpDisplay->FileRate);
GetWindowRect(hWnd, &WindowRect);
hClient = GetParent(hMDIWindow);
ScreenToClient(hClient, (LPPOINT)&WindowRect);
ScreenToClient(hClient, (LPPOINT)&WindowRect.right);
if (!IsZoomed(hMDIWindow) && !EqualRect(&lpDisplay->LastWindowRect, &WindowRect))
    {
    GetWindowRect(hMDIWindow, &r);
    ScreenToClient(hClient, (LPPOINT)&r);
    ScreenToClient(hClient, (LPPOINT)&r.right);
    iWidth   = RectWidth(&lpDisplay->LastWindowRect)-1;
    iWidth  += r.right - WindowRect.right;
    iHeight  = RectHeight(&lpDisplay->LastWindowRect)-1;
    iHeight += r.bottom - WindowRect.bottom;
    UpperLeft.x  = lpDisplay->LastWindowRect.left;
    i            = (WindowRect.left - r.left);
    UpperLeft.x -= i;
    iWidth      += i;
    UpperLeft.y  = lpDisplay->LastWindowRect.top;
    i            = (WindowRect.top - r.top);
    UpperLeft.y -= i;
    iHeight     += i;
    MoveWindow(hMDIWindow,UpperLeft.x, UpperLeft.y, iWidth, iHeight, TRUE);

    lpDisplay->LastWindowRect = WindowRect;
    }
else
    {
    SetupRulers(hWnd);
    InvalidateRect(hWnd, NULL, TRUE);
    }
ZoomMainViewChanged(hWnd);
}
예제 #9
0
void ComputeDispRect(HWND hWnd)
/************************************************************************/
{
int w, h, dx, dy;
int iWidth, iHeight, iImageWidth, iImageHeight;
LFIXED DispRate;
RECT DispRect;
BOOL bZoomed, bIconic;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

BOOL bInPlaceFrameType = FALSE;
HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
{
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();
	bInPlaceFrameType = ((CServerView*)pWnd)->GetDocument()->IsInPlaceActive();
}

// get max size of client area with no scrollbars
GetDispRect(hWnd, &DispRect, 1, 1);
w = RectWidth(&DispRect);
h = RectHeight(&DispRect);

// If we have no FileRate to this point, it means somebody wants
// to display a specific FileRect.  Calculate a FileRate so that
// we can calculate a DispRect.  This is necessary because it is
// possible (when the window is maximized for example) that the
// FileRect requested will not fill up the window, so it would
// need to be recalculated.  It is assumed that scrollbars would
// not be needrf and should not be needed if the calculation is
// done correctly, which hopefully it is.
if (!lpDisplay->FileRate)
    {
    iWidth = w; iHeight = h;
    DispRate = ScaleToFit(&iWidth, &iHeight, RectWidth(&lpDisplay->FileRect), RectHeight(&lpDisplay->FileRect));
    lpDisplay->FileRate = FGET(FUNITY, DispRate);
    }
if (lpDisplay->FileRate == TINYRATE) // Iconic
    {
    iWidth = w;
    iHeight = h;

    iImageWidth = lpImage->npix;
    iImageHeight = lpImage->nlin;
    DispRate = ScaleToFit(&iWidth, &iHeight, iImageWidth, iImageHeight);
	//---------------------------------------------------------------------
	// NOTE!! added bInPlaceFrameType here because Insitu needs to be able 
	// to scale over 100%.
	//---------------------------------------------------------------------
	if (!bInPlaceFrameType && (DispRate > FGET(1, 1))) 
        {
        DispRate = FGET(1, 1);
        iWidth = FMUL(iImageWidth, DispRate);
        iHeight = FMUL(iImageHeight, DispRate);
        }
    }
else // if (lpDisplay->FileRate) // Specific FileRate
    {
    // Calulate how much space is needed at this FileRate
    DispRate = FGET(FUNITY, lpDisplay->FileRate);
    iImageWidth = FMUL(lpImage->npix, DispRate);
    iImageHeight = FMUL(lpImage->nlin, DispRate);

    // See if scrollbars will be necessary and get the
    // appropriate DispRect if so
    if (iImageWidth > w && iImageHeight > h)
        {
        GetDispRect(hWnd, &DispRect, 2, 2);
        }
    else
    if (iImageWidth > w)
        {
        GetDispRect(hWnd, &DispRect, 2, 1);
        h = RectHeight(&DispRect);
        if (iImageHeight > h)
            {
            GetDispRect(hWnd, &DispRect, 2, 2);
            }
        }
    else
    if (iImageHeight > h)
        {
        GetDispRect(hWnd, &DispRect, 1, 2);
        w = RectWidth(&DispRect);
        if (iImageWidth > w)
            {
            GetDispRect(hWnd, &DispRect, 2, 2);
            }
        }
    w = RectWidth(&DispRect);
    h = RectHeight(&DispRect);
    iWidth = w;
    iHeight = h;

    // Clip the DispRect size to the amount needed for image
    if (iImageWidth < iWidth)
        iWidth = iImageWidth;
    if (iImageHeight < iHeight)
        iHeight = iImageHeight;
    }

bIconic = IsIconic(hMDIWindow);
bZoomed = IsZoomed(hMDIWindow);
if (bZoomed || bIconic)
    {
    dy = RectHeight(&DispRect) - iHeight;
    dy /= 2;
    dx = RectWidth(&DispRect) - iWidth;
    dx /= 2;
    lpDisplay->DispRect.top = DispRect.top + dy;
    lpDisplay->DispRect.left = DispRect.left + dx;
    }
else
    {
    lpDisplay->DispRect.top = DispRect.top;
    lpDisplay->DispRect.left = DispRect.left;
    }
lpDisplay->DispRect.bottom = lpDisplay->DispRect.top + iHeight - 1;
lpDisplay->DispRect.right = lpDisplay->DispRect.left + iWidth - 1;
}
예제 #10
0
static int ComputeZoom( HWND hWnd, int x, int y, int value,
                        BOOL fIncremental, LFIXED *lfFileRate,
                        int *Percentage )
/************************************************************************/
{
LFIXED DispRate;
int OldPercentage, iImageWidth, iImageHeight;
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

HWND hMDIWindow = hWnd;
CWnd *pWnd = CWnd::FromHandle(hMDIWindow);
if (pWnd->IsKindOf(RUNTIME_CLASS(CServerView)))        
	hMDIWindow = pWnd->GetParentFrame()->GetSafeHwnd();

if (IsIconic(hMDIWindow))
    return(FALSE);

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

// Compute the viewing percentage, if necessary
if ( !(*Percentage = lpDisplay->ViewPercentage) )
    *Percentage = FMUL( 100, lpDisplay->DispRate );

// Compute the NEW viewing percentage, and DispRate
if ( fIncremental )
    {
    if (value < 0)
        {
        if (*Percentage > 100)
            {
            if (*Percentage % 100 != 0)
                *Percentage -= *Percentage % 100;
            else
                *Percentage -= 100;
            }
        else
        if (*Percentage <= 1)
            *Percentage = 0;
        else
            {
            OldPercentage = *Percentage;
            *Percentage = 100;
            while (*Percentage >= OldPercentage)
                *Percentage = (*Percentage+1)/2;
            }
        }
    else
    if (value > 0)
        {
        if (*Percentage > 32600)
            *Percentage = 0;
        else
        if (*Percentage >= 50)
            *Percentage = ((*Percentage+100)/100) * 100;
        else
        if (*Percentage)
            {
            OldPercentage = (*Percentage * 2) + 1;
            *Percentage = 100;
            while (*Percentage > OldPercentage)
                *Percentage = (*Percentage+1)/2;
            }
        else
            *Percentage = 1;
        }
    }
else
if (value > 0 && value < 32700)
    *Percentage  = value;
else
    *Percentage = 0;

// do we have a valid zoom percentage?
if (!*Percentage)
    return(FALSE);

// can we mathematically support this percentage?
DispRate = FGET( *Percentage, 100 );  /* DispRate */
*lfFileRate = FGET( 100, *Percentage );  /* FileRate */
if (!CanZoom(hWnd, *lfFileRate, &lpDisplay->FileRect,
        &lpDisplay->DispRect))
    {
    return(FALSE);
    }

// is our display surface too small?
iImageWidth = FMUL(lpImage->npix, DispRate);
iImageHeight = FMUL(lpImage->nlin, DispRate);
if (iImageHeight < 1 || iImageWidth < 1)
    {
    return(FALSE);
    }
return(TRUE);
}
예제 #11
0
BOOL CControlBar::PreTranslateMessage(MSG* pMsg)
{
	ASSERT_VALID(this);
	ASSERT(m_hWnd != NULL);

	// allow tooltip messages to be filtered
	if (CWnd::PreTranslateMessage(pMsg))
		return TRUE;

	UINT message = pMsg->message;
	CWnd* pOwner = GetOwner();

	// handle CBRS_FLYBY style (status bar flyby help)
	if (((m_dwStyle & CBRS_FLYBY) ||
		message == WM_LBUTTONDOWN || message == WM_LBUTTONUP) &&
		((message >= WM_MOUSEFIRST && message <= AFX_WM_MOUSELAST) ||
		 (message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST)))
	{
	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();

		// gather information about current mouse position
		CPoint point = pMsg->pt;
		ScreenToClient(&point);
		TOOLINFO ti; memset(&ti, 0, sizeof(TOOLINFO));
		ti.cbSize = sizeof(AFX_OLDTOOLINFO);
		INT_PTR nHit = OnToolHitTest(point, &ti);
		if (ti.lpszText != LPSTR_TEXTCALLBACK)
			free(ti.lpszText);
		BOOL bNotButton =
			message == WM_LBUTTONDOWN && (ti.uFlags & TTF_NOTBUTTON);
		if (message != WM_LBUTTONDOWN && GetKeyState(VK_LBUTTON) < 0)
			nHit = pModuleThreadState->m_nLastStatus;

		// update state of status bar
		if (nHit < 0 || bNotButton)
		{
			if (GetKeyState(VK_LBUTTON) >= 0 || bNotButton)
			{
				SetStatusText(static_cast<INT_PTR>(-1));
				KillTimer(ID_TIMER_CHECK);
			}
		}
		else
		{
			if (message == WM_LBUTTONUP)
			{
				SetStatusText(static_cast<INT_PTR>(-1));
				ResetTimer(ID_TIMER_CHECK, 200);
			}
			else
			{
				if ((m_nStateFlags & statusSet) || GetKeyState(VK_LBUTTON) < 0)
					SetStatusText(nHit);
				else if (nHit != pModuleThreadState->m_nLastStatus)
					ResetTimer(ID_TIMER_WAIT, 300);
			}
		}
		pModuleThreadState->m_nLastStatus = nHit;
	}

	// don't translate dialog messages when in Shift+F1 help mode
	CFrameWnd* pFrameWnd = GetTopLevelFrame();
	if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
		return FALSE;

	// since 'IsDialogMessage' will eat frame window accelerators,
	//   we call all frame windows' PreTranslateMessage first
	while (pOwner != NULL)
	{
		// allow owner & frames to translate before IsDialogMessage does
		if (pOwner->PreTranslateMessage(pMsg))
			return TRUE;

		// try parent frames until there are no parent frames
		pOwner = pOwner->GetParentFrame();
	}

	// filter both messages to dialog and from children
	if (::IsWindow(m_hWnd))
		return PreTranslateInput(pMsg);
	return FALSE;
}