Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 793
  • Last Modified:

selcolor in richtextbox

How i can change the color in a richtextbox without move selstart or without flashing?
0
flecoq
Asked:
flecoq
1 Solution
 
MAVERICKCommented:
I've had some success with the rtf.visible property set to false, change the color..... , then reset it to rtf.visible ......


0
 
manish_kothariCommented:
Dear flecoq,
       Your question is not clear. Please clearly specify the problem. What u want to do whether u want to change the color of the text or the backgroud color of the rich textbox and what u don't want to use.

0
 
flecoqAuthor Commented:
yes I want change the color of text without move cursor and selectionned text. I want realise an editor as vb which change the color of text automatic
0
 
azupancicCommented:
One possible solution (which I've employed with success) is to record your current position (rtf.SelStart) to a variable.  Use the LockWindowUpdate() API call passing it the window handle (rtf.hWnd) property of the RichTextBox.  Then select the text you want to change the color for, change it, then move back and unlock the RichTextBox:

i.e.  (Where rtf is the name of the RichTextBox):

Dim lOrigStart&, lOrigLen&   'current selection
Dim r&                       'return value from API functions

  With rtf

    'record current position and freeze window
    lOrigStart = .SelStart
    lOrigLen = .SelLength
    r& = LockWindowUpdate(.hWnd)

    'move to new position
    .SelStart = xxxx           'Starting position
    .SelLength = xxxx          'Length of text to select
    .SelColor = RGB(x, x, x)   'New color

    'move back to original position and unfreeze window
    .SelStart = lOrigStart
    .SelLength = lOrigLen
    r& = LockWindowUpdate(0&)

  End With


0
 
flecoqAuthor Commented:
Adjusted points to 70
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now