Using "SetTimer()" to Call a non-static Function

K

KevinSimonson

I'm in a situation where I need to call a non-static function every
fifteen minutes. I read the article at "http://www.codeproject.com/KB/
cpp/SetTimer__non-static.aspx?display=Print", that told me how to use
"SetTimer()" with callback to a non-static member function, and used
the author's basic idea, though I didn't write a callback wrapper
function. His idea was basically to create a static variable of type
"void *" in the class, and before my code calls "SetTimer()", it sets
that "void *" object to "this". I've got the "void *" object declared
as public in my header file. Then the author said to put a line that
says "void* CHomeSearchCtrl::chsObject;" in my implementation to match
the header file, which I did. Then in my callback function I cast
"chsObject" back to type "CHomeSearchCtrl" and store it in variable
"hsc", and then I call "hsc->Search( true, true);" ("Search()" is the
non-static function that needs to be called every fifteen minutes.

Then I try to compile this code, and I get the message,
"1>c:\program files\microsoft visual studio 10.0\vc\include
\fstream(890): error
C2248:'std::basic_ios<_Elem,_Traits> ::basic_ios' : cannot access
private member declared in class 'std::basic_ios<_Elem,_Traits>'".

Isn't this kind of bizarre? I mean, it's not complaining about my
code, is it? Instead it's complaining about
"vc\include\fstream"! How can changes I make to my local code be
causing compilation errors in "vc\include\fstream", that I have
absolutely no control over?

Anyhow, I'm kind of lost. Is someone could point out to me how I can
get my project compiled I'd really appreciate it. My operating system
is Windows XP and I'm compiling on Visual Studio (version
10.0.30319.1).

Kevin S
 
I

Ian Collins

I'm in a situation where I need to call a non-static function every
fifteen minutes. I read the article at "http://www.codeproject.com/KB/
cpp/SetTimer__non-static.aspx?display=Print", that told me how to use
"SetTimer()" with callback to a non-static member function,

Your really should ask this on a windows programming group.
 
G

Geoff

On Thu, 4 Nov 2010 12:21:35 -0700 (PDT), KevinSimonson

http://www.codeproject.com/KB/cpp/SetTimer__non-static.aspx?display=Print

[snip]
though I didn't write a callback wrapper
function.

[snip]

Did you wonder why the original author had to write a wrapper
function? Perhaps it was related to a class object that had to be
passed to a non-C++ Windows API?

Why do you think you don't need it?

Win32 API is not C++. Windows MFC is a very thin C++ wrapper to the
Win32 API. Do not confuse Windows programming with standard C++.

You might find more activity and more people who can respond directly
to your Windows programming questions here:

http://www.microsoft.com/communities/forums/default.mspx

Microsoft is in the process of abandoning Usenet as a support channel
and regards their web forums as a better medium.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top