Teechart ActiveX v5 StopMouse() ?

TeeChart for ActiveX, COM and ASP
Post Reply
Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am

Teechart ActiveX v5 StopMouse() ?

Post by » Tue Nov 18, 2003 9:46 am

Using Teechart ActiveX V5 with VC++ and ATL.
Im trying to generate a context menu, if the user click with the rigth mouse button on a serie.
Context menu will be shown, but after handling this, the teechart goes in the move state (the graphic always floating to the current position of the mouse pointer, until i click with the mouse agin) and the "3D view" will switched on . How can i deactivate this ???

StopMouse() function has no effect.

my code on the event :

Code: Select all

HRESULT __stdcall CPlotterView::OnClickSeries (long SeriesIndex,long ValueIndex,enum TeeChart::EMouseButton Button,enum TeeChart::EShiftState Shift,long X,long Y )
{
	HRESULT hr = S_OK;
	if((Button == mbRight) && (Shift==ssNone))
	{
		// Context Menu oeffnen 
		HMENU hmenu = ::LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_SERIES_CONTEXT));
		ATLASSERT(hmenu != NULL);

		// Get the position of the mouse pointer.
		POINT ptMenu;
		ptMenu.x = X;
		ptMenu.y = Y;

		/*
		UINT nDummy = 0;
		HTREEITEM hItem = HitTest(ptMenu, &nDummy);

		if(hItem == NULL) return hr;
		*/


		HMENU hPopup = NULL;
		hPopup = ::GetSubMenu(hmenu, 0);
		if(hPopup != NULL)
		{
			m_lastSelectedSeries = SeriesIndex;
			ClientToScreen(&ptMenu);
			::TrackPopupMenu(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON,
				(ptMenu.x), (ptMenu.y), 0, m_hWnd, NULL);
			
		}


	/*
		// signalId von der Serie Holen .... 
		long lngId = 14869;
		::PostMessage(m_pDoc->GetFrameWndHandle(),WM_SIGINFO_OPEN,lngId,lngId);
	*/
	}
	// test Scrolling deactivieren 
	hr = m_spTChart->StopMouse();
	return hr;
}
Ciao ....

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Nov 18, 2003 10:21 am

Hi,

have you tried to do this :

HRESULT __stdcall CPlotterView::OnClickSeries (long SeriesIndex,long ValueIndex,enum TeeChart::EMouseButton Button,enum TeeChart::EShiftState Shift,long X,long Y )
{
m_chart.StopMouse();
if((Button == mbRight) && (Shift==ssNone))
{
// Context Menu oeffnen
HMENU hmenu = ::LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_SERIES_CONTEXT));
ATLASSERT(hmenu != NULL);

Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am

Post by » Wed Nov 19, 2003 4:18 pm

yes, even if you put the StopMouse call on the beginning on the function, it has no effect. (I think you meant this)
the chart goes into the move and 3d mode, after the popup menu called, and closed.
MouseDown is called before OnSeriesClick
MouseUp after. there is no effect if you put StopMouse in these events too ...


btw I'm not working with MFC, so i dont have a member like m_chart.
I only have a smartpointer of the tchart interfaces, and i have to route all event functions manually ....

so only m_spTChart->StopMouse(); works ...

Ciao ...

hansw
Newbie
Newbie
Posts: 59
Joined: Fri Nov 15, 2002 12:00 am

Right mouse click popup menu solution

Post by hansw » Thu Nov 20, 2003 9:41 pm

Here is how I do a popup menu.
It works for me... hope it helps...:-)

Corrected version !

///////////////////////////////////////////////////////////////////////////////
//
void C_TeeChartView::OnMouseDownTChart(long Button, long Shift, long X, long Y)
{
if (Button == LeftButton)
{
// other left button stuf here
}


if (Button == RightButton)
{
m_Chart1.StopMouse();
CPoint point;
point.x=X;
point.y=Y;

// get popup somewhere near the mouse cursor
// TeeChart may have a better solution
CDC* pDC = m_Chart1.GetDC();
pDC->DPtoLP(&point);
DoPopUp(&point);
return;
}

}
///////////////////////////////////////////////////////////////
// does the Popup menu
void C_TeeChartView::DoPopUp(CPoint point)
{
if (point.x == -1 && point.y == -1){
//keystroke invocation
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);

point = rect.TopLeft();
point.Offset(5, 5);
}

CMenu menu;
VERIFY(menu.LoadMenu(CG_IDR_POPUP_C_TEE_CHART_VIEW));

CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;

while (pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner);
}
//////////////////////////////////////////
// Handler for menu item
// Added using Class Wizard
void C_TeeChartView::OnPopUpItem1()
{
// handle the selected menu item here
}

Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am

Post by » Fri Nov 21, 2003 12:48 pm

I have no problems to open the popup menues.
I only can't avoid the right mouse click to the teechart control. (wich results to a format change of the chart, what i dont want)

with using the OnMouseDown event, instead of OnSeriesClick event i can avoid this ?
I need the also need the index of the clicked serie, thats why i'm try to use OnSeriesClick !

How can i get the serie, if the user clicks near one (without using OnSeriesClick ) ?

Ciao ....

hansw
Newbie
Newbie
Posts: 59
Joined: Fri Nov 15, 2002 12:00 am

Post by hansw » Fri Nov 21, 2003 3:21 pm

6920119 wrote:I have no problems to open the popup menues.
I only can't avoid the right mouse click to the teechart control. (wich results to a format change of the chart, what i dont want)

with using the OnMouseDown event, instead of OnSeriesClick event i can avoid this ?
I need the also need the index of the clicked serie, thats why i'm try to use OnSeriesClick !

How can i get the serie, if the user clicks near one (without using OnSeriesClick ) ?

Ciao ....
The example AVOIDS the mouse doing anything with the chart... I included the popup menu code to demonstrate the whole concept.

Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am

Post by » Mon Dec 01, 2003 11:20 am

Ahh ok, thank you. But:
Im using teechart ActiveX 5.0.5.0 under WinXP and VC++ 6.0 SP5 without MFC (ATL project) (no mfc generated classes for the techart control, im using simple smartpointer)
Handling the events above don't avoid the mouse event on the chart :-(
even if I use OnMouseDown or OnSeriesClick .... and put StopMouse() in the events, I can't avoid the click event. :-(
Maybe its depending on ther version ?

Ciao ...

Post Reply