Page 1 of 1

UpDown->Tab Behavior

Posted: 24 Nov 2009, 12:49
by Mex
Hi

Is following behavior possible with yor TextBox (Like MSForms TextBox)

1) TextBox with Multiline enabled

Lets say there are 5 lines text in textbox.
Cursor is on first line, user presses Down key on keyboard, cursor is moved to the next line.
When curos is on the last line and user presses Down, focus is sent to the next control (Like Tab)

BR;
Meelis

Re: UpDown->Tab Behavior

Posted: 24 Nov 2009, 14:03
by TiKu
There is no such built-in feature, but you can use the KeyDown event, the GetSelection method, the GetLineFromChar method and the GetLineCount method to check whether the cursor is in the last line. Then you should be able to fake a Tab key press using SendKeys or keybd_event or SendInput.

Re: UpDown->Tab Behavior

Posted: 24 Nov 2009, 14:19
by Mex
Hi Timo

Ok i found a solution.
Im using SendMessage APi and EM_LINEFROMCHAR message to find current line and then i set focus to previous or next textbox, when cursor is on last or first line.

What im also missing is Locked property like in MSForms TextBox.

One more thing i noticed - i think its not a bug but it works with MSForms controls.

Lets say i have 5 textboxes on PictureBox.
With MSForms controls when you press Tab key, focus is set to the next control. When last control is in focus then Tab press has no effect(goes not outside container)
but with your TextBox it goes outside the container.

Alles gute;
Meelis

Re: UpDown->Tab Behavior

Posted: 24 Nov 2009, 16:07
by TiKu
Mex wrote:Ok i found a solution.
Im using SendMessage APi and EM_LINEFROMCHAR message to find current line and then i set focus to previous or next textbox, when cursor is on last or first line.
So you are doing the same as I suggested in my previous post, but using the API. Internally, the TextBox methods that I mentioned also use SendMessage and EM_LINEFROMCHAR and so on.
Mex wrote:What im also missing is Locked property like in MSForms TextBox.
What does it do? I don't have any MS Office product, so I don't have MS Forms 2.0 to look it up myself. There's a ReadOnly property, maybe this is what you're looking for.
Mex wrote:One more thing i noticed - i think its not a bug but it works with MSForms controls.

Lets say i have 5 textboxes on PictureBox.
With MSForms controls when you press Tab key, focus is set to the next control. When last control is in focus then Tab press has no effect(goes not outside container)
but with your TextBox it goes outside the container.
I would call this a bug of MS Forms controls. The normal behavior of ActiveX controls is that the focus can go outside the container.

Re: UpDown->Tab Behavior

Posted: 24 Nov 2009, 16:57
by Mex
Hi

U can download http://www.deltmar.ee/riks/download/setuppad.exe
Microsoft ActiveX Control Pad, this setup contains MSForms controls.

Meelis

Re: UpDown->Tab Behavior

Posted: 24 Nov 2009, 22:58
by TiKu
It can't be installed on Windows 7 64 Bit.