1. [WIN] richedit: how to programmatically select text?

I tried to select text in a richedit (using Win32Lib 59.1) by using
setIndex, & it wouldn't work;  is this a bug that's corrected in more recent
versions, or is there an alternate way to programmatically select text in a
richedit control?

Dan Moyer

new topic     » topic index » view message » categorize

2. Re: [WIN] richedit: how to programmatically select text?

danielmoyer wrote:
> 
> I tried to select text in a richedit (using Win32Lib 59.1) by using
> setIndex, & it wouldn't work;  is this a bug that's corrected in more recent
> versions, or is there an alternate way to programmatically select text in a
> richedit control?

Nothing new or fixed here.

   setIndex(myRichEdit, {start, stop} )

What happens when you try? 

-- 
Derek Parnell
Melbourne, Australia

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

3. Re: [WIN] richedit: how to programmatically select text?

> posted by: Derek Parnell <ddparnell at bigpond.com>
>
> danielmoyer wrote:
> >
> > I tried to select text in a richedit (using Win32Lib 59.1) by using
> > setIndex, & it wouldn't work;  is this a bug that's corrected in more
recent
> > versions, or is there an alternate way to programmatically select text
in a
> > richedit control?
>
> Nothing new or fixed here.
>
>    setIndex(myRichEdit, {start, stop} )
>
> What happens when you try?
>
> -- 
> Derek Parnell
> Melbourne, Australia
>

The text between start & stop is not selected (ie, not high-lighted).

In order to experiment with richedit to see if I could use it, I went into
generic.exw & added an "info" button to the tool bar, & put some text in the
richedit like this:

setText(GText, "this is a line\nthis is a second line\n" &
   "select some text & click the right-most question mark\n" &
   "to see the index of start/finish")

And then in the click on that button event did this:


-- richedit info... behavior
procedure onClick_ToolInfo(integer self, integer even, sequence parms)
    atom found

    found = findText(GText, "click", 0, findDown + findMatchCase +
findWholeWord)
    setIndex(GText, {found,  found + length("click")})

       setText({GStatus,2},"")
       setText({GStatus,2},sprint(found))


end procedure
setHandler (ToolInfo, w32HClick, routine_id( "onClick_ToolInfo" ))

I thought the above should have high-lighted "click" when the button in the
toolbar was clicked on, but while the status bar showed the correct position
of the word, it was not high-lighted.

Using:
Win98 1st ed, Eu 2.3, Win32Lib 59.1.

Dan

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

4. Re: [WIN] richedit: how to programmatically select text?

danielmoyer wrote:
> 
> 
> > posted by: Derek Parnell <ddparnell at bigpond.com>
> >
> > danielmoyer wrote:
> > >
> > > I tried to select text in a richedit (using Win32Lib 59.1) by using
> > > setIndex, & it wouldn't work;  is this a bug that's corrected in more
> recent
> > > versions, or is there an alternate way to programmatically select text
> in a
> > > richedit control?
> >
> > Nothing new or fixed here.
> >
> >    setIndex(myRichEdit, {start, stop} )
> >
> > What happens when you try?
> >
> > -- 
> > Derek Parnell
> > Melbourne, Australia
> >
> 
> The text between start & stop is not selected (ie, not high-lighted).
> 
> In order to experiment with richedit to see if I could use it, I went into
> generic.exw & added an "info" button to the tool bar, & put some text in the
> richedit like this:
> 
> setText(GText, "this is a line\nthis is a second line\n" &
>    "select some text & click the right-most question mark\n" &
>    "to see the index of start/finish")
> 
> And then in the click on that button event did this:
> 
> 
> -- richedit info... behavior
> procedure onClick_ToolInfo(integer self, integer even, sequence parms)
>     atom found
> 
>     found = findText(GText, "click", 0, findDown + findMatchCase +
> findWholeWord)
>     setIndex(GText, {found,  found + length("click")})
> 
>        setText({GStatus,2},"")
>        setText({GStatus,2},sprint(found))
> 
> 
> end procedure
> setHandler (ToolInfo, w32HClick, routine_id( "onClick_ToolInfo" ))
> 
> I thought the above should have high-lighted "click" when the button in the
> toolbar was clicked on, but while the status bar showed the correct position
> of the word, it was not high-lighted.
> 
> Using:
> Win98 1st ed, Eu 2.3, Win32Lib 59.1.

Either set focus to the richedit before selecting text, or create the
richedit control with the ES_NOHIDESEL flag.

-- 
Derek Parnell
Melbourne, Australia

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

5. Re: [WIN] richedit: how to programmatically select text?

You can either do that, or you can use this method of selecting text.

include win32lib.ew
constant mywin = create(Window,"RichEdit Text",0,Default,Default,300,200,0),
                riched = create(RichEdit,"",mywin,0,0,300,200,0),
                mFile = create(Menu,"&File",mywin,0,0,0,0,0),
                mSelTex = create(MenuItem,"&Select Text",mFile,0,0,0,0,0),
                mSep1 = create(MenuItem,"-",mFile,0,0,0,0,0),
                mExit = create(MenuItem,"E&xit",mFile,0,0,0,0,0)

procedure onResize_mywin(integer id, integer event, sequence param)
    param = getClientRect(mywin)
    setRect(riched,0,0,param[3],param[4],1)
end procedure
setHandler(mywin,w32HResize,routine_id("onResize_mywin"))

procedure onOpen_mywin(integer id, integer event, sequence param)
    setText(riched,"Hello World, this is a Select Text demo")
end procedure
setHandler(mywin,w32HOpen,routine_id("onOpen_mywin"))

procedure onClick_mSelText(integer id, integer event, sequence param)
    object void
    void = sendMessage(riched,WM_SETSEL,0,15)
end procedure
setHandler(mSelText,w32HClick,routine_id("onClick_mSelText"))

procedure onClick_mExit(integer id, integer event, sequence param)
    closeWindow(mywin)
end procedure
setHandler(mExit,w32HClick,routine_id("onClick_mExit"))

WinMain(mywin,Normal)


This code is untested, seeing as I'm now on Linux, and no longer have 
access to a Windows Computer.  But if I'm right, this should work, minus 
the fact, that it might be another Window Message Constant, but it 
should be something similar to that.

EuMario

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

6. Re: [WIN] richedit: how to programmatically select text?

Oy,  too simple (not to mention reasonable:  setting focus is what an app
user would normally have to do first, too, before they could select
anything)!  :)

Thanks Derek!
Dan

----- Original Message ----- 
From: "Derek Parnell" <guest at RapidEuphoria.com>
To: <EUforum at topica.com>
Sent: Monday, August 16, 2004 11:37 PM
Subject: Re: [WIN] richedit: how to programmatically select text?


>
>
> posted by: Derek Parnell <ddparnell at bigpond.com>
>
> danielmoyer wrote:
> >
> >
> > > posted by: Derek Parnell <ddparnell at bigpond.com>
> > >
> > > danielmoyer wrote:
> > > >
> > > > I tried to select text in a richedit (using Win32Lib 59.1) by using
> > > > setIndex, & it wouldn't work;  is this a bug that's corrected in
more
> > recent
> > > > versions, or is there an alternate way to programmatically select
text
> > in a
> > > > richedit control?
> > >
> > > Nothing new or fixed here.
> > >
> > >    setIndex(myRichEdit, {start, stop} )
> > >
> > > What happens when you try?
> > >
> > > -- 
> > > Derek Parnell
> > > Melbourne, Australia
> > >
> >
> > The text between start & stop is not selected (ie, not high-lighted).
> >
> > In order to experiment with richedit to see if I could use it, I went
into
> > generic.exw & added an "info" button to the tool bar, & put some text in
the
> > richedit like this:
> >
> > setText(GText, "this is a line\nthis is a second line\n" &
> >    "select some text & click the right-most question mark\n" &
> >    "to see the index of start/finish")
> >
> > And then in the click on that button event did this:
> >
> >
> > -- richedit info... behavior
> > procedure onClick_ToolInfo(integer self, integer even, sequence parms)
> >     atom found
> >
> >     found = findText(GText, "click", 0, findDown + findMatchCase +
> > findWholeWord)
> >     setIndex(GText, {found,  found + length("click")})
> >
> >        setText({GStatus,2},"")
> >        setText({GStatus,2},sprint(found))
> >
> >
> > end procedure
> > setHandler (ToolInfo, w32HClick, routine_id( "onClick_ToolInfo" ))
> >
> > I thought the above should have high-lighted "click" when the button in
the
> > toolbar was clicked on, but while the status bar showed the correct
position
> > of the word, it was not high-lighted.
> >
> > Using:
> > Win98 1st ed, Eu 2.3, Win32Lib 59.1.
>
> Either set focus to the richedit before selecting text, or create the
> richedit control with the ES_NOHIDESEL flag.
>
> -- 
> Derek Parnell
> Melbourne, Australia
>
>
>
>

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

7. Re: [WIN] richedit: how to programmatically select text?

Mario,

Thanks for trying in the blind; WM_SETSEL isn't it, & WM_SETFOCUS didn't
work, & I couldn't find any other constant that looked like it would be the
one either..

But Derek's setFocus() suggestion worked fine.

Dan

----- Original Message ----- 
From: "Mario Steele" <eumario at tuscanchat.com>
To: <EUforum at topica.com>
Sent: Tuesday, August 17, 2004 12:50 AM
Subject: Re: [WIN] richedit: how to programmatically select text?


>
>
> You can either do that, or you can use this method of selecting text.
>

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

8. Re: [WIN] richedit: how to programmatically select text?

Mario,

Thanks for trying in the blind; WM_SETSEL isn't it, & WM_SETFOCUS didn't
work, & I couldn't find any other constant that looked like it would be the
one either..

But Derek's setFocus() suggestion worked fine.

Dan

----- Original Message ----- 
From: "Mario Steele" <eumario at tuscanchat.com>
To: <EUforum at topica.com>
Sent: Tuesday, August 17, 2004 12:50 AM
Subject: Re: [WIN] richedit: how to programmatically select text?


>
>
> You can either do that, or you can use this method of selecting text.
>

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

9. Re: [WIN] richedit: how to programmatically select text?

Mario,

Thanks for trying in the blind; WM_SETSEL isn't it, & WM_SETFOCUS didn't
work, & I couldn't find any other constant that looked like it would be the
one either..

But Derek's setFocus() suggestion worked fine.

Dan

----- Original Message ----- 
From: "Mario Steele" <eumario at tuscanchat.com>
To: <EUforum at topica.com>
Sent: Tuesday, August 17, 2004 12:50 AM
Subject: Re: [WIN] richedit: how to programmatically select text?


>
>
> You can either do that, or you can use this method of selecting text.
>
> }}}
<eucode>
> include win32lib.ew
> constant mywin = create(Window,"RichEdit
Text",0,Default,Default,300,200,0),
>                 riched = create(RichEdit,"",mywin,0,0,300,200,0),
>                 mFile = create(Menu,"&File",mywin,0,0,0,0,0),
>                 mSelTex = create(MenuItem,"&Select Text",mFile,0,0,0,0,0),
>                 mSep1 = create(MenuItem,"-",mFile,0,0,0,0,0),
>                 mExit = create(MenuItem,"E&xit",mFile,0,0,0,0,0)
>
> procedure onResize_mywin(integer id, integer event, sequence param)
>     param = getClientRect(mywin)
>     setRect(riched,0,0,param[3],param[4],1)
> end procedure
> setHandler(mywin,w32HResize,routine_id("onResize_mywin"))
>
> procedure onOpen_mywin(integer id, integer event, sequence param)
>     setText(riched,"Hello World, this is a Select Text demo")
> end procedure
> setHandler(mywin,w32HOpen,routine_id("onOpen_mywin"))
>
> procedure onClick_mSelText(integer id, integer event, sequence param)
>     object void
>     void = sendMessage(riched,WM_SETSEL,0,15)
> end procedure
> setHandler(mSelText,w32HClick,routine_id("onClick_mSelText"))
>
> procedure onClick_mExit(integer id, integer event, sequence param)
>     closeWindow(mywin)
> end procedure
> setHandler(mExit,w32HClick,routine_id("onClick_mExit"))
>
> WinMain(mywin,Normal)
> </eucode>
{{{

>
> This code is untested, seeing as I'm now on Linux, and no longer have
> access to a Windows Computer.  But if I'm right, this should work, minus
> the fact, that it might be another Window Message Constant, but it
> should be something similar to that.
>
> EuMario
>
>
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu