Solved

VC++ Error C2642

Posted on 1997-05-02
5
217 Views
Last Modified: 2010-04-10
I'm using MSVC++ V1.52
Trying to set up a simple 1 sec timer.

On the line "ON_WM_TIMER()", which the tool inserted,
I get the following compile error:

"error C2642: cast to pointer to member must be from related pointer to member"

This works OK in another class, but not this one.

Thanks,

MrKerry@aol.com
0
Comment
Question by:mrkerry
5 Comments
 
LVL 4

Expert Comment

by:AVaulin
Comment Utility
Are you sure that your class delivered from CWnd class?
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
Please post the source code that was generated (header and cpp).

Post as a comment to here and/or direct to me at Roger_Onslow@compsys.com.au
0
 
LVL 1

Accepted Solution

by:
TKII earned 100 total points
Comment Utility
I believe you are trying to use a timer in a class not derived from CWnd. Such a class is for instance CDocument. You should use the associated view-class for your timer or the MainFrame CMainFrame. You should use the classwizzard to add the generic handler and message-map-entries for the WM_TIMER-message.
0
 

Author Comment

by:mrkerry
Comment Utility
Thanks...your answer was right on. I don't know how to grade but you get an A.
0
 
LVL 1

Expert Comment

by:TKII
Comment Utility
Thanks, your welcome.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now