Solved

selcolor in richtextbox

Posted on 1998-08-27
5
735 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points to 70
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 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

10 Experts available now in Live!

Get 1:1 Help Now