0

I have three questions about editbox control in WINAPI (i can't find information on msdn about this) 1. How to disable moving typeing cursor with mouse, arrows, backspace in editbox ? I want to make typing like in command line in dos, but with out backspace.

  1. Can I write some piece of text with red color, and another with blue ?

  2. How to write to editbox control from another thread ?

piotrek
  • 1,333
  • 4
  • 17
  • 35

1 Answers1

0
  1. Make it read-only (ES_READONLY) & manually intercept keystrokes and append only those you want to.
  2. No, you would need to use a RICHEDIT class for that and use RTF. (You could owner draw a normal EDIT window but that would not be much fun)
  3. SendMessage with WM_SETTEXT (Or EM_SETTEXTEX / EM_REPLACESEL if you use a RICHEDIT)

Why not use a Console?

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • It must be in window :/ To answer 1. - Are there any other option instead of ES_READONLY and intercept keystrokes ? I asking beacouse in my language there is a lot of combinations on keyboard to make variuos characters. – piotrek May 14 '10 at 12:16
  • You can intercept WM_CHAR & examine its value, discarding if appropriate. – Alex K. May 14 '10 at 12:31
  • Thx. Can I disable mouse selection in richedit ? I append char with this code: SendMessage(richEdit, EM_SETSEL, - 1, 0); SendMessage(richEdit,EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); SendMessage(richEdit, EM_REPLACESEL, (WPARAM)0, (LPARAM)(LPSTR)msg); But when I click on richedit with mouse this code doesn't work :/ – piotrek May 14 '10 at 14:11
  • You could discard mouse messages, WM_LBUTTONDOWN et al. – Alex K. May 14 '10 at 14:38