ThaiPBL.com

PowerBuilder Library Thailand

อีเมล พิมพ์ PDF

เพิ่ม Timer event ให้กับ object ต่างๆ

สวัสดีครับ เรามีวิธีการเพิ่ม Timer event ให้กับ object ต่างๆโดยทำการ declare user event และ ทำการเรียกใช้ API function ซึ่งมีรูปแบบดังนี้นะครับ

เริ่มแรกให้ทำการกำหนด user event ตั้งชื่อว่า Timer และทำการ map กับ pbm_timer

เสร็จแล้วก็กำหนด Global External Functions ดังนี้

Function Long SetTimer(Long hwnd, long idTimer, Long uTimeOut, Long tmprc) Library "user32.dll"
Function Long KillTimer(Long hwnd, Long idEvent) Library "user32.dll"


เวลาที่ต้องการใช้งานก็เรียกคำสั่งดังตัวอย่างด้านล่างนี้


SetTimer(Handle(the_control), 1, 500, 0) 
KillTimer(Handle(the_control),1)


ตัวเลข 500 คือจำนวนของ ครึ่งวินาที