1. Win32Lib - addStyle/removeStyle

Anyone have any experience with addStyle/removeStyle?  What I'm wanting 
to do is add/remove the ES_READONLY style from a rich edit during 
program execution.

When I use these routines nothing happens.  I've tried using setEnable() 
but if the control is disabled the scroll bar is also disable, therefore 
the user cannot scroll down through the text.

Any suggestions?

Thanks!

Jonas

new topic     » topic index » view message » categorize

2. Re: Win32Lib - addStyle/removeStyle

----- Original Message -----
From: "Jonas Temple" <jtemple at yhti.net>
To: "EUforum" <EUforum at topica.com>
Subject: Win32Lib - addStyle/removeStyle


>
> Anyone have any experience with addStyle/removeStyle?  What I'm wanting
> to do is add/remove the ES_READONLY style from a rich edit during
> program execution.
>
> When I use these routines nothing happens.  I've tried using setEnable()
> but if the control is disabled the scroll bar is also disable, therefore
> the user cannot scroll down through the text.
>
> Any suggestions?

I'm afraid that this is the way that the richedit control, as supplied by
Microsoft, works. Once its read-only style is set at creation time, it
cannot be changed during run-time.

One trick to get around this is to use two controls, identical to each other
except the read-only status. When you need to switch to read-only, copy the
current text to the read-only control, hide the read-write control and make
the read-only control visible. When you need to switch back, reverse the
procedure.

----------------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib - addStyle/removeStyle

On Thu, 13 Mar 2003 07:48:09 +1100, Derek Parnell <ddparnell at bigpond.com> 
wrote:

>
> ----- Original Message -----
> From: "Jonas Temple" <jtemple at yhti.net>
> To: "EUforum" <EUforum at topica.com>
> Subject: Win32Lib - addStyle/removeStyle
>
>
>> Anyone have any experience with addStyle/removeStyle?  What I'm wanting
>> to do is add/remove the ES_READONLY style from a rich edit during
>> program execution.
>>
>> When I use these routines nothing happens.  I've tried using setEnable()
>> but if the control is disabled the scroll bar is also disable, therefore
>> the user cannot scroll down through the text.
>>
>> Any suggestions?

Actually there is another method that I use that has the same effect.

procedure KeyPress_RE(integer self, integer event, sequence parms)
	if equal(getUserProperty(self, "ReadOnly"), {True}) then
		returnValue(-1)
      end if
end procedure
setHandler(RE, w3HKeyPress, routine_id("KeyPress_RE"))
defineUserProperty(RE, "ReadOnly", False)

. . . if NeedsReadOnly then
       setUserProperty(RE, "ReadOnly", True)
   end if

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib - addStyle/removeStyle

Well actually...

You can acheive this effect via sendMessage.

Enable read-only:
junk = sendMessage(RichEditID, EM_SETREADONLY, 1, 0)

Disable read-only:
junk = sendMessage(RichEditID, EM_SETREADONLY, 0, 0)


Regards, 
   Robert  Szalay

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib - addStyle/removeStyle

On Thu, 13 Mar 2003 04:59:00 +0000, Robert Szalay <robsz1 at hotpop.com> 
wrote:

>
> Well actually...
>
> You can acheive this effect via sendMessage.
>
> Enable read-only:
> junk = sendMessage(RichEditID, EM_SETREADONLY, 1, 0)
>
> Disable read-only:
> junk = sendMessage(RichEditID, EM_SETREADONLY, 0, 0)
>

Well, there's yet another thing that I didn't know about. Thanks Robert.



-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu