PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Scrollbars Events  (Read 222 times)

jermy

  • Junior Member
  • **
  • Posts: 55
Scrollbars Events
« on: July 26, 2020, 11:12:24 AM »

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
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9301
  • Windows 10
    • PlanetSquires Software
Re: Scrollbars Events
« Reply #1 on: July 26, 2020, 03:32:02 PM »

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:

Code: [Select]
''
''
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
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

jermy

  • Junior Member
  • **
  • Posts: 55
Re: Scrollbars Events
« Reply #2 on: July 26, 2020, 04:31:26 PM »

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

Code: [Select]
' 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
« Last Edit: July 26, 2020, 04:36:35 PM by jermy »
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9301
  • Windows 10
    • PlanetSquires Software
Re: Scrollbars Events
« Reply #3 on: July 27, 2020, 01:19:55 PM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

jermy

  • Junior Member
  • **
  • Posts: 55
Re: Scrollbars Events
« Reply #4 on: July 28, 2020, 05:41:42 PM »

Hi Paul,

I have done a mini survey, sub_classing the edit control does pass the necessary messages
Code: [Select]
' 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)
« Last Edit: July 29, 2020, 01:28:10 AM by jermy »
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 31
Re: Scrollbars Events
« Reply #5 on: July 29, 2020, 01:58:55 AM »

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....
Logged

jermy

  • Junior Member
  • **
  • Posts: 55
Re: Scrollbars Events
« Reply #6 on: July 29, 2020, 03:01:27 AM »

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.

Code: [Select]
''
''
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
Logged