Hi,
I have a question... I have a text control. It has Tab Stop and Multi Line. After adding Multi Line, I can't Tab or Shift+Tab out of the control. I put a WM_CHAR in there to check for Tab (9) and SetFocus when I reach it, but I can't seem to catch Shift+Tab to go backwards.
Is there a way to enable this?
Thanks!
John
I have just come across the same problem. Did you find a solution?
I have tried a completely new project just with 4 text boxes on a form and setting one to multiline. Like you describe the focus will tab into the multiline box but not out.
I have evn tried making the project and compliling under both Win 98 and XP Home with no change
Add the following code to the WM_KEYDOWN message for your multiline textbox:
Function FORM1_TEXT2_WM_KEYDOWN ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle in Control
nVirtKey As Long, _ ' virtual key code
lKeyData As Long _ ' key data
) As Long
Select Case nVirtKey
Case %VK_TAB
If (GetKeyState(%VK_SHIFT) And &H8000) = 0 Then
SetFocus GetNextDlgTabItem( hWndForm, hWndControl, 0) 'Move focus to next control
Else 'If Shift is pressed -
SetFocus GetNextDlgTabItem( hWndForm, hWndControl, -1) 'Move focus to previous control
End If
Function = 0 : Exit Function
End Select
End Function
Thanks Paul that does the trick (had me baffled yesterday!). Do you know why it doesn't work without handling the tab key manually - is it a Windows or a PB feature?
I have made a small addition to select the text in the tabbed to control as would usually happen.
Local SelStart As Long, SelEnd As Long
Local hCtrl As Long
Select Case nVirtKey
Case %VK_TAB
If (GetKeyState(%VK_SHIFT) And &H8000) = 0 Then
hCtrl = GetNextDlgTabItem( hWndForm, hWndControl, 0) 'Get handle of next Tab control
Else 'If Shift is pressed -
hCtrl = GetNextDlgTabItem( hWndForm, hWndControl, -1) 'Get handle of previous Tab control
End If
SetFocus hCtrl 'set focus to control
'select text in control
SendMessage hCtrl, %EM_GETSEL, VarPtr(SelStart), VarPtr(SelEnd) 'grab start/end pos
SendMessage hCtrl, %EM_SETSEL, SelStart, SelEnd 'to reset pos/selection in text
SendMessage hCtrl, %EM_SCROLLCARET, 0, 0 'make sure caret is scrolled into view..
Function = 0 : Exit Function
End Select
I found the text selection code in a post of Borje's on the PB forum
http://www.powerbasic.com/support/forums/Forum6/HTML/003381.html
To be honest, I am not sure why this happens for multiline text boxes. I assume that it is a Windows thing but I don't know for a 100%. PowerBASIC DDT may be different because that uses the Windows Dialog Engine whereas FireFly uses pure Win32 window creation methods.