TAB

Category: Keyboard

Date: 02-16-2022

Return to Index


 
'None of the common controls respond to the TAB key, except as a way
'to move focus from one control to another.
 
'TAB characters can be placed programmatically into a textbox, but the
'single line textbox will not correctly display a TAB character whereas
'the multi-line textbox will correctly display TAB characters.  With
'subclassing, however, an application can allow a user to place TABs into
'a multiline textbox.
 
'The RichEdit control allows users to directly input TAB characters using
'the Ctrl-I key shortcut. But leaving a RichEdit control (changing focus
'to another control) requires subclassing of the RichEdit control.
 
'Note that PowerBASIC provides the $Tab equate.
 
'Primary Code:
'To put TABs in a textbox or RichEdit control programmatically, do something like this:
Control Set Text hDlg, 200, "Washington" + $Tab + "Ohio" + "Utah" + $Tab + "Pennsylvania"
 
'Compilable Example:  (Jose Includes)
'This example programmatically places TABs into a textbox.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Include "Win32API.inc"
Global hDlg as Dword
 
Function PBMain() As Long
   Dialog New Pixels, 0, "Test Code",300,300,200,250, %WS_OverlappedWindow To hDlg
   Control Add Button, hDlg, 100,"Push", 50,10,100,20
   Control Add TextBox, hDlg, 200,"Washington Ohio" + $crlf + "Utah Pennsylvania", _
      10,40,180,200, %WS_Border Or %ES_WantReturn Or %ES_Multiline
   Dialog Show Modal hDlg Call DlgProc
End Function
 
CallBack Function DlgProc() As Long
   If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
      Control Set Text hDlg, 200, "Washington" + $Tab + "Ohio" + $crlf + "Utah" + $Tab + $Tab + "Pennsylvania"
   End If
End Function
 
'gbs_00196
'Date: 03-10-2012


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm