Author Topic: Remove Control from Tab-Order  (Read 127 times)

PaulSamuelson

  • Newbie
  • *
  • Posts: 38
Remove Control from Tab-Order
« on: December 10, 2018, 07:32:43 am »
Is there any way to remove a dialog control from the tab order? I have buttons that do not need to be accessible from the tab key.

Thanks,

Paul

td

  • Tech Support
  • *****
  • Posts: 2725
    • WinBatch
Re: Remove Control from Tab-Order
« Reply #1 on: December 10, 2018, 02:24:46 pm »
Code: Winbatch
;; User defined callback procedure that removes the tabstop style from the Cancel button
;; just before the dialog is displayed.
#DefineFunction RemoveStyle(hStyleEx,StyleEx_Event,StyleEx_Name,StyleEx_EventInfo,StyleEx_ChangeInfo)
   switch StyleEx_Event                                    
      case @deInit                                          
         
         ;;; Remove the tabstop from the Cancel button.
         hWnd = DialogControlGet(hStyleEx,"PushButton_Cancel",@dchWnd, 0)
         GWL_STYLE  = -16
         WS_TABSTOP = 65536
         dwStyle = DllCall('user32.dll', long:'GetWindowLongA', long:hWnd, long:GWL_STYLE)
         dwStyle &= (~WS_TABSTOP)
         DllCall('user32.dll',long:"SetWindowLongA",long:hWnd,long:GWL_STYLE,long:dwStyle)
         return(@retDefault)

   endswitch                                                
   return(@retDefault)
#EndFunction                                                

StyleExFormat=`WWWDLGED,6.2`

StyleExCaption=`WIL Dialog 1`
StyleExX=727
StyleExY=194
StyleExWidth=563
StyleExHeight=322
StyleExNumControls=002
StyleExProcedure=`RemoveStyle`
StyleExFont=`DEFAULT`
StyleExTextColor=`DEFAULT`
StyleExBackground=`DEFAULT,DEFAULT`
StyleExConfig=0
StyleExDPI=`192,10,20`

StyleEx001=`154,298,050,016,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
StyleEx002=`359,298,049,016,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("StyleEx")


 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

PaulSamuelson

  • Newbie
  • *
  • Posts: 38
Re: Remove Control from Tab-Order
« Reply #2 on: December 11, 2018, 01:34:08 pm »
I was hoping for a "tab order = -1" or something like that, but I will make that work.

Thanks,

Paul

td

  • Tech Support
  • *****
  • Posts: 2725
    • WinBatch
Re: Remove Control from Tab-Order
« Reply #3 on: December 11, 2018, 05:17:15 pm »
A six line cut and paste solution too much to handle?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

PaulSamuelson

  • Newbie
  • *
  • Posts: 38
Re: Remove Control from Tab-Order
« Reply #4 on: December 12, 2018, 06:49:03 am »
I made a function out of it, since I had dozens of controls to apply it to.

Consider it a feature request: a tab-order entry of 0 or -1 removes a control from the tab-order sequence.

Thanks,

Paul

td

  • Tech Support
  • *****
  • Posts: 2725
    • WinBatch
Re: Remove Control from Tab-Order
« Reply #5 on: December 12, 2018, 07:12:53 am »
Giving a control's tab order a magic number with special meaning would cause too many backward compatibility issues and backward compatibility is something users value so it is not something we would implement unless users had no other option.   In this case, a simple UDF seems like a viable option for the present.   An enhancement along these lines might be done using the DialogControlState function in the future.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade