Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 28 OCT 2006 10:53:20PM Richard Hunt wrote:

Version 7.2.1

I would like to select all text in an "EDIT LINE" control and also have the cursor position at the beginning of the text. I know this sounds simple although when I do it the way the "SELECTION" property help says to do it, it does not work. It always leaves the cursor on the right side of the selected text. I want it on the left side of the selected text. Am I doing it wrong or is the "SELECTION" property flawed?

Return value is startpos:@FM:length, where startpos is starting position, and length is the length of the selection. The length can be negative to select the text from the right to the left, leaving the insertion point at the start of the selected text.


At 30 OCT 2006 12:58PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:

Richard,

This should do it:

Set_Property(@Window[/color]:[/color]".EDITLINE"[/color], [/color]"SELECTION"[/color], -[/color]1[/color]:[/color]@FM[/color]:[/color]2[/color])[/color][/color][/size]         
               

kfournier@srpcs.com

SRP Computer Solutions, Inc.


At 30 OCT 2006 01:41PM Richard Hunt wrote:

Kevin,

I tried that and got all the text highlighted, although the "insertion point" was at the end of the string of characters and not at the beginning. Could you try it and see what results you get?


At 30 OCT 2006 03:39PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:

Richard,

As it turns out, I was testing on an EDITBOX, not an EDITLINE. My guess is that standard Windows editlines will only only allow you to programmatically backwards-select text in a multilined edit box. For EDITLINEs we have to get tricky. First, open SYSPROCS*DLL_USER32 and add this line to the bottom of it:

  [/color][/size]     
<code>
VOID STDCALL keybd_event(BYTE, BYTE, ULONG, ULONG) As KeyboardEvent[/color][/size] 
           
               
Next, execute RUN DECLARE_FCNS "DLL_USER32" from a command line. This will create a stored procedure called KeyboardEvent which will call the keybd_event WinAPI.

Now, add the following defines in an insert or directly in your stored procedure. They define the key codes and a flag.


<code>
Equ [/color]VK_HOME$ [/color]to             [/color]0x0024  [/color]; [/color]// Virtual key code for the HOME key 
[/color]Equ [/color]VK_SHIFT$ [/color]to            [/color]0x0010  [/color]; [/color]// Virtual key code for the SHIFT key 
[/color]Equ [/color]KEYEVENT_KEYUP$ [/color]to      [/color]2[/color][/color][/size]         
               

Finally, here is the logic to do what you want.

// Move to the end 
[/color]Set_Property([/color]@Window[/color]:[/color]".EDL_TEST"[/color], [/color]"SELECTION"[/color], [/color]9999[/color]:[/color]@FM[/color]:[/color]9999[/color]) 
[/color] 
[/color]// Simulate keyboard input 
[/color]KeyboardEvent(VK_SHIFT$, [/color]0[/color], [/color]0[/color], [/color]0[/color])                   ; [/color]// SHIFT down 
[/color]KeyboardEvent(VK_HOME$, [/color]0[/color], [/color]0[/color], [/color]0[/color])                    ; [/color]// HOME down 
[/color]KeyboardEvent(VK_HOME$, [/color]0[/color], KEYEVENT_KEYUP$, [/color]0[/color])      ; [/color]// HOME up 
[/color]KeyboardEvent(VK_SHIFT$, [/color]0[/color], KEYEVENT_KEYUP$, [/color]0[/color])     ; [/color]// SHIFT up[/color][/color][/size]         
               

Essentially, we move the selection to the end of the editline, then we simulate keyboard activity for select backwards to the beginning.

Hope this helps.

kfournier@srpcs.com

SRP Computer Solutions, Inc.


At 30 OCT 2006 03:41PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:

Richard,

I should further point out that the KeyboardEvent approach requires the EDITLINE in question to have focus. Otherwise, the keyboard input will be sent to whatever other control has focus.

kfournier@srpcs.com

SRP Computer Solutions, Inc.


At 30 OCT 2006 04:23PM dbakke@srpcs.com's Don Bakke wrote:

As it turns out, I was testing on an EDITBOX, not an EDITLINE.

Hmmm…couldn't Richard also set a style bit to resolve the way the SELECTION property behaves?

dbakke@srpcs.com

SRP Computer Solutions, Inc.


At 30 OCT 2006 05:21PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:

Don,

Indeed, the the EDITLINE and EDITBOX controls are both EDIT controls – the only difference being that the EDITBOX has the ES_MULTILINE style. So, Richard could conceivably add this style bit to his editlines. However, that means his editlines would also take on other undesirable features such as word wrapping, etc.

The keyboard input method allows him to keep his singleline EDITLINES

kfournier@srpcs.com

SRP Computer Solutions, Inc.


At 30 OCT 2006 06:17PM Richard Hunt wrote:

Wow!!! I am speachless… uhhh… thank you!

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/dba72e9b2e8229e585257216000fdeda.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1