some applications support overwrite mode in edit controls. you can toggle with the "insert" key between insert and overwrite mode. i would like to know how to code this overwrite function.


i checked the winapi help file and i searched the forum with no success.
Posted on 2006-09-01 12:43:26 by diablo2oo2
If you want nonstandard behaviour in a standard control, subclass it :)
Iczelion's tutorials contains a simple example.
Posted on 2006-09-01 22:22:11 by Homer
yes, subclass your Edit box, and only pre-process WM_CHAR (or maybe WM_KEYDOWN, too).
When in "overwrite" mode, do:

.if msg==WM_CHAR && bIsOverwriteMode
invoke CallWindowProc,lpPrevWndFunc,hWnd,WM_KEYDOWN,VK_DELETE,0
.endif
invoke CallWindowProc,lpPrevWndFunc,hWnd,msg,wParam,lParam
ret
Posted on 2006-09-01 22:58:25 by Ultrano
Simply use Richedits instead of edits. Richedits support insert/overwrite modes with no additional programming, whatsoever.
Posted on 2006-09-03 01:22:57 by ti_mo_n
And what about nonstandard behaviour in a richedit?
Same deal - subclassing is the universal solution :)
Posted on 2006-09-04 02:20:41 by Homer
i know how to subclass a control. but how can i switch to this overwrite mode (see screenshot)?. i also know the iczelion tutorials. but there is not this "overwrite" method mentioned. thats why i asked here....
Posted on 2006-09-06 10:23:41 by diablo2oo2
I doubt the control there is RichEdit. It isn't an Edit, either. KetilO's RAEdit and Scintilla behave/look like that.

You can still make a simple Edit control behave like that, following my simple code - and adding a trick to mark the next char to overwrite.
Posted on 2006-09-06 16:09:29 by Ultrano
You'll also need to CreateCaret to make the caret change to block shape...
Posted on 2006-09-06 16:56:23 by f0dder