I've found some C-code I (obviously) don't fully understand...
It's a way to bypass sendScintillaMessage and do a faster call to it.
Here's the C code from the Scintilla homepage:
Code: Select all
int (*fn)(void*,int,int,int);
void * ptr;
int canundo;
fn = (int (__cdecl *)(void *,int,int,int))SendMessage(
hwndScintilla,SCI_GETDIRECTFUNCTION,0,0);
ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRECTPOINTER,0,0);
canundo = fn(ptr,SCI_CANUNDO,0,0) // this is the final example function pointer for fast call
I tried this code with PB:
EnableExplicit
Code: Select all
InitScintilla()
Declare ScintillaCallBack(Gadget, *N.SCNotification)
define NrWin = OpenWindow(#PB_Any, 128, 128, 640, 512, "Scintilla Test")
if NrWin
define w = 640-16,
h = 512-16-32
define NrBoxSci = ContainerGadget(#PB_Any, 8, 32, w, h, #PB_Container_BorderLess)
define NrSci = ScintillaGadget(#PB_Any, -2, -2, w + 4, h + 4, @ScintillaCallBack())
CloseGadgetList()
; get some direct functions
Prototype SciPrototype(NrSci, Msg.i, WParam.i=0, LParam.i=0) ; or PrototypeC?
define fn.SciPrototype = ScintillaSendMessage(NrSci, #SCI_GETDIRECTFUNCTION)
; same prototype for fn and canSciUndo/setSciText?
define ptr = ScintillaSendMessage(NrSci, #SCI_GETDIRECTPOINTER)
; HERE IS THE PROBLEM: both vars are zero ********************************
define canSciUndo.SciPrototype = fn(ptr, #SCI_CANUNDO, 0, 0)
define setSciText.SciPrototype = fn(ptr, #SCI_SETTEXT, 0, 0)
debug "canSciUndo = " + Str(canSciUndo)
debug "setSciText = " + Str(setSciText)
repeat
define Evt = WaitWindowEvent()
select Evt
case #PB_Event_CloseWindow
break
default
endSelect
forever
endif
Procedure ScintillaCallBack(Gadget, *N.SCNotification)
if *N\message<>0
debug Str(*N\message)
endif
EndProcedure
Really appreciate any help!
Thanks a lot!!!