VB 和timer控制項功能相同的函式

2021-04-26 07:41:37 字數 995 閱讀 8951

利用api函式實現定時器功能

模組中:

option explicit

public ltimerid as long

private declare function settimer lib "user32" (byval hwnd as long, byval nidevent as long, byval uelapse as long, byval lptimerfunc as long) as long

private declare function killtimer lib "user32" (byval hwnd as long, byval nidevent as long) as long

private sub timerproc(byval lhwnd as long, byval lmsg as long, byval ltimerid as long, byval ltime as long)

static i as long

form1.label1.caption = i

i = i + 1

end sub

public sub starttimer(lminute as long)

ltimerid = settimer(0, 0, lminute, addressof timerproc)

end sub

public function stoptimer(ltimerid as long) as long

stoptimer = killtimer(0, ltimerid)

end function

窗體中:

private sub form_load()

starttimer 1000

end sub

private sub form_unload(cancel as integer)

stoptimer ltimerid

end sub

可替代VB自帶的Timer控制項的Timer類

宣告 魏滔序原創,轉貼請註明出處。用這個類可以替代vb自帶的timer控制項,這樣就不用在無窗體的專案中僅為了使用timer而多加乙個窗體了。我一般用在activex exe中用來分離系統控制權,用timer的好處是避免控制權死鎖,這樣也就模擬出了多執行緒 實際上是多程序 能給使用者更好的體驗。如下...

QT相同控制項相似功能

避免同一控制項相似事件的重複 一 定義 define max robot cachepoint number 16 有16個按鈕 qpushbutton pbuttoncache max robot cachepoint number 二 獲取指標 我們通過拖控制項或者 方式生成按鈕。然後利用如下 ...

用這個類可以替代VB自帶的Timer控制項

用這個類可以替代vb自帶的timer控制項,這樣就不用在無窗體的專案中僅為了使用timer而多加乙個窗體了。我一般用在activex exe中用來分離系統控制權,用timer的好處是避免控制權死鎖,這樣也就模擬出了多執行緒 實際上是多程序 能給使用者更好的體驗。如下 標準模組 mtimer opti...