How do I prevent(filter) WM_MOUSEMOVE from affecting WM_TIMER case statement evaluating true

56 Views Asked by At

I am using FreeBASIC with win32API to make a simple data logger. I have an EditBox inside the Main window displaying data-log records 1 per second.

It all works perfectly, except when I move the mouse between the Main window & the EditBox (specifically the lower & right edge, where the scroll bars would be or are displayed), then I get extra 2 timer events evaluated true in my case statement with each move. (WindowMain to EditBox or EditBox to WindowMain).

Is there a way to filter the message from (I assume) WM_MOUSEMOVE making the Timer Case code evaluate True?

Edit1: I can confirm the WM_TIMER event message is activated when the mouse moves in/out of the area of the Editbox ScrollBars. Disabling ScrollBar arrows does not mitigate the issue.(just disables the ScrollBars) EnableScrollBar(LogWindow,SB_BOTH,ESB_DISABLE_BOTH)

Edit2: Now that I have identified the specific cause of my issue, the title of this question is not right. The unwanted WM_TIMER messages are from the EditBox scroll bars, there would be a timer associated with mouse over.

Code:

SetTimer(Window_Main, 1, 1000, 0 )  
                      '                             
 Do     'Main loop to check WinAPI event states:

   WaitEvent(Window_Main, msg)
'- Select Case msg.hwnd
   Select Case msg.message
      Case WM_TIMER                          
         If LogState = Run_ Then Get_Data
'        Get_Data  '<<<-- DEBUG ONLY to test timer

   End Select

   Select Case msg.hwnd
      Case Btn_TstCom
         If msg.message = WM_LBUTTONUP Then
            EditBox_Paste(LogWindow)
         End If

      Case Btn_ClrLog

image

1

There are 1 best solutions below

0
tonigau On

With some help on a forum, adding the following filtered just the message from the timer in my SetTimer statement:

If msg.hwnd = Window_Main AndAlso msg.wParam = 1 Then

Here, msg.wParam is the Timer ID.