请问大家有没有遇到使用settimer killtimer过多造成死机的情况???(50分)

  • 主题发起人 主题发起人 sungu
  • 开始时间 开始时间
S

sungu

Unregistered / Unconfirmed
GUEST, unregistred user!
settimer(0,0,1000,@timeproc);<br>这样用对不对,<br>前面两个参数是什么作用??<br>如果我要在回调函数外使用killtimer参数应该用什么呢?
 
UINT SetTimer(<br><br>&nbsp; &nbsp; HWND hWnd, // handle of window for timer messages<br>&nbsp; &nbsp; UINT nIDEvent, // timer identifier<br>&nbsp; &nbsp; UINT uElapse, // time-out value<br>&nbsp; &nbsp; TIMERPROC lpTimerFunc // address of timer procedure<br>&nbsp; &nbsp;);<br><br>第一个:定时器所有的窗口句柄<br>第二个:定时器的标识号<br>settime(handle,1,1000,@timrproc);<br><br>BOOL KillTimer(<br><br>&nbsp; &nbsp; HWND hWnd, // handle of window that installed timer<br>&nbsp; &nbsp; UINT uIDEvent // timer identifier<br>&nbsp; &nbsp;); <br>&nbsp;<br>killtimer(handle,1);
 
下面这段代码是截图用的!每30秒运行一次,一个半小时后程序出现非法操作,不知道是什么原因,望高手指正!<br>procedure TgetBmp.Get(x1, y1, x2, y2: Word;FileName:string);<br>var MyDC:HDC;<br>&nbsp; &nbsp; Mycanvas:TCanvas;<br>&nbsp; &nbsp; rect1,rect2:TRect;<br>begin<br><br><br>&nbsp; &nbsp; MyDC:=createdc('display','','',nil);<br>&nbsp; &nbsp; MyBmp:=TBitmap.Create;<br>&nbsp; &nbsp; mybmp.Height:=35;<br>&nbsp; &nbsp; mybmp.Width:=35;<br>&nbsp; &nbsp; Mycanvas:=TCanvas.Create;<br>&nbsp; &nbsp; myCanvas.Handle:=MyDC;<br>&nbsp; &nbsp; rect1.TopLeft.X:=x1;<br>&nbsp; &nbsp; rect1.TopLeft.Y:=y1;<br>&nbsp; &nbsp; rect1.BottomRight.X:=x2;<br>&nbsp; &nbsp; rect1.BottomRight.Y:=y2;<br>&nbsp; &nbsp; rect2.TopLeft.X:=0;<br>&nbsp; &nbsp; rect2.TopLeft.Y:=0;<br>&nbsp; &nbsp; rect2.BottomRight.X:=35;<br>&nbsp; &nbsp; rect2.BottomRight.Y:=35;<br><br>&nbsp; &nbsp; mybmp.Canvas.CopyRect(rect2,Mycanvas,rect1);<br>&nbsp; &nbsp; MyBmp.SaveToFile(FileName);<br>&nbsp; &nbsp; ReleaseDC(MyBmp.Handle,MyDC);<br>end;<br>
 
后退
顶部