Results 1 to 16 of 16

Thread: [RESOLVED] Looking for a way to simulate a .SelStartRTF property

  1. #1

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Resolved [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.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  2. #2
    Addicted Member
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    135

    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

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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.

  4. #4

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Looking for a way to simulate a .SelStartRTF property

    Quote 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.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Looking for a way to simulate a .SelStartRTF property

    Quote 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.

  6. #6

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    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?
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Looking for a way to simulate a .SelStartRTF property

    Quote 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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  9. #9

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    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.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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:
    1. Private Const EM_LINELENGTH = &HC1
    2. Private Const EM_LINEINDEX = &HBB

  11. #11
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  12. #12

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    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.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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

  14. #14
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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.)
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  15. #15

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    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
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  16. #16

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    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
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width