Keypress event in win32

Iv been looking on google for the past hour or so, and it is hard to belive how uncommon this question is. I want to know how to tell when a key is pressed inside of an rich editbox. I am creating a application IDE and I am currently working on the syntax highlighing portion of the code. Rather than re-formating all of the text on a fixed time table, I want to only format the line that the cursor is on, and only do it when the text changes. If there is a better way to go about doing that, please let me know. Thanks.
Iv been looking on google for the past hour or so, and it is hard to belive how uncommon this question is. I want to know how to tell when a key is pressed inside of an rich editbox. I am creating a application IDE and I am currently working on the syntax highlighing portion of the code. Rather than re-formating all of the text on a fixed time table, I want to only format the line that the cursor is on, and only do it when the text changes. If there is a better way to go about doing that, please let me know. Thanks.



What about WM_CHAR? http://msdn.microsoft.com/en-us/library/ms646276(VS.85).aspx
I tryed that, but it only works when the window has focus, not the editbox. Anyway, I found out how to fix the issue. For rich textboxes you need ot sent them a EM_SETEVENTMASK with the lParam as ENM_CHANGE to get the EN_CHANGE message event to work for them. Thanks anyway though. Hey, I have another question, and it dosnt feel right to create another whole topic just for it. If you push the "tab" key on the keybord it will inset a tab, my problem is that this "tab" is out of sync with the rest of the characters, it is too short for three spaces to cover, and too long for two, it is odd. Well I'm using code blocks to program and it lets you specify the length of tabs, I am wondering if this affect can be applyed to a rich editbox as well. Thanks
The default font is proportional. Get the control to use one with a fixed pitch.
subclassing the window (your textbox) is the infallible solution here

more information on subclassing:
http://msdn.microsoft.com/en-us/library/ms633570%28v=vs.85%29.aspx#subclassing_window
Last edited on
I assume that you mean that by monitoring the keypress event and looking for the '\t' key, and then simply replacing that with X many spaces. If so that that would be an realy good idea, apart from pasting. If the user pastes a TAB key, it will stay a TAB, even though when you type TAB it will be the amount of spaces you specified.
Both the Rich Edit and the Edit control know how to handle tab chars (\t)

Andy
Topic archived. No new replies allowed.