Page 1 of 1

event 280 is which Constant ? when has input focus

Posted: Tue Sep 26, 2017 1:23 am
by gurj
event 280 is which Constant ? when has input focus

Code: Select all

;event 280 is which Constants ?
OpenWindow(0,0,0,300,300,"",#PB_Window_SystemMenu)
EditorGadget(0,0,30,222,222)
SetGadgetText(0,~"this is my cipher list:\n...\nif I away, aoto End")
SetActiveGadget(0);if use this line, will has event 280
Repeat
 a=ElapsedMilliseconds()
 ev=WaitWindowEvent(2222)
 re:
 Select ev
  Case 280:Debug a
  Case 0:Debug 0
  Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End

Re: event 280 is which Constant ? when has input focus

Posted: Tue Sep 26, 2017 1:48 am
by nco2k
its the undocumented WM_SYSTIMER message, that is being used for the caret blink. the blinkrate depends on the current users keyboard settings. never use an undocumented feature though. if you need to check the gadget focus, you should use #PB_EventType_Focus and #PB_EventType_LostFocus instead. if you need to set up a timer, use AddWindowTimer().

c ya,
nco2k

Re: event 280 is which Constant ? when has input focus

Posted: Tue Sep 26, 2017 2:39 am
by gurj
thanks nco2k, i need #wm_systimer, when user sleeping.

Re: event 280 is which Constant ? when has input focus

Posted: Tue Sep 26, 2017 4:06 am
by nco2k
gurj wrote:i need #wm_systimer, when user sleeping.
no you dont.

as i said earlier, the frequency of how often you will receive that message, depends on the current users blinkrate settings and will differ from system to system. since its an undocumented feature, it may rely on other things as well. who knows. also what if the user has the caret disabled? you probably wont get that message at all.

ElapsedMilliseconds() is meant to measure the delta between two calls. it was never meant to be used as you do in your example. the internal behavior of ElapsedMilliseconds() changed in the past and may change again in the future, so you really shouldnt use it like that.

if you need idle detection, you could use GetLastInputInfo_() for example:

Code: Select all

Procedure TimeLastInput()
  Protected lii.LASTINPUTINFO\cbSize = SizeOf(LASTINPUTINFO)
  GetLastInputInfo_(@lii)
  ProcedureReturn lii\dwTime
EndProcedure

OpenWindow(0, #PB_Ignore, #PB_Ignore, 400, 300, "Test", #PB_Window_SystemMenu)
AddWindowTimer(0, 0, 1000)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Timer
      If EventTimer() = 0
        TimeDelta = GetTickCount_() - TimeLastInput()
        Debug "Last Input: "+Str(TimeDelta / 1000)+" Seconds ago"
      EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
Until TimeDelta >= 5000
c ya,
nco2k

Re: event 280 is which Constant ? when has input focus

Posted: Tue Sep 26, 2017 4:55 am
by gurj
@nco2k, thank you very much! again!