Re: How Syncronize scroll in two gadgets?
Posted: Thu Oct 15, 2009 10:42 am
Fluid Byte
thank you

http://www.purebasic.com
https://www.purebasic.fr/english/
Yes exactely....SROD against NETMAESTRO....incredible....it's so greatchen wrote:Battle at the top![]()
Here is so workspablov wrote: How syncronize scroll in two ScintillaGadget?
Code: Select all
Global hSci0.l, hSci1.l, scroll_0.l, scroll_1.l
Enumeration 0
#Sci0
#Sci1
EndEnumeration
If InitScintilla("Scintilla.dll")=0
MessageRequester("File not found", " File " + Chr(34) + "Scintilla.dll" + Chr(34) + " not found!", #MB_OK|#MB_ICONERROR)
End
EndIf
ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
scroll_0 = ScintillaSendMessage(#Sci0, #SCI_GETFIRSTVISIBLELINE)
scroll_1 = ScintillaSendMessage(#Sci1, #SCI_GETFIRSTVISIBLELINE)
If scroll_0 <> scroll_1
Select *scinotify\nmhdr\HwndFrom
Case hSci0
ScintillaSendMessage(#Sci1, #SCI_LINESCROLL, 0, scroll_0 - scroll_1)
Case hSci1
ScintillaSendMessage(#Sci0, #SCI_LINESCROLL, 0, scroll_1 - scroll_0)
EndSelect
EndIf
EndProcedure
If OpenWindow(0, 200, 10, 400, 470, "Scintilla exemple", #PB_Window_SystemMenu )
If UseGadgetList(WindowID(0))
hSci0 = ScintillaGadget(#Sci0, 0, 0, 400, 227, @ScintillaCallBack())
hSci1 = ScintillaGadget(#Sci1, 0, 234, 400, 227, @ScintillaCallBack())
ScintillaSendMessage(#Sci0,#SCI_SETHSCROLLBAR,0)
ScintillaSendMessage(#Sci1,#SCI_SETHSCROLLBAR,0)
; Set caret line colour
ScintillaSendMessage(#Sci0, #SCI_SETCARETLINEBACK, $eeeeff)
ScintillaSendMessage(#Sci0, #SCI_SETCARETLINEVISIBLE, #True)
ScintillaSendMessage(#Sci1, #SCI_SETCARETLINEBACK, $eeeeff)
ScintillaSendMessage(#Sci1, #SCI_SETCARETLINEVISIBLE, #True)
; Margins
ScintillaSendMessage(#Sci0, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) ;
ScintillaSendMessage(#Sci0, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Sci0, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Sci0, #SCI_SETMARGINWIDTHN, 2, 0)
ScintillaSendMessage(#Sci0, #SCI_SETMARGINSENSITIVEN, 2, #True)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) ;
ScintillaSendMessage(#Sci1, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINWIDTHN, 2, 0)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINSENSITIVEN, 2, #True)
For i = 1 To 1000
txt.s + Str(i)+Str(i)+Str(i)+Str(i)+Str(i)+Str(i)+#LF$
Next i
ScintillaSendMessage(#Sci0, #SCI_SETTEXT, #Null, @txt)
ScintillaSendMessage(#Sci1, #SCI_SETTEXT, #Null, @txt)
EndIf
EndIf
;{- Event loop
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = 0
CloseWindow(0)
Break
EndIf
EndSelect
ForEver
;}
Thanks for this helpful code.pablov wrote:Here is so works![]()
Code: Select all
Global hSci0.l, hSci1.l, scroll_0.l, scroll_1.l
Enumeration 0
#Sci0
#Sci1
EndEnumeration
If InitScintilla("Scintilla.dll")=0
MessageRequester("File not found", " File " + Chr(34) + "Scintilla.dll" + Chr(34) + " not found!", #MB_OK|#MB_ICONERROR)
End
EndIf
ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
scroll_0 = ScintillaSendMessage(#Sci0, #SCI_GETFIRSTVISIBLELINE)
scroll_1 = ScintillaSendMessage(#Sci1, #SCI_GETFIRSTVISIBLELINE)
If scroll_0 <> scroll_1
Select *scinotify\nmhdr\HwndFrom
Case hSci0
ScintillaSendMessage(#Sci1, #SCI_LINESCROLL, 0, scroll_0 - scroll_1)
Case hSci1
ScintillaSendMessage(#Sci0, #SCI_LINESCROLL, 0, scroll_1 - scroll_0)
EndSelect
EndIf
xscroll_0 = ScintillaSendMessage(#Sci0, #SCI_GETXOFFSET)
xscroll_1 = ScintillaSendMessage(#Sci1, #SCI_GETXOFFSET)
If xscroll_0 <> xscroll_1
Select *scinotify\nmhdr\HwndFrom
Case hSci0
ScintillaSendMessage(#Sci1, #SCI_SETXOFFSET, xscroll_0)
Case hSci1
ScintillaSendMessage(#Sci0, #SCI_SETXOFFSET, xscroll_1)
EndSelect
EndIf
EndProcedure
If OpenWindow(0, 200, 10, 400, 470, "Scintilla exemple", #PB_Window_SystemMenu )
If UseGadgetList(WindowID(0))
hSci0 = ScintillaGadget(#Sci0, 0, 0, 400, 227, @ScintillaCallBack())
hSci1 = ScintillaGadget(#Sci1, 0, 234, 400, 227, @ScintillaCallBack())
; ScintillaSendMessage(#Sci0,#SCI_SETHSCROLLBAR,0)
; ScintillaSendMessage(#Sci1,#SCI_SETHSCROLLBAR,0)
; Set caret line colour
ScintillaSendMessage(#Sci0, #SCI_SETCARETLINEBACK, $eeeeff)
ScintillaSendMessage(#Sci0, #SCI_SETCARETLINEVISIBLE, #True)
ScintillaSendMessage(#Sci1, #SCI_SETCARETLINEBACK, $eeeeff)
ScintillaSendMessage(#Sci1, #SCI_SETCARETLINEVISIBLE, #True)
; Margins
ScintillaSendMessage(#Sci0, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) ;
ScintillaSendMessage(#Sci0, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Sci0, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Sci0, #SCI_SETMARGINWIDTHN, 2, 0)
ScintillaSendMessage(#Sci0, #SCI_SETMARGINSENSITIVEN, 2, #True)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) ;
ScintillaSendMessage(#Sci1, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINWIDTHN, 2, 0)
ScintillaSendMessage(#Sci1, #SCI_SETMARGINSENSITIVEN, 2, #True)
For n = 1 To 200
linetxt.s + Chr(n+63)
Next n
For i = 1 To 1000
txt.s + Mid(linetxt,Random(50),100+Random(50))+#LF$
Next i
ScintillaSendMessage(#Sci0, #SCI_SETTEXT, #Null, @txt)
ScintillaSendMessage(#Sci1, #SCI_SETTEXT, #Null, @txt)
EndIf
EndIf
;{- Event loop
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = 0
CloseWindow(0)
Break
EndIf
EndSelect
ForEver
;}