PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: TabStop + MultiLine <> Shift+Tab  (Read 395 times)

Anonymous

  • Guest
TabStop + MultiLine <> Shift+Tab
« on: April 02, 2005, 05:20:23 AM »

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
Logged

Dominic Sexton

  • Guest
TabStop + MultiLine <> Shift+Tab
« Reply #1 on: August 25, 2005, 08:09:23 PM »

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
Logged

TechSupport

  • Guest
TabStop + MultiLine <> Shift+Tab
« Reply #2 on: August 26, 2005, 12:46:01 AM »

Add the following code to the WM_KEYDOWN message for your multiline textbox:
Code: [Select]

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
Logged

Dominic Sexton

  • Guest
TabStop + MultiLine <> Shift+Tab
« Reply #3 on: August 26, 2005, 07:14:52 AM »

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.

Code: [Select]

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
Logged

TechSupport

  • Guest
TabStop + MultiLine <> Shift+Tab
« Reply #4 on: August 26, 2005, 10:37:01 AM »

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.
Logged