WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: PaulSamuelson on December 10, 2018, 07:32:43 AM

Title: Remove Control from Tab-Order
Post by: PaulSamuelson 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
Title: Re: Remove Control from Tab-Order
Post by: td on December 10, 2018, 02:24:46 PM
Code (winbatch) Select
;; 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")


Title: Re: Remove Control from Tab-Order
Post by: PaulSamuelson 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
Title: Re: Remove Control from Tab-Order
Post by: td on December 11, 2018, 05:17:15 PM
A six line cut and paste solution too much to handle?
Title: Re: Remove Control from Tab-Order
Post by: PaulSamuelson 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
Title: Re: Remove Control from Tab-Order
Post by: td 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.