Solved

selcolor in richtextbox

Posted on 1998-08-27
5
737 Views
Last Modified: 2008-03-17
How i can change the color in a richtextbox without move selstart or without flashing?
0
Comment
Question by:flecoq
5 Comments
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1431276
I've had some success with the rtf.visible property set to false, change the color..... , then reset it to rtf.visible ......


0
 

Expert Comment

by:manish_kothari
ID: 1431277
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
 

Author Comment

by:flecoq
ID: 1431278
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
 

Accepted Solution

by:
azupancic earned 70 total points
ID: 1431279
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
 

Author Comment

by:flecoq
ID: 1431280
Adjusted points to 70
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now