It is currently Thu Sep 19, 2019 12:12 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOINTER
PostPosted: Thu Jun 27, 2019 6:41 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1097
Location: Germany::Berlin()
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:
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:
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:
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.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Thu Jun 27, 2019 7:42 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Dec 21, 2015 8:12 pm
Posts: 141
The pointer return by SCI_GETDOCPOINTER is properly a memory address in program 1, so it's not valid for program 2.


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Thu Jun 27, 2019 7:58 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1097
Location: Germany::Berlin()
Thanks for your answer. Yes, you're right.
Is there another way to connect two ScintillaGadgets over two processes?

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Thu Jun 27, 2019 8:12 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3395
Hi RSBasic
for one process :)
Code:
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

_________________
Egypt my love


Last edited by RASHAD on Thu Jun 27, 2019 8:25 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Thu Jun 27, 2019 8:15 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1097
Location: Germany::Berlin()
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?

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Thu Jun 27, 2019 8:34 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3395
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


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Fri Jun 28, 2019 8:10 am 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1044
Location: right here
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Fri Jun 28, 2019 8:39 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1097
Location: Germany::Berlin()
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 )

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Fri Jun 28, 2019 11:47 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1097
Location: Germany::Berlin()
@#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.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Fri Jun 28, 2019 12:11 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1044
Location: right here
But I could imagine even a hidden tab might mess with the IDEs tab/session management and/or with undo/redo or other things.


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Fri Jun 28, 2019 5:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 608
Location: Linz, Austria
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 ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: ScintillaGadget - #SCI_GETDOCPOINTER and #SCI_SETDOCPOIN
PostPosted: Fri Jun 28, 2019 5:54 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1097
Location: Germany::Berlin()
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.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye