Problem With Event Handlers 
Author Message
 Problem With Event Handlers

I'm a bit new to C++ and am having trouble hooking up an event.

This is what I have (just for testing)

void PageObject::PrintPage(Object *sender,
System::Drawing::Printing::PrintPageEventArgs *e)
{

Quote:
}

void PageObject::ProcessPage(void)
{
        PrintDocument *pd;
        pd->OnPrintPage += new
System::Drawing::Printing::PrintPageEventHandler(this,
&PageObject::PrintPage);

Quote:
}

When I try to compile this is the error that I get:
(291): error C2475: 'System::Drawing::Printing::PrintDocument::OnPrintPage'
: forming a pointer-to-member requires explicit use of the address-of
operator ('&') and a qualified name

What am I doing wrong here?

Thanks in advance!!



Sun, 20 Nov 2005 22:32:59 GMT  
 Problem With Event Handlers

--------------------

| Newsgroups: microsoft.public.dotnet.languages.vc
| Subject: Problem With Event Handlers
| Date: 4 Jun 2003 07:32:59 -0700
| Organization: http://groups.google.com/
| Lines: 25

| NNTP-Posting-Host: 216.130.130.98
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1054737180 17201 127.0.0.1 (4 Jun 2003
14:33:00 GMT)

| NNTP-Posting-Date: 4 Jun 2003 14:33:00 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!skynet.be!skynet.be!news.tele.dk!news.tele.dk!small.news.tele.dk!sn-xit
-02!sn-xit-06!sn-xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:24595
| X-Tomcat-NG: microsoft.public.dotnet.languages.vc
|
| I'm a bit new to C++ and am having trouble hooking up an event.
|
| This is what I have (just for testing)
|
| void PageObject::PrintPage(Object *sender,
| System::Drawing::Printing::PrintPageEventArgs *e)
| {
| }
|
| void PageObject::ProcessPage(void)
| {
|       PrintDocument *pd;
|       pd->OnPrintPage += new
| System::Drawing::Printing::PrintPageEventHandler(this,
| &PageObject::PrintPage);
| }
|
| When I try to compile this is the error that I get:
| (291): error C2475:
'System::Drawing::Printing::PrintDocument::OnPrintPage'
| : forming a pointer-to-member requires explicit use of the address-of
| operator ('&') and a qualified name
|
| What am I doing wrong here?
|
| Thanks in advance!!
|
The event that you are using is called PrintPage and not OnPrintPage. You
need to change one line like this:

        pd->PrintPage += new
System::Drawing::Printing::PrintPageEventHandler(this,
&PageObject::PrintPage);

Hope it helps,

--
Silviu Guea, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Tue, 22 Nov 2005 01:44:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CDialogBar event handler problem

2. Q: Removing subscribed event handlers from an event

3. REPOST : VS generated event handlers cause problems?

4. VS generated event handlers cause problems?

5. Event without event handler?

6. NullReferenceException thrown when raising an event where there are no event handlers attached

7. how to break out of an event handler

8. EnableViewState kills event handler

9. What control called event handler

10. Event Handler

11. SQLMERGXLib status event handler not firing

12. multiple event handlers exception help

 

 
Powered by phpBB® Forum Software