-
Dec 4th, 2005, 03:25 AM
#1
Thread Starter
No place like 127.0.0.1
[RESOLVED] Looking for a way to simulate a .SelStartRTF property
I need a way to tell where the insertion point is in the .TextRTF. I was thinking about parsing all the "\par" out and figuring out which line the cursor was on in the normal text and syncing those 2 numbers up (if that made any sense). I was hoping for a faster way then that though because that would involve a lot of Split-ing or a lot of other slow VB string functions.
Last edited by eyeRmonkey; Dec 8th, 2005 at 01:21 AM.
-
Dec 4th, 2005, 05:04 PM
#2
Addicted Member
Re: Looking for a way to simulate a .SelStartRTF property
A couple questions....
Why would you want to remove all the \par out of your RTF?
And... if you're concerned about speed, why are you using VB
-
Dec 4th, 2005, 05:44 PM
#3
Re: Looking for a way to simulate a .SelStartRTF property
An workaround may be, -
Add a hidden text in the SelRTF of insertion point. Use \v and \v0 tags.
Like : \v |~~iPrank has gone crazy~~|\v0
Now in TextRTF find our custom text. That's our SelStartRTF.
Make sure you delete the hidden text, otherwise RTF may act funny with backspace/delete keys.
Also, please note that, if the insertion point is beginning of a line, the \v tag will move after \pard.
-
Dec 4th, 2005, 07:19 PM
#4
Thread Starter
No place like 127.0.0.1
Re: Looking for a way to simulate a .SelStartRTF property
Originally Posted by JasonC
A couple questions....
Why would you want to remove all the \par out of your RTF?
And... if you're concerned about speed, why are you using VB
I didn't mean remove all the \par. I meant count all the \par (in .TextRTF) and then line that up with all the vbCrLf (in .Text) and use the current cursor position to simular where the cursor would be in .TextRTF.
Not a bad idea iPrank, but I don't see how I would insert the special text into .TextRTF just by using .SelRTF. I though .SelRTF was read-only. I guess I could be wrong though.
The reason I am asking all this is because I want to be able to syntax color just the current line that the cursor is on.
-
Dec 4th, 2005, 07:43 PM
#5
Re: Looking for a way to simulate a .SelStartRTF property
Originally Posted by eyeRmonkey
The reason I am asking all this is because I want to be able to syntax color just the current line that the cursor is on.
You can do this like this :
On SelChange or Change event,
1. Get current line number by GetLineFromChar method.
2. Now get start of current line by using EM_LINEINDEX. It would be our SelStart.
3. Now use EM_LINELENGTH message to get total number of character of our line. This is our SelLength.
4. We have our SelRTF.
AFAIK, there is no PROPER way to get the current cursor position from TextRTF.
-
Dec 4th, 2005, 07:58 PM
#6
Thread Starter
No place like 127.0.0.1
Re: Looking for a way to simulate a .SelStartRTF property
How am I suppose to know what EM_LINEINDEX and EM_LINELENGTH are? And is there any way I can do it without subclassing? Or was that API stuff?
-
Dec 4th, 2005, 08:10 PM
#7
Re: Looking for a way to simulate a .SelStartRTF property
Originally Posted by eyeRmonkey
How am I suppose to know what EM_LINEINDEX and EM_LINELENGTH are? And is there any way I can do it without subclassing? Or was that API stuff?
Sorry.
They are messages that Edit controls/RTB uses as a 'command'.
Please see
Edit Control MSDN documentation - http://msdn.microsoft.com/library/de...itcontrols.asp
and
Rich Edit Control MSDN documentation - http://msdn.microsoft.com/library/en...itControls.asp
You'll find every message they use in those pages.
-
Dec 4th, 2005, 08:15 PM
#8
Re: Looking for a way to simulate a .SelStartRTF property
You don't need subclassing for this. Just send those messages to the control's hWnd using SendMessage API.
If you haven't used any API before, you may find this tutorial helpful.
-
Dec 5th, 2005, 01:15 AM
#9
Thread Starter
No place like 127.0.0.1
Re: Looking for a way to simulate a .SelStartRTF property
Sorry, I don't think I was very clear on my last post.
Yes, I am very familiar with API-related code. My problem was that I can't find the numerical values for those constants (EM_LINEINDEX, EM_LINELENGTH) anywhere on MSDN. Thats the only thing holding me up at the moment.
-
Dec 5th, 2005, 01:28 AM
#10
Re: Looking for a way to simulate a .SelStartRTF property
Don't you have the API Viewer in VB6 add-ons? It lists Declares, Constants, and Types. Then it writes them either as public or private.
VB Code:
Private Const EM_LINELENGTH = &HC1
Private Const EM_LINEINDEX = &HBB
-
Dec 5th, 2005, 05:06 AM
#11
Re: Looking for a way to simulate a .SelStartRTF property
You may download the free APIViewer - It has lot more definition than VS API Viewer.
Also, for quick info and example on a API, download APIGuide
-
Dec 5th, 2005, 09:51 AM
#12
Thread Starter
No place like 127.0.0.1
Re: Looking for a way to simulate a .SelStartRTF property
I havn't actually used the API viewer before because APIGuide has always had what I needed. I actually thought about using the API Viewer last night as I was going to bed.
Thanks for the help guys. That should figure things out for me.
Last edited by eyeRmonkey; Dec 5th, 2005 at 09:57 AM.
-
Dec 5th, 2005, 11:14 AM
#13
Re: Looking for a way to simulate a .SelStartRTF property
I don't really like either the API-Guide or API Viewer. I get my function definitions from MSDN and for the constant values - just google "#define CONSTANT_NAME".
e.g.
"#define EM_LINELENGTH"
and use the value you see most often, that usually works
-
Dec 5th, 2005, 12:18 PM
#14
Re: Looking for a way to simulate a .SelStartRTF property
I agree with penagate. APIViewer is not 100% correct.
In addition to Google search,
If you have VC++ installed, you can find those constants in different C++ header (.h) files.
For example, EM_LINELENGTH constant is defined in WINUSER.H.
(Remember to replace 0x hex prefix of C++ with &H hex prefix of VB.)
-
Dec 5th, 2005, 04:03 PM
#15
Thread Starter
No place like 127.0.0.1
Re: Looking for a way to simulate a .SelStartRTF property
Cool. Google will probably be what I use the most then. Although I do have dialup, so when I'm not signed on I will probably use APIViewer.
Thanks guys
-
Dec 8th, 2005, 01:20 AM
#16
Thread Starter
No place like 127.0.0.1
Re: [RESOLVED] Looking for a way to simulate a .SelStartRTF property
Incase anyone cares. I solved this and all my other RTB problems by using this custom control from vbAccelerator:
RichEdit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|