• Welcome to Theos PowerBasic Museum 2017.

Scintilla: Why Use SendMessage?

Started by Gary Beene, June 20, 2010, 05:43:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gary Beene

In reading the documentation for Scintilla I've read about the ability to directly call Scintilla functions without using SendMessage.  In the SED source code I see how it was implemented but also noticed that both SciMsg and SendMessage are used.

In practice, are there actual circumstances where the use of SciMsg would be noticed by a user?  And if SciMsg is faster, is there any reason to ever use SendMessage?

It seems as though, in SED, that SciMsg was used mostly in actions related to code folding.


José Roca

 
When you have to do a repeated action in a loop or have to send many messages one after another, using SciMsg will be slightly faster. When you just have to send a message, it will be slower, unless you already have a direct pointer, because you first will have to send a message ( pSci = SendMessage(hSci, %SCI_GETDIRECTPOINTER, 0, 0) ) to get it.

Gary Beene

Hello Jose,

Thanks for the information.

Once the pointer is acquired (such as once on program startup), it can be reused over and over, yes? So the speed loss only applies to the first time the pointer is acquired?

And with the pointer in hand, is there any reason/advantage to using SendMessage again - as was done in the SED source code?



José Roca

Quote
Once the pointer is acquired (such as once on program startup), it can be reused over and over, yes? So the speed loss only applies to the first time the pointer is acquired?

Yes... if you only have an instance of Scintilla.

Quote
And with the pointer in hand, is there any reason/advantage to using SendMessage again - as was done in the SED source code?

SED is a MDI application. You can open as many windows as you wish, and each one uses an instance of the Scintilla control. Keeping track of all these pointers an retrieving the one that belongs to the active window will be cumbersome and slower than using SendMessage.