Ejemplo n.º 1
0
/*

* Method preamble ************************************************************
*
* CLASS:            TFXDataTip
* NAME:             Display
*
* DESCRIPTION:      This method displays the DataTip window. If there is a
*                   currently active DataTip this is hidden before the tip
*                   size is calculated and the tip positioned at the 
*                   specified offset from the mouse pointer location.
*
* PARAMETERS:       none
*
* RETURN TYPE:      void
*
******************************************************************************
*                                  REVISION HISTORY                                                               
*
******************************************************************************
*/
void TFXDataTip::Display( )
{
	PROC_TRACE;

    if (!m_ready) return;

    // hide any other currently visible data tips
    if (_current != NULL)
    {
        _current->Hide( );
    }

    // determine the size of the data tip text 
    // in order to size the window correctly
    CClientDC dc(this);
    dc.SelectObject(&_font);
    CSize size = dc.GetTextExtent(m_tip);

    // capture the mouse in order to be able to 
    // determine when to hide the window
//    SetCapture( );

    // determine the window size and position
    // displayed above and centered on the origin
    CRect wndRect(m_origin.x, 
                  m_origin.y, 
                  m_origin.x + size.cx, 
                  m_origin.y + size.cy); 

    // adjust window for offset and borders
    wndRect.InflateRect(2 * _border, _border);
    wndRect.OffsetRect(m_offset);

    // update window position and display
    SetWindowPos(&wndTop, 
                 wndRect.left,
                 wndRect.top,
                 wndRect.Width( ), 
                 wndRect.Height( ), 
                 SWP_SHOWWINDOW | SWP_NOACTIVATE);

    // define the active area around the cursor position
    m_captureRect = CRect(m_origin.x - _horizontal, 
                          m_origin.y - _vertical,
                          m_origin.x + _horizontal,
                          m_origin.y + _vertical);

    // set the current data tip window
    _current = this;
}
Ejemplo n.º 2
0
void Executor::clickTo(WId hwnd, int x, int y)
{
   RECT rect;
   GetWindowRect(hwnd, &rect);

   static int x_border = 0;
   static int y_border = 0;
   if (x_border == 0)
   {
      QRect wndRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
      RECT clrect;
      GetClientRect(hwnd, &clrect);
      QRect clntRect(clrect.left, clrect.top, clrect.right - clrect.left, clrect.bottom - clrect.top);
      x_border = (int)(wndRect.width() - clntRect.width()) / 2.;
      y_border = wndRect.height() - clntRect.height() - x_border;
   }

   x += rect.left + x_border;
   y += rect.top + y_border;
   HwndToTop(hwnd);

   long X = (long)(x * ABSOLUTE_COORD)/screen_res_x_;
   long Y = (long)(y * ABSOLUTE_COORD)/screen_res_y_;
   
   Hooker hook(Hooker::Mouse);
   //запомнить текущие координаты мышки
   POINT pt;
   GetCursorPos(&pt);
   long cX = (long)(pt.x * ABSOLUTE_COORD)/screen_res_x_;
   long cY = (long)(pt.y * ABSOLUTE_COORD)/screen_res_y_;

   mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, X, Y, 0, 0);
   Sleep(100);
   mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN, X, Y, 0, 0);
   Sleep(100);
   mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
   Sleep(100);
   
   //вернуть координаты мышки откуда взяли
   mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, cX, cY, 0, 0);
}
Ejemplo n.º 3
0
/*

* Method preamble ************************************************************
*
* CLASS:            TFXDataTip
* NAME:             Display
*
* DESCRIPTION:      This method displays the DataTip window. If there is a
*                   currently active DataTip this is hidden before the tip
*                   size is calculated and the tip positioned at the 
*                   specified offset from the mouse pointer location.
*
* PARAMETERS:       none
*
* RETURN TYPE:      void
*
******************************************************************************
*                                  REVISION HISTORY                                                               
*
******************************************************************************
*/
void TFXDataTip::Display( )
{
    if (!m_ready) return;

    // hide any other currently visible data tips
    if (_current != NULL)
    {
        _current->Hide( );
    }

    // determine the size of the data tip text 
    // in order to size the window correctly
    CClientDC dc(this);
    dc.SelectObject(&_font);

    CSize size( 0, 0 );
	
	bool flushLine = false;
	bool overFlow = false;
	int tipLength = m_tip.GetLength();

	CString line;
	for(int i=0;i<tipLength;i++)
	{
		char c = (char)m_tip[i];

		if ( c == '\n' )
			flushLine = true;
		else if ( c != '\r' )	// ignore /r character
			line += c;

		if ( i == (tipLength - 1 ) )
			flushLine = true;			// last character
		if ( dc.GetTextExtent( line ).cx > MAX_TIP_WIDTH )
			overFlow = flushLine = true;			// max width

		if ( flushLine )
		{
			if ( line.GetLength() == 0 )
				line += ' ';

			CString wrapped( "" );
			if ( overFlow )
			{
				int lastWhite = line.ReverseFind( ' ' );
				if ( lastWhite > 0 )
				{
					wrapped = line.Mid( lastWhite );
					wrapped.TrimLeft();
					// terminate the line at the last whitespace
					line = line.Mid( 0, lastWhite );
				}
			}

			CSize extents( dc.GetTextExtent( line ) );
			if ( extents.cx > size.cx )
				size.cx = extents.cx;
			size.cy += extents.cy;
	
			flushLine = overFlow = false;
			line = wrapped;
		}
	}

    // capture the mouse in order to be able to 
    // determine when to hide the window
    SetCapture( );

    // determine the window size and position
    // displayed above and centered on the origin
    CRect wndRect(m_origin.x, 
                  m_origin.y, 
                  m_origin.x + size.cx, 
                  m_origin.y + size.cy); 

    // adjust window for offset and borders
    wndRect.InflateRect(2 * _border, _border);
    wndRect.OffsetRect(m_offset);

    // update window position and display
    SetWindowPos(&wndTop, 
                 wndRect.left,
                 wndRect.top,
                 wndRect.Width( ), 
                 wndRect.Height( ), 
                 SWP_SHOWWINDOW | SWP_NOACTIVATE);

    // define the active area around the cursor position
    m_captureRect = CRect(m_origin.x - _horizontal, 
                          m_origin.y - _vertical,
                          m_origin.x + _horizontal,
                          m_origin.y + _vertical);

    // set the current data tip window
    _current = this;
}