Well here I'll give you an example and kind of explain it and give you a comparison between the VB version and the delphi code to do the same thing (I'm not really to knowledgable with C++ or I might give you an example of that)

This is the Delphi function to get the seltext of scintilla:

function TScintillaBase.GetSelText(text : PChar) : LongInt;
begin
  result := SPerform(SCI_GETSELTEXT, 0, LongInt(text));
end;

One line of code.  Very simple and to the point. 
Here is what I had to do in VB to pull off the same thing

Public Function GetSelText() As String
  Dim bByte() As Byte
  Dim lPtr As Long
  Dim strTmp As String
  Dim i As Long
  lPtr = SendMessage(sci, SCI_GETSELTEXT, 0, 0)
  ReDim Preserve bByte(0 To lPtr)
  SendMessage sci, SCI_GETSELTEXT, 0, VarPtr(bByte(0))
  strTmp = ""
 ! ; For i = 0 To UBound(bByte) - 1
    strTmp = strTmp & Chr(bByte(i))
  Next i
  GetSelText = strTmp
End Function

The first step was to call getseltext to a long to get the length of the seltext.  Then redim the byte array to that size.  Then call getseltext again this time using the pointer of the byte (This is pretty normal.  You do the same thing with delphi your utilizing the pointer.)
Then I have to go threw each item in the bByte (which is a byte) array and convert it over to a letter and store it to a string.  Finally I can output it. 

Obviously it works but it's a great example of the biggest reason I didn't do as neil suggested with a script to utilize scintilla.iface.  Because of the Odd little factors of VB to much of it would be hard to make a simple script descide what to do.  There are other occasions where scintilla will work just fine with a VB strin! g object for some reason.  So I descided doing it by hand was the safest though deffinatly not fastest way to go.

Anyway I've run into a new problem and maybe one of you can answer this.  I've run into a new problem.  I descided to make it work like a more standard text editing component.  If I can't get threw this problem and there's no way to work it I'll just stick to what I've been doing.  Anyway the major problem is the arrow keys won't work.  I'm guessing the easiest way to fix that would be in the subclassing code catch each arrow key and send the appropriate command back to scintilla.  Does scintilla send any messages when keys are pressed and is there any way to send back to scintilla a msg telling it to say move the cursor forward or back?

Thanks

Stewart


Edward Poore <[EMAIL PROTECTED]> wrote:
Steve,

That's fine then, I'm just a bit confused by what you mean by "The byte has to be made an array and what's returned into the byte array will be character longs not specificly letters."  Sorry if it's something obvious but as mentioned previously it's been a while since I used VB6.

Ed
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest


Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to