Code: Select all
FUNCTION BrwFocusTest
LOCAL oDlg, oBrw, oBtn
USE CUSTOMER NEW ALIAS CUST
DEFINE DIALOG oDlg SIZE 200,200 PIXEL
@ 10,10 BUTTON oBtn PROMPT 'Button' SIZE 40,12 PIXEL OF oDlg
@ 30,10 LISTBOX oBrw FIELDS ;
SIZE 80, 60 PIXEL OF oDlg ;
ALIAS 'CUST'
oBrw:nClrBackFocus := CLR_GREEN
oBrw:nClrForeFocus := CLR_WHITE
ACTIVATE DIALOG oDlg CENTER ;
ON INIT oBrw:SetFocus()
RETURN NIL
There are two workarounds though. But I think this should work without workarounds. Can someone help me how to set focus to the browse initially ?
I adopt one of the following two workarounds, but they are workarounds. I guess it should work without any workarounds:
1. After defining the button, oBtn:nStyle -= WS_TABSTOP. Then naturally oBrw is the first control with tabstop and so it gets the focus anyway.
2. Define the browse first and define the button in the subsequent program code. That way browse gets 1st tab stop and button gets the second tabstop despite their appearance.
But I want to focus on the browse initially without disturbing the taborders of the controls. How can I do this please?