[comp.windows.ms.programmer] Read-only Edit Windows

whisd@sersun1.essex.ac.uk (Whiteside S D B) (06/06/91)

I had a query about Read-Only Edit windows.

Many thanks to all who sent me suggestions on how to implement them.

Following up on some of them, I have found one solution to the problem:

i)	Subclass the edit window (using SetWindowLong, GetWindowLong and 
CallWindowProc to insert your window procedure before the default one)

ii)	Trap WM_SETFOCUS messages and return 0 from them (refusing the change
focus request). This prevents any keyboard input from going to the
window

iii)	Trap WM_SETCUSOR messages to prevent the Caret cursor being drawn.
Make sure you set the cursor to some appropriate one otherwise you'll
inherit the last cursor used (e.g. a double-headed scrollbar cursor).

These measures work fine. They also allow you to switch the read-only
feature on and off - by testing a boolean condition in the 
setfocus and setcursor routines.

Many thanks,


Simon Whiteside.
 

jja@wsl.ie (John Allen on wsl) (06/12/91)

In article <5266@servax0.essex.ac.uk> whisd@essex.ac.uk (Whiteside S D B) writes:
>
>I had a query about Read-Only Edit windows.
>
>Many thanks to all who sent me suggestions on how to implement them.
>
>Following up on some of them, I have found one solution to the problem:
>
>i)	Subclass the edit window (using SetWindowLong, GetWindowLong and 
>CallWindowProc to insert your window procedure before the default one)
>

Forgive me if I'm missing something, but
what is wrong with

EnableWnd(hEditWnd, FALSE);    // can't edit
EnableWnd(hEditWnd, TRUE);    // can edit.

lalli@casee.enet.dec.com (06/13/91)

>Forgive me if I'm missing something, but
>what is wrong with

>EnableWnd(hEditWnd, FALSE);    // can't edit
>EnableWnd(hEditWnd, TRUE);    // can edit.

You happen to loose also the usage of the scrollbars.

Too bad isn't it ?

--
Didier Lalli				lalli@casee.enet.dec.com
Digital Equipment,
Centre Technique Europe S.A.R.L.        DTN 828-5423
B.P. 129 - Sophia Antipolis 	        Tel. +33 92 95 54 23
06561 Valbonne Cedex - France	        Fax  +33 93 65 41 58

bonneau@hyper.hyper.com (Paul Bonneau) (06/14/91)

In article <783@wsl.ie> jja@wsl.ie (John Allen on wsl) writes:
>In article <5266@servax0.essex.ac.uk> whisd@essex.ac.uk (Whiteside S D B) writes:
>>
>>I had a query about Read-Only Edit windows.
>>
>>Many thanks to all who sent me suggestions on how to implement them.
>>
>>Following up on some of them, I have found one solution to the problem:
>>
>>i)	Subclass the edit window (using SetWindowLong, GetWindowLong and 
>>CallWindowProc to insert your window procedure before the default one)
>>
>
>Forgive me if I'm missing something, but
>what is wrong with
>
>EnableWnd(hEditWnd, FALSE);    // can't edit
>EnableWnd(hEditWnd, TRUE);    // can edit.

If your edit is a scrollable (ES_AUTOHSCROLL or a multi line
edit for example), it is nice to be able to scroll it without
allowing the user to edit it.  Disbaling the edit, will
disable scrolling via the mouse or keyboard.

cheers - Paul Bonneau.