Пример #1
0
void CWebCtrl::EnterMenu(POINT* pPoint)
{
	if ( m_pThis != NULL )
	{
		SetWindowLongPtr( m_pThis->m_hWndThis, GWLP_WNDPROC, (LONG_PTR)m_pThis->m_pWndProc );
		m_pThis = NULL;
	}

	if ( pPoint == NULL || m_pMenu == NULL ) return;

	CPoint ptScreen( *pPoint );
	ptScreen.Offset( 2, 2 );

	CWnd* pChild = this;
	for ( ;; )
	{
		CPoint ptClient( ptScreen );
		pChild->ScreenToClient( &ptClient );
		CWnd* pNext = pChild->ChildWindowFromPoint( ptClient, CWP_ALL );
		if ( pNext == NULL || pNext == pChild ) break;
		pChild = pNext;
	}

	TCHAR szClass[128];
	GetClassName( *pChild, szClass, 128 );
	if ( _tcsistr( szClass, _T("Internet Explorer") ) == NULL ) return;

	m_pThis = this;
	m_hWndThis = pChild->GetSafeHwnd();
	m_pWndProc = (WNDPROC)(LONG_PTR)GetWindowLongPtr( m_hWndThis, GWLP_WNDPROC );
	SetWindowLongPtr( m_hWndThis, GWLP_WNDPROC, (LONG_PTR)&WebWndProc );
}
Пример #2
0
void CParamTooltipCtrl::ShowTooltip(const CPoint& ptClient)
{
	m_ptOldClient = ptClient;
	CPoint ptScreen(ptClient);
	GetParent()->ClientToScreen(&ptScreen);

	CClientDC dc(this);
	CSize size = Draw(dc, false);

	SetWindowPos(NULL, ptScreen.x, ptScreen.y, size.cx, size.cy, SWP_SHOWWINDOW|SWP_NOACTIVATE);
}
QImage Camera::printScreen(Terrain &t,const Vector2D& a, const Vector2D& b, const Vector3D& s, int l, int h)
{
    QImage im(l,h,QImage::Format_ARGB32);
    double min=t.getHauteurMin(a,b);
    double max=t.getHauteurMax(a,b);
    Vector3D aBox(a.x(),min,a.y());
    Vector3D bBox(b.x(),max*1.5,b.y());

    for(int i=0; i<l; ++i) {
        for(int j=0; j<h; ++j) {
            im.setPixel(i,h-1-j,ptScreen(t,aBox,bBox,s,i,j,l,h));
        }
    }

    return im;

}
Пример #4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pView - 
//			point - 
// Output : 
//-----------------------------------------------------------------------------
bool Marker3D::OnContextMenu2D(CMapView2D *pView, CPoint point)
{
	if (!IsEmpty())
	{
		CMapDoc *pDoc = pView->GetDocument();
		if (pDoc == NULL)
		{
			return true;
		}

		// FIXME: functionalize this or fix it!
		pView->ScreenToClient(&point);

		CRect rect;
		pView->GetClientRect(&rect);
		if (!rect.PtInRect(point))
		{
			return true;
		}

		CPoint ptScreen(point);
		CPoint ptMapScreen(point);
		pView->ClientToScreen(&ptScreen);
		pView->ClientToWorld(point);

		ptMapScreen.x += pView->GetScrollPos(SB_HORZ);
		ptMapScreen.y += pView->GetScrollPos(SB_VERT);

		if (HitTest(ptMapScreen, FALSE) != -1)
		{
			static CMenu menu, menuCreate;
			static bool bInit = false;

			if (!bInit)
			{
				bInit = true;
				menu.LoadMenu(IDR_POPUPS);
				menuCreate.Attach(::GetSubMenu(menu.m_hMenu, 1));
			}

			menuCreate.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_LEFTALIGN, ptScreen.x, ptScreen.y, pView);
		}
	}

	return true;
}
BOOL CVWScale3DTool::OnMouseMove(UINT nFlags, POINT pt)
{
	HRESULT hr = S_OK;
	BOOL bHandled = FALSE;
	HWND hWnd;

	int nDeltaX, nDeltaY;

	if (!m_pUIView || !m_pVWRenderRoot || m_bTrackingMouse == VARIANT_FALSE)
		goto EXIT_FAIL;

	// If no delta then leave.
	if( (pt.x == m_cptLast.x )	&& (pt.y == m_cptLast.y ) )
		goto EXIT_FAIL;

	// If left button is down, scale all selected translatable objects.
	if( (MK_LBUTTON & nFlags)	)
	{
		CPoint ptScreen(m_ptAnchor);

		m_pUIView->get_HWND(&hWnd);
		ClientToScreen(hWnd, &ptScreen);
		SetCursorPos(ptScreen.x, ptScreen.y);

		nDeltaX = pt.x - m_cptLast.x;
		nDeltaY = pt.y - m_cptLast.y;

		if (IsPressed(VK_SHIFT))
		{
			nDeltaX = nDeltaY = (nDeltaX - nDeltaY) / 2;
			//nDeltaY = nDeltaX;
		}
		else
			nDeltaY = -nDeltaY;

		hr = ScaleSelectedObjects((float) (nDeltaX/MOUSE_TO_WORLD_FACTOR), (float) (nDeltaY/MOUSE_TO_WORLD_FACTOR) );
		if (FAILED(hr)) goto EXIT_FAIL;
	}
EXIT_FAIL:

	return bHandled;
}
Пример #6
0
LRESULT CToolBarPopup::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
    if ( WM_MOUSEFIRST <= message && message <= WM_MOUSELAST )
    {
        DWORD dwPos = ::GetMessagePos();
        CPoint ptScreen( LOWORD( dwPos ), HIWORD( dwPos ) );
        CWnd* pWnd = WindowFromPoint( ptScreen );
        if ( pWnd != 0 )
        {
            CPoint ptClient( ptScreen );
            pWnd->ScreenToClient( &ptClient );

            switch ( message )
            {
                case WM_MOUSEMOVE:
                {
                    // Check if hot item should be changed
                    bool bOverTbCtrl = ( pWnd == &m_tbCtrl );
                    if ( bOverTbCtrl )
                    {
                        int nHit = m_tbCtrl.HitTest( &ptClient );
                        m_tbCtrl.SetHotItem( nHit );

                        // Let tooltip control process mouse event
                        CToolTipCtrl* pTtCtrl = m_tbCtrl.GetToolTips();
                        if ( pTtCtrl != 0 )
                        {
                            MSG msg;
                            msg.hwnd    = m_tbCtrl.m_hWnd;
                            msg.message = WM_MOUSEMOVE;
                            msg.wParam  = wParam;
                            msg.lParam  = MAKELPARAM( ptClient.x, ptClient.y );
                            msg.pt      = ptScreen;
                            msg.time    = ::GetMessageTime();
                            pTtCtrl->RelayEvent( &msg );
                        }
                    }
                    else if ( m_bOverTbCtrl )
                    {
                        m_tbCtrl.SetHotItem( -1 );
                    }

                    m_bOverTbCtrl = bOverTbCtrl;
                    return 0L;
                }
                case WM_LBUTTONDOWN:
                    if ( pWnd != this )
                    {
                        // Dismiss menu if user has clicked outside the window
                        if ( pWnd != &m_tbCtrl )
                        {
                            SendMessage( WM_TB_ENDMODALLOOP );
                        }

                        // Forward this mouse event to the window that was clicked
                        LPARAM nPosition = MAKELPARAM( ptScreen.x, ptScreen.y );
                        WPARAM nHitTest  = pWnd->SendMessage( WM_NCHITTEST, 0, nPosition );
                        if ( nHitTest == HTCLIENT )
                        {
                            nPosition = MAKELPARAM( ptClient.x, ptClient.y );
                            pWnd->PostMessage( WM_LBUTTONDOWN, wParam, nPosition );
                        }
                        else
                        {
                            pWnd->PostMessage( WM_NCLBUTTONDOWN, nHitTest, nPosition );
                        }
                    }
                    return 0L;

                default:
                    break;
            }
        }
    }

    return CWnd::WindowProc( message, wParam, lParam );
}