EM_HIDESELECTION & the RichTextBox
Hi, have found a huge amount of code in this forum dealing
with creating color syntax editors.The general concensus is not to
make one from scratch but to rather use/extend the RichTextBox
control for this purpose. Sample code provided by members such
as Megatron and BuggyProgrammer demonstrate the
fundamentals of syntax highlighting. Other members imroved
upon these basics with a wide variety of nice features.
There is one problem however that nobody seems to have
successfully addressed, and that is the visual flicker caused by
having to reformat text as the user is typing. Various attempts
to minimize this visual annoyance have been made with varying
degress of success (none of them completely successful). Some
examples include:
* Using the LockWindowUpdate () from the Win32 API.
* Only reformatting text which is not of the desired format.
* Reformatting the text in an offscreen buffer and 'streaming'
it back into the control.
These attempts are definately good attempts, but the end result
still lacks a professional looking quality. The flicker problem seems
to stem from automating the selecting (highlighting) of text (not
the actual reformating itself). I tried to test this hypothesis by
sending a EM_HIDESELECTION message to the control but it
seemed to have no affect. Upon further investigation (using
MS Spy++) I discovered that the control was simply not
interpreting EM_HIDESELECTION, thus leading me to believe
that VBs RichTextBox control is an extended RichEdit control
whose windowProc () is sending certain messages into a black
hole.
I would really like to know if anybody has found a solution
to this problem (or even a way to get the EM_HIDESELECTION
message to be recognized). I would also like to know if anybody
has had an positive experiences with creating a pure Win32
RichEdit control on a VB Form and making it useful (through
messages I would presume).
Thanks,
-CC
Subclass Theory Tested...
Just thought I would update you. I made a pretty nice
subclasser to tackle my theory of forcing a double-buffer of
some sort. Here it is if you are interested:
http://www.vbforums.com/showthread.p...hreadid=201650
Anyhow, I guess I should have used Spy++ first because the
WM_PAINT messages have an HDC value of '0'... nothing much
I can do with that. I tried eliminating WM_PAINT messages while
performing color-coding... but there was still some flicker. Why?
WM_PAINT is not called in many instances (rendering happens
directly without any paint messages).
So, while I got to make a great subclasser that facilitated the
creation of all sorts of useful components for me... I also had
the privilage of demonstrating the futility of trying to turn the RTB
into a high quality color syntax editor. Live and learn I suppose.
RICK BULL, I really really really hate using 3rd party components.
As soon as they are no longer made anymore you're stuck (not
to mention you have no control over the bugs).
Now for the good news. I did some preliminary experiments and
discovered that with a little subclassing the PictureBox control
of all things will make a fantastic color editor (very high quality).
The downside is that there is alot of work involved in making
this a fully functional editor (let alone a color editor).
If anybody would like to help me develop this control, now would
be a great time to speak up. Some benefits to helping me with
this are:
* The control gets completed that much quicker.
* You know the ins and outs of the control.
* You get a really good control in the end!
* We can finally put RTB hell to death (along with any 3rd
party-were-gonna-dissappear-on-you temptations such as
the 'codemax' control for which no links work against
anymore).
Thanks,
-CC