Remove Control from Tab-Order

Started by PaulSamuelson, December 10, 2018, 07:32:43 AM

Previous topic - Next topic

PaulSamuelson

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

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")


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

PaulSamuelson

I was hoping for a "tab order = -1" or something like that, but I will make that work.

Thanks,

Paul

td

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

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

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