Kill a timer on form show

Started by Rick McNeely, April 18, 2011, 11:59:38 AM

Previous topic - Next topic

Rick McNeely

I have a form with a timer on it.  I don't want the timer to run when the form loads.  I set the timers interval to 1000 mS at design time and tried to kill it before it times out using:


Function FRMREMOTECONFIG_CUSTOM ( _
                                hWndForm      As Dword, _  ' handle of Form
                                wMsg          As Long,  _  ' type of message
                                wParam        As Dword, _  ' first message parameter
                                lParam        As Long   _  ' second message parameter
                                ) As Long
   
    Select Case wMsg
           
        Case %WM_SHOWWINDOW
            KillTimer HWND_FRMREMOTECONFIG, IDC_FRMREMOTECONFIG_TBHOLDTIME
    End Select

End Function


I also tried to kill the timer(s) during WM_CREATE, but it still runs.  What am I missing here?

Thanks

Paul Squires

I think that the easiest approach in this case would be to create a global variable, say, gAllowTimer, and then in the WM_TIMER event handler have a line like:


If gAllowTimer = %FALSE Then Exit Function


Whenever you want to start/stop the timer then all you have to do is set the global variable to TRUE/FALSE.
Paul Squires
PlanetSquires Software