Jump to content
Software FX Community

how to get paint marker event when printing?


User (Legacy)

Recommended Posts

Greetings.

I am having trouble getting the PaintMarker event when printing the chart. I

am using MFC/VC++, and when using a chart in a dialog box I have been able

to use this feature to draw on my markers. When printing, I am invoking

ChartFX using CreateControl as previously suggested to me in this forum

(thanks again for the continued great support). I have seen the articles

referring to ICfxEvents, but can't find these implementations in my

installation. And the help seems limited with reference to the

SetEventHandler method (which seems like it would be useful in what I'm

attempting). Any suggestions?

Regards,

Michael

Link to comment
Share on other sites

SetEventHandler is to be used when using the DLL only. When using the

ActiveX, the events must be captured as usual using the

IConnectionPointContainer interface (standard ActiveX event interface).

Using CreateControl will also do the trick, all MFC Windows are ActiveX

containers, so whoever you are specifying as the parent of the chart control

will be receiving the events, all you need to do is use the macros

BEGIN_EVENTSINK_MAP, ON_EVENT and END_EVENTSINK_MAP to capture them. Same

as you do in the dialog.

If you are using the DLL, all you need to do is create a class that derives

from ICfxEvents and pass an instance of that object to SetEventHandler, in

this class you can write all the code to handle the events.

--

FP

Software FX

Link to comment
Share on other sites

Actually, if I had written my problem correctly it would have helped. Sorry.

I'm not using CreateControl. I'm using CoGetClassObject and

CreateInstanceLic in my CView derived class to instantiate the chart object.

Then I manipulate the chart in my printing functions. I tried to set up the

eventsink map like in my dialog view of the chart, but I can't figure out

what ID to use in the second ON_EVENT parameter.

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message

news:h1LyW8hLEHA.600@webserver3.softwarefx.com...

> SetEventHandler is to be used when using the DLL only. When using the

> ActiveX, the events must be captured as usual using the

> IConnectionPointContainer interface (standard ActiveX event interface).

> Using CreateControl will also do the trick, all MFC Windows are ActiveX

> containers, so whoever you are specifying as the parent of the chart

control

> will be receiving the events, all you need to do is use the macros

> BEGIN_EVENTSINK_MAP, ON_EVENT and END_EVENTSINK_MAP to capture them. Same

> as you do in the dialog.

>

> If you are using the DLL, all you need to do is create a class that

derives

> from ICfxEvents and pass an instance of that object to SetEventHandler, in

> this class you can write all the code to handle the events.

>

> --

> FP

> Software FX

>

>

Link to comment
Share on other sites

I don't know the context in whcih it was suggested to you to use not use

CreateControl. Can you please alaborate ?

If you don't use CreateControl, your ActiveX is not going to have a

container until you activate it, activating an ActiveX control requires a

control container that is very tedious to program, you need to implement a

vunch of COM functionality.

In order to receive events, an ActiveX exposes an interface called

IConnectionPointContainer that allows a listener to listen to events. To

attach as a listener is also a very tedious process and if you are

interested you can find out about it in MSDN (if you need to go this way,

search for IConnectionPointContainer and you will get a lot of info).

MFC Already has all the plumbing. Any MFC window is an ActiveX container and

the macros that I mentioned before make it easier to listen to events but

this requires that the ActiveX is contained inside an MFC Window which you

do using CreateControl as follows:

So it is WAY better for you to use MFC's plumbing instead of building your

own.

If I needed to create a chart dinamically in MFC and capture events from it

this is what I would do:

// Declaring the container

class CChartFXContainer : public CWnd

{

DECLARE_EVENTSINK_MAP()

afx_msg void OnLButtonDblClkChart1(short x, short y, short nSerie, long

nPoint, short FAR* nRes);

};

BEGIN_EVENTSINK_MAP(CChartFXContainer, CWnd)

//{{AFX_EVENTSINK_MAP(CCfxScroll)

ON_EVENT(CChartFXContainer, 1001/*any ID*/, 1 /* LButtonDblClk */,

OnLButtonDblClkChart1, VTS_I2 VTS_I2 VTS_I2 VTS_I4 VTS_PI2)

//}}AFX_EVENTSINK_MAP

END_EVENTSINK_MAP()

void CChartFXContainer::OnLButtonDblClkChart1(short x, short y, short

nSerie, long nPoint, short FAR* nRes)

{

MessageBox("DoubleClick");

}

// Using the container

CChartFXContainer m_ChartFX;

m_ChartFX.CreateControl(__uuidof(ChartFX), NULL, WS_VISIBLE, rc, this,

IDC_CHART1,NULL,NULL,NULL /* LICENSE STRING SHOULD GO HERE */ );

--

FP

Software FX

Link to comment
Share on other sites

Thanks for the reply.

I added the funtionality in printing charts based on code you sent in

"mfcdocview.zip" (see my previous post dated 3/14) in which no call was made

to CreateControl. I have attached a picture of what I'm trying to do. I was

able, using the PaintMarker event, to draw the numbers on the markers when

displaying a chart in my dialog box. The problem I am having is being able

to do the same when printing. The "point labels" for markers in 2

dimensional charts seems to display only the vertical axis values, which

have little meaning in this regard with a 2 dimensional plot. What I am

trying to do is match up the marker with the ordered item voted on.

Easy solutions are always appreciated. I am not trying to make more work for

myself, but this ability is necessary in my program. My abilities in VC++

and MFC are high, but have only hacked through COM implementations so I'd

hate to make this overly complicated.

Thanks again,

Michael.

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message

news:GEWZWseMEHA.3092@webserver3.softwarefx.com...

> I don't know the context in whcih it was suggested to you to use not use

> CreateControl. Can you please alaborate ?

>

> If you don't use CreateControl, your ActiveX is not going to have a

> container until you activate it, activating an ActiveX control requires a

> control container that is very tedious to program, you need to implement a

> vunch of COM functionality.

>

> In order to receive events, an ActiveX exposes an interface called

> IConnectionPointContainer that allows a listener to listen to events. To

> attach as a listener is also a very tedious process and if you are

> interested you can find out about it in MSDN (if you need to go this way,

> search for IConnectionPointContainer and you will get a lot of info).

>

> MFC Already has all the plumbing. Any MFC window is an ActiveX container

and

> the macros that I mentioned before make it easier to listen to events but

> this requires that the ActiveX is contained inside an MFC Window which you

> do using CreateControl as follows:

>

> So it is WAY better for you to use MFC's plumbing instead of building your

> own.

>

> If I needed to create a chart dinamically in MFC and capture events from

it

> this is what I would do:

>

> // Declaring the container

> class CChartFXContainer : public CWnd

> {

> DECLARE_EVENTSINK_MAP()

>

> afx_msg void OnLButtonDblClkChart1(short x, short y, short nSerie, long

> nPoint, short FAR* nRes);

> };

>

> BEGIN_EVENTSINK_MAP(CChartFXContainer, CWnd)

> //{{AFX_EVENTSINK_MAP(CCfxScroll)

> ON_EVENT(CChartFXContainer, 1001/*any ID*/, 1 /* LButtonDblClk */,

> OnLButtonDblClkChart1, VTS_I2 VTS_I2 VTS_I2 VTS_I4 VTS_PI2)

> //}}AFX_EVENTSINK_MAP

> END_EVENTSINK_MAP()

>

> void CChartFXContainer::OnLButtonDblClkChart1(short x, short y, short

> nSerie, long nPoint, short FAR* nRes)

> {

> MessageBox("DoubleClick");

>

> }

>

> // Using the container

>

> CChartFXContainer m_ChartFX;

>

> m_ChartFX.CreateControl(__uuidof(ChartFX), NULL, WS_VISIBLE, rc, this,

> IDC_CHART1,NULL,NULL,NULL /* LICENSE STRING SHOULD GO HERE */ );

>

> --

> FP

> Software FX

>

>

Link to comment
Share on other sites

Greetings, SoftwareFX.

Please review my previous post (also below). I can't seem to get the

suggestion working that you sent with CreateControl as the initiator - in

that code frag, to what does IDC_CHART1 refer? There is no dialog active in

the printing process - is this just a random id? I would appreciate any

assistance, or ask for clarification.

Regards,

Michael.

"Michael Catello" <mail@catello.com> wrote in message

news:nD1YNhhMEHA.600@webserver3.softwarefx.com...

> Thanks for the reply.

>

> I added the funtionality in printing charts based on code you sent in

> "mfcdocview.zip" (see my previous post dated 3/14) in which no call was

made

> to CreateControl. I have attached a picture of what I'm trying to do. I

was

> able, using the PaintMarker event, to draw the numbers on the markers when

> displaying a chart in my dialog box. The problem I am having is being able

> to do the same when printing. The "point labels" for markers in 2

> dimensional charts seems to display only the vertical axis values, which

> have little meaning in this regard with a 2 dimensional plot. What I am

> trying to do is match up the marker with the ordered item voted on.

>

> Easy solutions are always appreciated. I am not trying to make more work

for

> myself, but this ability is necessary in my program. My abilities in VC++

> and MFC are high, but have only hacked through COM implementations so I'd

> hate to make this overly complicated.

>

> Thanks again,

> Michael.

>

> "SoftwareFX Support" <noreply@softwarefx.com> wrote in message

> news:GEWZWseMEHA.3092@webserver3.softwarefx.com...

> > I don't know the context in whcih it was suggested to you to use not use

> > CreateControl. Can you please alaborate ?

> >

> > If you don't use CreateControl, your ActiveX is not going to have a

> > container until you activate it, activating an ActiveX control requires

a

> > control container that is very tedious to program, you need to implement

a

> > vunch of COM functionality.

> >

> > In order to receive events, an ActiveX exposes an interface called

> > IConnectionPointContainer that allows a listener to listen to events. To

> > attach as a listener is also a very tedious process and if you are

> > interested you can find out about it in MSDN (if you need to go this

way,

> > search for IConnectionPointContainer and you will get a lot of info).

> >

> > MFC Already has all the plumbing. Any MFC window is an ActiveX container

> and

> > the macros that I mentioned before make it easier to listen to events

but

> > this requires that the ActiveX is contained inside an MFC Window which

you

> > do using CreateControl as follows:

> >

> > So it is WAY better for you to use MFC's plumbing instead of building

your

> > own.

> >

> > If I needed to create a chart dinamically in MFC and capture events from

> it

> > this is what I would do:

> >

> > // Declaring the container

> > class CChartFXContainer : public CWnd

> > {

> > DECLARE_EVENTSINK_MAP()

> >

> > afx_msg void OnLButtonDblClkChart1(short x, short y, short nSerie, long

> > nPoint, short FAR* nRes);

> > };

> >

> > BEGIN_EVENTSINK_MAP(CChartFXContainer, CWnd)

> > //{{AFX_EVENTSINK_MAP(CCfxScroll)

> > ON_EVENT(CChartFXContainer, 1001/*any ID*/, 1 /* LButtonDblClk */,

> > OnLButtonDblClkChart1, VTS_I2 VTS_I2 VTS_I2 VTS_I4 VTS_PI2)

> > //}}AFX_EVENTSINK_MAP

> > END_EVENTSINK_MAP()

> >

> > void CChartFXContainer::OnLButtonDblClkChart1(short x, short y, short

> > nSerie, long nPoint, short FAR* nRes)

> > {

> > MessageBox("DoubleClick");

> >

> > }

> >

> > // Using the container

> >

> > CChartFXContainer m_ChartFX;

> >

> > m_ChartFX.CreateControl(__uuidof(ChartFX), NULL, WS_VISIBLE, rc, this,

> > IDC_CHART1,NULL,NULL,NULL /* LICENSE STRING SHOULD GO HERE */ );

> >

> > --

> > FP

> > Software FX

> >

> >

>

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...