Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Using "SetTimer()" to Call a non-static Function

Reply
Thread Tools

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

 
 
KevinSimonson
Guest
Posts: n/a
 
      11-04-2010
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
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      11-04-2010
On 11/ 5/10 08:21 AM, KevinSimonson wrote:
> 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.

--
Ian Collins
 
Reply With Quote
 
 
 
 
Geoff
Guest
Posts: n/a
 
      11-05-2010
On Thu, 4 Nov 2010 12:21:35 -0700 (PDT), KevinSimonson
<(E-Mail Removed)> wrote:

http://www.codeproject.com/KB/cpp/Se...?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...s/default.mspx

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 4 01-30-2008 05:12 PM
How to call function whose function call with arguments is in astring grbgooglefan C++ 2 01-30-2008 07:18 AM
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 0 01-30-2008 04:19 AM
defined? for recursive function call v/s defined? for function call stack Alok Ruby 3 04-13-2006 11:53 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments