Page 3 of 3

Re: How Syncronize scroll in two gadgets?

Posted: Thu Oct 15, 2009 10:42 am
by pablov
Fluid Byte
Image thank you

Re: How Syncronize scroll in two gadgets?

Posted: Fri Dec 11, 2009 4:32 pm
by pablov
One more question.
How syncronize scroll in two ScintillaGadget?

Thank you

Re:

Posted: Fri Dec 11, 2009 5:37 pm
by Kwai chang caine
chen wrote:Battle at the top :wink:
Yes exactely....SROD against NETMAESTRO....incredible....it's so great :shock: 8)
It's the battle of TITANS, like when i was young and buy the "Strange" book 8)
But a kind battle :? .......because i love them both :D

Image

Re: How Syncronize scroll in two gadgets?

Posted: Mon Dec 21, 2009 8:34 am
by pablov
pablov wrote: How syncronize scroll in two ScintillaGadget?
Here is so works :wink:

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
;}

Re: How Syncronize scroll in two gadgets?

Posted: Mon Dec 21, 2009 4:41 pm
by PureLust
pablov wrote:Here is so works :wink:
Thanks for this helpful code. :D

Here is a little update including both - vertical and horizontal synchronization:

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
;}
Greetz, PL.