I'm programming this program that when a specific work is typed into the edit control, it turns blue. But, just that one word. How would I go about doing this? Thanks!
I'm programming this program that when a specific work is typed into the edit control, it turns blue. But, just that one word. How would I go about doing this? Thanks!
1978 Silver Anniversary Corvette
Maybe a seperate thread running EM_FINDTEXT mesasages to a rich edit...............on a return > 0.....EM_SETCHARFORMAT to change text colour
What do you mean?
1978 Silver Anniversary Corvette
Assuming rich edit.... (you would need that for the text colour)
Create a worker thread to constantly scan your edit for certain key words....this can be done by sending (with SendMessage) EM_FINDTEXT messages......now if one is found the return is more than 0 (the first char of the found word)....use that and the length of the word to send an EM_SETSEL message and select the word....Now prepare a CHARFORMAT structure (for the colour) and send it with the wParam set to SCF_WORD | SCF_SELECTION........
I havent tried any of this, but I assume it should work.....
I would code an example to try it, but its 2AM and I have to be up in the morning.....
Hope it works
Okay, I haven't quite gotten into threads yet (I've been slacking in the WinAPI department ) but I'm going to go read about them and work in what you said. I'll come back with results/problems. Thanks, Fordy!
1978 Silver Anniversary Corvette
Another, brute-force, method using rich edit controls is to take the contents, parse for keywords and add syntax formatting for rtf - colours, fonts etc. Use the EditStreamCallback fn to fill the control using the EM_STREAMIN or EM_STREAMOUT messages.
There is an interesting tutorial (in assembly) about this subject on Iczelion's web site, the number 35.
http://win32asm.cjb.net
But it is not an easy task.
If you want to use such a control for an editor give a look at http://www.winmain.com/ (at this moment this site is down).
Fordy, do you really think I need to use threads? After all, the program is only an IDE and nothing will be needed to go on besides checking the rich edit for those certain words. So, do you think that using threads are necessary?
1978 Silver Anniversary Corvette
(this is not the previous Unregistered)
Are you then attempting to make a syntax-highlighting edit control?
If so, I can only say from my experience with using (end-user so far, but its my Summer project to make my own) slow implementations (presumably brute-force) of this that it is worth your time to make sure that you can refresh quickly enough.
Consider later that you may be doing additional processing to add word completion, funcion sig. messages , or further consider what happens when someone tries to load a 2000-line source document.
So what are you saying I do? Use a thread?Originally posted by Unregistered
(this is not the previous Unregistered)
Are you then attempting to make a syntax-highlighting edit control?
If so, I can only say from my experience with using (end-user so far, but its my Summer project to make my own) slow implementations (presumably brute-force) of this that it is worth your time to make sure that you can refresh quickly enough.
Consider later that you may be doing additional processing to add word completion, funcion sig. messages , or further consider what happens when someone tries to load a 2000-line source document.
1978 Silver Anniversary Corvette
Instead of using a thread you could subclass the rich edit control. Everytime a key is pressed you could run through a function to find and highlight the text.
- Sean
If cities were built like software is built, the first woodpecker to come along would level civilization.
Black Frog Studios