How Syncronize scroll in two gadgets?

Just starting out? Need help? Post your questions and find answers here.
pablov
User
User
Posts: 19
Joined: Mon Apr 06, 2009 11:55 am

Re: How Syncronize scroll in two gadgets?

Post by pablov »

Fluid Byte
Image thank you
pablov
User
User
Posts: 19
Joined: Mon Apr 06, 2009 11:55 am

Re: How Syncronize scroll in two gadgets?

Post by pablov »

One more question.
How syncronize scroll in two ScintillaGadget?

Thank you
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re:

Post 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
ImageThe happiness is a road...
Not a destination
pablov
User
User
Posts: 19
Joined: Mon Apr 06, 2009 11:55 am

Re: How Syncronize scroll in two gadgets?

Post 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
;}
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: How Syncronize scroll in two gadgets?

Post 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.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Post Reply