// ----------------------------------------------------------------------------
//		* HandleControlEvent
// ----------------------------------------------------------------------------
OSStatus
GuidoCarbonControl::HandleControlEvent( EventRef inEvent )
{
    OSStatus result = noErr;	// handled by default.
  	
    switch( ::GetEventKind( inEvent ))
    {
        case kEventControlDraw:		DoDraw();	 break;  
  		case kEventControlHitTest: 	HitTest( inEvent );	break;	
  		case kEventControlTrack:	TrackMouse( inEvent );	break;
  
  
	/*	case kEventControlClick:
        {
         	int x = 0;
         	int y = 0;
         	cout << "Guido control clicked ( " << x << ", " << y << " )" << endl;
         	break;
         }*/
         
         default:
          	result = eventNotHandledErr;
          	break;
    }
    
    return result;
}
Beispiel #2
0
void TaskSortFieldSelector::OnMouseMove(WPARAM /*wParam*/, LPARAM lParam)
{
	if(!m_bTrackMouse)TrackMouse();
	POINT p = LPARAM_TO_POINT(lParam);

	if(hilite >= 0 && hilite < COMPARE_COUNT && PtInRect(itemRects + hilite, p))return;
	for(int i = 0; i < COMPARE_COUNT; i++)
	{
		if(PtInRect(itemRects + i, p))
		{
			hilite = i;
			Invalidate();//Rect(m_hwnd, NULL, TRUE);
			return;
		}
	}
	if(hilite != -1)Invalidate();//Rect(m_hwnd, NULL, TRUE);
	hilite = -1;
}
Beispiel #3
0
LRESULT CALLBACK GdiTableVis::WinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	HDC         hDC;
    PAINTSTRUCT Ps;
	HBRUSH      tmpBrush;
	RECT rect = { 0 };

	switch(Msg)
	{
	case WM_CREATE:
		break;

	case WM_ERASEBKGND:
		{
			GetClientRect(hWnd, &rect);
			hDC = (HDC)wParam;
			tmpBrush = CreateSolidBrush(COLORREF(RGB(0,0,0)));
			FillRect(hDC, &rect, tmpBrush);
			DeleteObject(tmpBrush);
		}
		break;

	case WM_PAINT:
		{
			GetClientRect(hWnd, &rect);

			hDC = BeginPaint(hWnd, &Ps);
			if(gdiObjectsX64.size() > 0) 
			{
				for (std::vector<GDICELL_64>::iterator iter = gdiObjectsX64.begin(); iter != gdiObjectsX64.end(); ++iter)
				{
						DWORD index = (DWORD)(iter - gdiObjectsX64.begin());
						tmpBrush = CreateSolidBrush(GetCellColor(LOBYTE(iter->wType)));
						// get a RECT from table index
						RectFromIndex(hWnd, index, (DWORD)gdiObjectsX64.size(), &rect, 1);		
						FillRect(hDC, &rect, tmpBrush);
						DeleteObject(tmpBrush);
				}
			}
			EndPaint(hWnd, &Ps);
		}
		break;

	case WM_DESTROY:
		PostQuitMessage(int(lParam));
		break;

	case WM_MOUSEHOVER:
		break;

	case WM_MOUSELEAVE: // The mouse pointer has left our window. Deactivate the tooltip.
		SendMessage(hWndToolTip, TTM_TRACKACTIVATE, (WPARAM)FALSE, (LPARAM)&_toolInfo);
		bTrackingMouse = FALSE;
		ShowWindow(hWndToolTip, SW_HIDE);
		break;

	case WM_MOUSEMOVE:
		{
			static int oldX, oldY;
			int newX, newY;

			if (!bTrackingMouse)   {
				TrackMouse();
				// Activate the tooltip.
				SendMessage(hWndToolTip, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&_toolInfo);
			}
    
			newX = GET_X_LPARAM(lParam);
			newY = GET_Y_LPARAM(lParam);

			// greedy update for tooltip
			if ((newX != oldX) || (newY != oldY))
			{
				DWORD index = CoordToIndex(hWnd, newX, newY, (DWORD)gdiObjectsX64.size());

				if((index > gdiObjectsX64.size()-1) || (gdiObjectsX64.size() == 0)) {
					ShowWindow(hWndToolTip, SW_HIDE);
					break;
				} else {
					ShowWindow(hWndToolTip, SW_SHOW);

					oldX = newX;
					oldY = newY;
            
					WCHAR coords[0x100];
					swprintf_s(coords, ARRAYSIZE(coords), L"%016I64X", gdiObjectsX64.at(index).pKernelAddress);

					_toolInfo.lpszText = coords;
					RECT _rect;
					GetGridRect(hWnd, (DWORD)gdiObjectsX64.size(), &_rect);
					_toolInfo.rect = _rect;
					SendMessage(hWndToolTip, TTM_SETTOOLINFO, 0, (LPARAM)&_toolInfo);

					POINT pt = { newX, newY }; 
					ClientToScreen(hWnd, &pt);
					SendMessage(hWndToolTip, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(pt.x + 10, pt.y - 20));
				}
			}
		}
		break;

	case WM_LBUTTONDOWN:
		{
			POINT point;
			GetCursorPos(&point);
			ScreenToClient(hWnd, &point);
			DWORD index = 0;
			if(gdiObjectsX64.size() > 0) {
				index = CoordToIndex(hWnd, point.x, point.y, (DWORD)gdiObjectsX64.size());

				if(index > (DWORD)gdiObjectsX64.size()-1) 
					break;

				DumpBase(index);
			}

		}
		break;

	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}