Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

selcolor in richtextbox

Posted on 1998-08-27
5
Medium Priority
?
769 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

719 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