Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

selcolor in richtextbox

Posted on 1998-08-27
5
Medium Priority
?
779 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 210 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

971 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