Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VC++ Error C2642

Posted on 1997-05-02
5
Medium Priority
?
258 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
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 300 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

963 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