Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Gary Beene on June 20, 2010, 05:43:41 PM

Title: Scintilla: Why Use SendMessage?
Post by: Gary Beene on June 20, 2010, 05:43:41 PM
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.

Title: Re: Scintilla: Why Use SendMessage?
Post by: José Roca on June 20, 2010, 06:27:19 PM
 
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.
Title: Re: Scintilla: Why Use SendMessage?
Post by: Gary Beene on June 20, 2010, 10:55:41 PM
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?


Title: Re: Scintilla: Why Use SendMessage?
Post by: José Roca on June 20, 2010, 11:29:37 PM
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.