Click here to Skip to main content
15,887,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Still need help with FTPConnection Pin
includeh1015-Aug-06 6:49
includeh1015-Aug-06 6:49 
GeneralRe: Still need help with FTPConnection Pin
racing5715-Aug-06 10:50
racing5715-Aug-06 10:50 
GeneralRe: Still need help with FTPConnection Pin
thangnvhl15-Aug-06 21:53
thangnvhl15-Aug-06 21:53 
GeneralRe: Still need help with FTPConnection Pin
racing5715-Aug-06 23:00
racing5715-Aug-06 23:00 
GeneralRe: Still need help with FTPConnection Pin
Justin Tay16-Aug-06 2:23
Justin Tay16-Aug-06 2:23 
GeneralRe: Still need help with FTPConnection Pin
racing5716-Aug-06 3:46
racing5716-Aug-06 3:46 
GeneralRe: Still need help with FTPConnection Pin
Justin Tay16-Aug-06 22:01
Justin Tay16-Aug-06 22:01 
Questiontimers without windows Pin
m.dietz15-Aug-06 4:09
m.dietz15-Aug-06 4:09 
Hi,

In a current project I need a class that monitors some maintenance data and regularly writes them to a log file. As this class is used in different modules in different ways, the functions should be encapsulated as best as possible and the usual way of using this class should be by giving a filename to the constructor to configure the instance and then calling Collect() to immediately collect and log the data or calling EnableTimer(time_span) to regularly log the data to the log file every time_span milliseconds.

The problem I can't solve is the timer. My first approach was

<br />
<br />
BOOL CMaintMonitor::EnableTimer(UINT interval)<br />
{<br />
    if(bl_TimerEnabled) StopTimer();<br />
    bl_TimerEnabled = TRUE;<br />
    ui_TimerInterval = interval;<br />
    TimerID = SetTimer(NULL, 0, interval, TimerFunction);<br />
    if(!TimerID)<br />
    {<br />
        bl_TimerEnabled = FALSE;<br />
        ui_TimerInterval = 0;<br />
        return FALSE;<br />
    }<br />
    return TRUE;<br />
}<br />
<br />
...<br />
<br />
BOOL CMaintMonitor::StopTimer()<br />
{<br />
    if(bl_TimerEnabled)<br />
    {<br />
        bl_TimerEnabled = FALSE;<br />
        ui_TimerInterval = 0;<br />
        KillTimer(TimerID);<br />
    }<br />
    return TRUE;<br />
}<br />


TimerFunction was thought as a private method of CMaintMonitor that calls Collect(). Visual C++ didn't like this approach, telling me that it couldn't convert parameter 4 of SetTimer from void(...) to void(__stdcall *)(...). Reading the help pages again I saw that this function is meant to send a WM_TIMER message to a window whose message processing function should call the provided function instead of standard functions, so it still needs a WM_TIMER message processing even if the window handle provided is NULL Confused | :confused: .

The problem now is that I can't call a global function (I think this is what the compiler wants to say with the (__stdcall *) part of the error message) as Collect is a member function of an instance of CMaintMonitor using instance member data to do its work. So even if I found a way to use a global function for that timer event, I still need a way to give a pointer to my CMaintMonitor instance to that function for the call to Collect(), but I don't see a way to do so.

Can anyone help me solving the problem with that timer? This class should come without a user-Interface, so there is no window I can abuse to handle the timer event, and I can't even use the window of a caller as there are a lot of modules which come without UI either but still need to to use my monitor class. I'm new to programming under Windows, so I don't know if there might be an easy workaround for this problem I just don't know.

Thanks in advance
Martin Dietz
AnswerRe: timers without windows Pin
led mike15-Aug-06 4:26
led mike15-Aug-06 4:26 
GeneralRe: timers without windows Pin
m.dietz15-Aug-06 5:07
m.dietz15-Aug-06 5:07 
GeneralRe: timers without windows [modified] Pin
led mike15-Aug-06 5:53
led mike15-Aug-06 5:53 
GeneralRe: timers without windows Pin
m.dietz15-Aug-06 20:24
m.dietz15-Aug-06 20:24 
GeneralRe: timers without windows Pin
led mike16-Aug-06 5:05
led mike16-Aug-06 5:05 
AnswerRe: timers without windows Pin
cje15-Aug-06 4:26
cje15-Aug-06 4:26 
QuestionSingleton problem !!! Pin
Bratu Aurelian15-Aug-06 4:05
Bratu Aurelian15-Aug-06 4:05 
QuestionGetting IP of a Network group PC Pin
Kharfax15-Aug-06 4:03
Kharfax15-Aug-06 4:03 
AnswerRe: Getting IP of a Network group PC Pin
David Crow15-Aug-06 4:09
David Crow15-Aug-06 4:09 
GeneralRe: Getting IP of a Network group PC Pin
Kharfax15-Aug-06 4:11
Kharfax15-Aug-06 4:11 
AnswerRe: Getting IP of a Network group PC Pin
A_Fa15-Aug-06 19:45
A_Fa15-Aug-06 19:45 
GeneralRe: Getting IP of a Network group PC Pin
Kharfax16-Aug-06 2:26
Kharfax16-Aug-06 2:26 
QuestionHow to auto size a column in a CListCtrl Pin
paperke6715-Aug-06 3:07
paperke6715-Aug-06 3:07 
AnswerRe: How to auto size a column in a CListCtrl Pin
RChin15-Aug-06 4:17
RChin15-Aug-06 4:17 
AnswerRe: How to auto size a column in a CListCtrl Pin
JWood15-Aug-06 4:19
JWood15-Aug-06 4:19 
AnswerRe: How to auto size a column in a CListCtrl Pin
Hamid_RT16-Aug-06 4:55
Hamid_RT16-Aug-06 4:55 
AnswerRe: How to auto size a column in a CListCtrl Pin
paperke6718-Aug-06 11:52
paperke6718-Aug-06 11:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.