BeforUpdate, AfterUpdate Example

Code snippets illustrating how LBB can be used
Post Reply
sarmednafi
Posts: 17
Joined: Fri Apr 06, 2018 6:27 am

BeforUpdate, AfterUpdate Example

Post by sarmednafi » Fri Oct 05, 2018 1:46 pm

The following is a Demo of how to simulate BeforUpdate, AfterUpdate events of MSvisual Basic on LBB.



NOMAINWIN
WindowWidth = 474 : WindowHeight = 359
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
tx1i=0: tx1o=0
tx2i=0: tx2o=0
tx3i=0: tx3o=0
tx4i=0: tx4o=0

textbox #w.textbox1, 332, 35, 110, 24
textbox #w.textbox2, 222, 35, 110, 24
textbox #w.textbox3, 111, 35, 110, 24
textbox #w.textbox4, 0, 35, 110, 24

Open "Window " for Window as #w
#w "trapclose [quit]"
#w "font ms_sans_serif 10"

htxt1= hWnd(#w.textbox1)
htxt2= hWnd(#w.textbox2)
htxt3= hWnd(#w.textbox3)
htxt4= hWnd(#w.textbox4)

[Loop]
Timer 150, [events]
wait

[events]
CallDLL #user32, "GetFocus", Fh As long 'Gheck the focus
if Fh<>htxt1 then
if tx1i=1 then tx1o=1: tx1i=0: Timer 0: Goto [AfterUpdate1]
End if
if Fh= htxt1 AND tx1i=0 then tx1i=1: tx1o=0: Timer 0: Goto [BeforUpdate1]

if Fh<>htxt2 then
if tx2i=1 then tx2o=1: tx2i=0: Timer 0: Goto [AfterUpdate2]
End if
if Fh= htxt2 AND tx2i=0 then tx2i=1: tx2o=0: Timer 0: Goto [BeforUpdate2]

if Fh<>htxt3 then
if tx3i=1 then tx3o=1: tx3i=0: Timer 0: Goto [AfterUpdate3]
End if
if Fh= htxt3 AND tx3i=0 then tx3i=1: tx3o=0: Timer 0: Goto [BeforUpdate3]

if Fh<>htxt4 then
if tx4i=1 then tx4o=1: tx4i=0: Timer 0: Goto [AfterUpdate4]
End if
if Fh= htxt4 AND tx4i=0 then tx4i=1: tx4o=0: Timer 0: Goto [BeforUpdate4]
wait

[quit]
close #w : END

[BeforUpdate1]
notice "BeforUpdate 1"
Goto [Loop]

[BeforUpdate2]
notice "BeforUpdate 2"
Goto [Loop]

[BeforUpdate3]
notice "BeforUpdate 3"
Goto [Loop]

[BeforUpdate4]
notice "BeforUpdate 4"
Goto [Loop]

[AfterUpdate1]
notice "AfterUpdate 1"
Goto [Loop]

[AfterUpdate2]
notice "AfterUpdate 2"
Goto [Loop]

[AfterUpdate3]
notice "AfterUpdate 3"
Goto [Loop]

[AfterUpdate4]
notice "AfterUpdate 4"
Goto [Loop]

Post Reply