Page 1 of 1

Teechart ActiveX v5 StopMouse() ?

Posted: Tue Nov 18, 2003 9:46 am
by 6920119
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 ....

Posted: Tue Nov 18, 2003 10:21 am
by Pep
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);

Posted: Wed Nov 19, 2003 4:18 pm
by 6920119
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 ...

Right mouse click popup menu solution

Posted: Thu Nov 20, 2003 9:41 pm
by 9078641
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
}

Posted: Fri Nov 21, 2003 12:48 pm
by 6920119
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 ....

Posted: Fri Nov 21, 2003 3:21 pm
by 9078641
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.

Posted: Mon Dec 01, 2003 11:20 am
by 6920119
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 ...