Solved

VC++ Error C2642

Posted on 1997-05-02
5
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

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

Expert Comment

by:RONSLOW
ID: 1163222
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
ID: 1163223
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
ID: 1163224
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
ID: 1163225
Thanks, your welcome.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

623 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