I got some code from a VB project that has a lot of editing features for a RichTextBox. When selecting a word, multiple words, or the entire text the selected text is highlighted in black. How can I change this to be the same color used when selecting in VB projects (dark blue)?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
The RichTextBox control appears to have no such property nor method that can change the color of the selection rectangle. Neither does the API Rich Edit control. That could be because the RichTextBox control simply inverts the ForeColor and BackColor of the selection.
EDIT
The Rich Edit control used in WordPad (v4.0 I believe) highlights characters using the same fore and back color as that of the Edit control.
Last edited by Bonnie West; Jun 21st, 2013 at 02:21 PM.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
The RichTextBox control appears to have no such property nor method that can change the color of the selection rectangle. Neither does the API Rich Edit control. That could be because the RichTextBox control simply inverts the ForeColor and BackColor of the selection.
EDIT
The Rich Edit control used in WordPad (v4.0 I believe) highlights characters using the same fore and back color as that of the Edit control.
Years ago I did it using API but that code is long lost. Probably some code I got from LaVolpe
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Years ago I did it using API but that code is long lost. Probably some code I got from LaVolpe
Interesting. However, I don't know how it can be done, if it can even be done at all. Perhaps there's an API message I've missed in the link I've posted above...
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
I said FFFFFF - (Dark Blue), not just FFFFFF. Let's say your shade of dark blue is 991111 (bear in mind, in VB6, RGB values are actually ordered as BGR), then to get 991111 as your highlight color, use FFFFFF - 991111 = 66EEEE. So to make the highlight 991111, use:
Code:
RichTextBox1.BackColor = &H0066EEEE&
Last edited by Lenggries; Jun 21st, 2013 at 03:41 PM.
Reason: typo
Oh sure NOW you clear that up ... it wasn't obvious it was a formula... you could have explained it that it needed to be white (FFFFFF) minus the dark blue value ... when I read it, I thought you were trying to say that FFFFFF was Dark Blue... I wondered what world you lived in and if I could get in on your reality...
I thought you were trying to say that FFFFFF was Dark Blue.
Me too.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Interesting. However, I don't know how it can be done, if it can even be done at all. Perhaps there's an API message I've missed in the link I've posted above...
I'm searching through my mind trying to recall the circumstances when and how and who. It seems to me that it was a either a custom control (by LaVolpe) or something and he was spending a lot of time helping me with this but I don't think it involved any of those EM_ constants; more like using drawing APIs (DrawText, Rectangles, etc).
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
I wondered what world you lived in and if I could get in on your reality...
All it takes is the right prescription medication, allergies, and a lot of missing sleep.
To the OP... not sure if any of this will actually help you, since it has the side effect of changing the background from white to a sickly yellow, but if it's dark blue highlighting you want, what's a little sickly yellow background matter, eh?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
The Rich Edit control used in WordPad (v4.0 I believe) highlights characters using the same fore and back color as that of the Edit control.
That's probably Rich Edit version 4.1, Msftedit.dll. The VB6 RTB uses Riched20.dll (versions 2.0 or 3.0) indirectly via Riched32.dll (Rich Edit version 1.0) emulation.
So unless you create a naked Win32 control or a 3rd party ActiveX wrapper control instead of using the VB6 RTB control you don't have the capability in VB6.
Turns out the version is the issue, as shown here:
Selected text shows as white on blue
Last edited by dilettante; Jun 21st, 2013 at 08:20 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
As everyone here pointed out, there it no property to change selection color, but there is always a work around!
My solution is not complete, as I could only spend 20min on this.
The only problem that I need to find is if the selection contains vbNewLine, in other words if you select 2 (or more) lines it will not select properly.
How to fix this would be to verify if how many vbNewLine the selected text has, and then create a different picturebox (picbox array) for each line so it looks exactly like a real selection.
But anyways, have a look and play with it, if its too hard well at least you tried, I might give it another shot in the next couple days.
Also, to change the selection color you need to change the picture1.backcolor.
Note: You can delete the commandbuttons, I noticed I did not delete them!
Actually, Max, I switched over to a regular Textbox as it already highlights in dark blue. Also, the regular Textbox has all the properties I need for the project I'm working on. I can still do all the editing features that I want like Undo, Redo, Cut, Copy, Paste, Delete, Select All, Find, Find Next, and Replace. Of course I have to code for these but I had to code for these anyway with a RichTextBox.
Let me ask you a question. What happens if you start at any given point in the text and drag the mouse over the text to another point. Will it highlight in dark blue with white text?
EDIT: I ran your code. Not too crazy about it as I don't understand your method. When I drag over text in the textbox it totally covers the text in dark blue.
What gets me is why did MS design the regular textbox to highlight with white text on dark blue and for the rich text box it is simply inverted text on black. I noticed that when you select lines in the VB design mode it does white on dark blue even if the text is colored. Wonder what control they used for the editor.
I'm sure that I had resolved this issue some time back. I can just see it in my mind that LaVolpe and I spent several days on this when finally he came up with a solution. I seem to remember it involved using APIs like DrawText and figuring out what the overall area is that was selected and coloring that in dark blue then drawing text over it in white. Now if I can find my text search app I could just select a drive and search for "DrawText". It finds text within files. Oh, where did I put that app.
Last edited by jmsrickland; Jun 23rd, 2013 at 02:03 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Ya I'm not too crazy about it to haha, but I was just trying to make up something.
It highlights the text in dark blue (on my pc anyways).
If I change the picture1.backcolor it will select in that color.
I thought that's what you were trying to do, make a function to change selection color, so that's kind of what I did.
It's all good I would probably make my own usercontrol for this instead.
I see that you used a textbox instead, so I won't bother trying to get my code to work properly
(Not related to this Thread)
Have you got your chat program "sound wave" to work properly, like you wanted?
Whenever you do I want to have a little demo of it, if possible of course.
I have a chat application that shows the sine wave of the messages sent from one user to another. It is not really in real-time however. It works by sending the sound bytes to the other user and that app takes the sound data and converts it to a sine wave on a picturebox that is hidden under another picturebox. Then as the sound is being played back the top picturebox moves from left to right across the under picturebox revealing the sine wave in sync with the sound as it is being heard. This gives the appearance of real-time although it isn't.
I have another application that allows talking into a mic and showing the sine wave in real time but this only works on the same application. The problem here is I haven't yet figured out how to send the sound and produce the sine wave in real time on the receiving app.
I have a third application that allows chat in real time but doesn't display any sine wave.
So, I have the ingredients; I just don't have the recipe to put it all together.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.