ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOINTER

Windows specific forum
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOINTER

Post by RSBasic »

Hello

I have a problem. I have two ScintillaGadgets and I want to connect both ScintillaGadgets with #SCI_GETDOCPOINTER and #SCI_SETDOCPOINTER.
This code works:

Code: Select all

EnableExplicit

InitScintilla()

Define PBScintillaPointer

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScintillaGadget(1, 0, 0, 500, 200, 0)
  ScintillaGadget(2, 0, 200, 500, 200, 0)
  
  PBScintillaPointer = SendMessage_(GadgetID(1), #SCI_GETDOCPOINTER, 0, 0)
  
  SendMessage_(GadgetID(2), #SCI_SETDOCPOINTER, 0, PBScintillaPointer)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
But if I have two programs, it won't work.

Program 1:

Code: Select all

EnableExplicit

InitScintilla()

Define PBScintillaPointer

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScintillaGadget(1, 0, 0, 500, 400, 0)
  
  SendMessage_(GadgetID(1), #SCI_GETDOCPOINTER, 0, 0)
  
  PBScintillaPointer = SendMessage_(GadgetID(1), #SCI_GETDOCPOINTER, 0, 0)
  Debug PBScintillaPointer ;-Please copy the handle
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
Program 2:

Code: Select all

EnableExplicit

InitScintilla()

Define PBScintillaPointer

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScintillaGadget(1, 0, 0, 500, 400, 0)
  
  PBScintillaPointer = 4552448 ;-Please insert the handle here.
  
  SendMessage_(GadgetID(1), #SCI_SETDOCPOINTER, 0, PBScintillaPointer)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
When I start program 1, copy and paste the handle and start program 2, there is a crash. :!:
Can you help me? :(

It should be a new tool "SplitView" for PureBasic.
Image
Image
fryquez
Enthusiast
Enthusiast
Posts: 362
Joined: Mon Dec 21, 2015 8:12 pm

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by fryquez »

The pointer return by SCI_GETDOCPOINTER is properly a memory address in program 1, so it's not valid for program 2.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RSBasic »

Thanks for your answer. Yes, you're right.
Is there another way to connect two ScintillaGadgets over two processes?
Image
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RASHAD »

Hi RSBasic
for one process :)

Code: Select all

InitScintilla()

Procedure WinCallback(hWnd, uMsg, WParam, LParam) 
 result = #PB_ProcessPureBasicEvents    
  Select uMsg
    Case #WM_NCPAINT
        ProcedureReturn 1
     
    Case #WM_NCACTIVATE
        ProcedureReturn 1
  EndSelect
  
  ProcedureReturn Result
EndProcedure 

If OpenWindow(0, 0, 0, 500, 400, "Window #1", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScintillaGadget(1, 0, 0, 500, 400, 0) 
  PBScintillaPointer = SendMessage_(GadgetID(1), #SCI_GETDOCPOINTER, 0, 0)
  OpenWindow(1, 100, 100, 500, 400, "Window #2", #PB_Window_SystemMenu )
  UseGadgetList(WindowID(1))
  ScintillaGadget(2, 0, 0, 500, 400, 0)
  SendMessage_(GadgetID(2), #SCI_SETDOCPOINTER, 0, PBScintillaPointer)
  SetActiveWindow(0)
  SetWindowCallback(@WinCallback(),0)
  SetActiveWindow(1)
  SetWindowCallback(@WinCallback(),1)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver 
EndIf
Last edited by RASHAD on Thu Jun 27, 2019 8:25 pm, edited 1 time in total.
Egypt my love
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RSBasic »

Hi RASHAD
Thank you for your answer.
Unfortunately this must be two processes, because I would like to develop a tool for PureBasic: SplitView
My tool creates its own ScintillaGadget and the ScintillaGadget is inserted into the PB window with SetParent_().
I would like to connect my ScintillaGadget with the PB-ScintillaGadget. Do you have an idea?
Image
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RASHAD »

I tried already AddGlobalAtom but I failed and that proof what fryquez said
Next I will try WM_COPYDATA
If failed we should try buffer application in between
Keep going
Egypt my love
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by #NULL »

Could you open a new tab, hijack the scintilla gadget and hide or close the tab? So the gadget already belongs to the IDE process. Just an idea, I don't know if that could work at all.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RSBasic »

Hello #NULL

That's a good idea. That would work, but the problem is that the new temporary tab for SplitView must remain open, otherwise PB will release my ScintillaGadget.
Because the TabBar is a CanvasGadget ( viewtopic.php?f=12&t=47588 ), I can hide the tab because I don't have access.
I'll test it.

Maybe there is an internal PB function in the PB process to create a new ScintillaGadget? ( For example, calling a procedure from PB with a pointer: https://www.purebasic.fr/german/viewtop ... 43#p319043 )
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RSBasic »

@#NULL
Thanks again for your idea. This works very well:
Image

Now I just have to check how to create a new ScintillaGadget or create and hide a new tab.
Image
Image
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by #NULL »

But I could imagine even a hidden tab might mess with the IDEs tab/session management and/or with undo/redo or other things.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by chi »

RSBasic wrote:Now I just have to check how to create a new ScintillaGadget...
Why don't you just unhide and resize the original ScintillaGadget(s)? No need for additional ones.

Image
RSBasic wrote:... or create and hide a new tab.
The IDE uses STARGÅTE's excellent TabBarGadget, which is made of a CanvasGadget. So there is no way to just SendMessage_(..) to create/remove or show/hide a tab, you have to inject a dll and hijack the callback. Which should/could work, but I bet the IDE will not be very happy about it. I've tried similar things before, had some random crashes... Also what #NULL said ^^


I really hope @Fred will pick up the task to properly implement SplitView (on all platforms). Should be much easier for him ;)
Et cetera is my worst enemy
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN

Post by RSBasic »

chi wrote:Why don't you just unhide and resize the original ScintillaGadget(s)? No need for additional ones.
I've already done that. :)
Image

Only a new tab must exist. I'll see if I can do it without an extra tab. Therefore I want to create a ScintillaGadget.
Image
Image
Post Reply