Scrollbars Events

Started by jermy, July 26, 2020, 11:42:24 AM

Previous topic - Next topic

jermy

Dear people,

how can i catch WM_VSCROLL and WM_HSCROLL with the visual designer?
I have already tested several Toolbox Events with Richedit control. there is no response at all from the scrollbar.

Thanks in advance for your help

Paul Squires

I don't think that the RichEdit control has dedicated message handlers for HSCROLL and VSCROLL.

You should be able to catch the messages by activating the "AllEvents" handler:


''
''
Function frmMain_RichEdit1_AllEvents( ByRef sender As wfxRichEdit, ByRef e As EventArgs ) As LRESULT

   select case e.Message
      case WM_SCROLL
      case WM_VSCROLL
   end select
   
   Function = 0
End Function

Paul Squires
PlanetSquires Software

jermy

#2
Hi Paul,

i cant catch any response at all from the scrollbar.
I tested with some other controls, no WM_HSCROLL to catch
perhaps it was forgotten while programming winfbe
I just need to know if the scrollbar has been used


' frmMain form code file
''
''
Function frmMain_RichEdit1_AllEvents( ByRef sender As wfxRichEdit, ByRef e As EventArgs ) As LRESULT

   select case e.Message
      case WM_HSCROLL
     print "WM_HSCROLL"
      case WM_VSCROLL
     Print "WM_VSCROLL"     
   end select

    Function = 0
End Function

''
''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT

dim i as long, s as CWSTR
for i = 0 to 20
     s = s & i & chr( 13, 10 )
next
frmMain.RichEdit1.Text = S

    Function = 0
End Function


Thanks in advance for your help

Paul Squires

Ah, yes, RichEdit scrollbars are more complicated. I remember that an "event mask" had to be set allowing the notification to be sent to the parent window (?). I will research it later once I have access to my development computer.
Paul Squires
PlanetSquires Software

jermy

#4
Hi Paul,

I have done a mini survey, sub_classing the edit control does pass the necessary messages

' frmMain form code file

declare Function SubRichEdit1(byval hWnd As HWND, byval uMsg As UINT, byval wParam As WPARAM, byval lParam As LPARAM, byval uIdSubclass As UINT_PTR, byval dwRefData As DWORD_PTR) As LRESULT

''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT

dim i as long, s as CWSTR
for i = 0 to 20
     s = s & i & chr( 13, 10 )
next
frmMain.RichEdit1.Text = S


  ' // subclass the RichEdit Control
  SetWindowSubclass( frmMain.RichEdit1.hWindow, @SubRichEdit1, 0, 0 )

    Function = 0
End Function

' ========================================================================================
' Processes messages for the subclassed RichEdit Control.
' ========================================================================================
Function SubRichEdit1( byval hWnd As HWND, _
                       byval uMsg As Uint, _
                       byval wParam As wparam, _
                       byval lParam As lparam, _
                       byval uIdSubclass As Uint_ptr, _
                       byval dwRefData As Dword_Ptr) As LRESULT
select case uMsg
             
       case WM_HSCROLL
             print "WM_HSCROLL"
       case WM_VSCROLL
             Print "WM_VSCROLL"
       Case WM_MOUSEWHEEL
             Print "WM_MOUSEWHEEL"
       Case WM_MOUSEMOVE
             Print "WM_MOUSEMOVE"     
       Case WM_PAINT ' 15
             Print "WM_PAINT"   
       Case WM_SETCURSOR
             Print "WM_SETCURSOR"
       Case WM_TIMER
             Print "WM_TIMER"       
       Case WM_NCHITTEST
             Print "WM_NCHITTEST"                     
       case WM_DESTROY
             ' // Remove the subclass
             RemoveWindowSubClass( hwnd, @SubRichEdit1, uIdSubclass )
       case WM_NCDESTROY
               
       Case else

end select

   ' // Default processing of Windows messages
   FUNCTION = DefSubclassProc(hwnd, uMsg, wParam, lParam)
End Function


Thanks in advance for your help

(removed typo)

veltesian

hello jermy & paul thanks for this post :D

i wanted to figure out how to work with a RichEdit CTRL. i hope its not a problem as i
copied jermy's example from their last post & everywhere i saw "frmMain" i just replaced that with "Form1"
& that code seemed to work perfectly. i did also want to understand how to populate a combobox & listbox
though, i guess i'll have to come back here soon & ask about it....

jermy

Hello veltesian,

A small warning

The Toolbox Events description is misleading, AllEvents in the toolbox returns all events except the events that you can also select in the toolbox.
At the moment AllEvents is not working properly yet, it would be more convenient if AllEvents would actually pass on all events.


''
''
Function frmMain_RichEdit1_AllEvents( ByRef sender As wfxRichEdit, ByRef e As EventArgs ) As LRESULT
   
    Print e.Message
    ' // no keyboard event, no click event ... and so on
    Function = 0
End Function