Page 1 of 2

XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 8:16 am
by Enrico Maria Giordano
I'm having strange problems with XBrowse and nomodal dialogs. Switching from one dialog to another, often I find 0 (zero) as the current workarea. What is the correct way to manage workarea switching in such scenario? I'm currently using oBrw:bGotFocus but it seems that other XBrowse functions are executed before it, so the workarea is not correctly switched.

Any help?

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 9:46 am
by Otto
Enrico, have you tried with oDlg:bGotFocus = { || dbSelectArea( "dbffile" )} .
Best regards
Otto

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 9:54 am
by Enrico Maria Giordano
Yes, same problem. oDlg:bGotFocus doesn't start at all.

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 10:15 am
by MaxP
And try with ?

Code: Select all

oBrw:bpainted = { || dbSelectArea( "dbffile" )}

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 10:21 am
by Enrico Maria Giordano
Sorry, it doesn't solve the problem. There are some codeblocks in XBrowse that are evaluated before bPainted and bGotFocus, so before workarea setting.

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 2:14 pm
by Enrico Maria Giordano
Is there any code in XBrowse that changes the current workarea? Otherwise, who is that selects the workarea number zero? I don't do it for sure.

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 3:03 pm
by dutch
Dear Enrico,

I'm so sorry to ask you.
Do you add "ALIAS" in XBROWSE command? If not, I guess the XBROWSE will read from current workarea.

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 3:13 pm
by Enrico Maria Giordano
Yes, I already add

ALIAS ALIAS()

Is it correct? But the problem is that the workarea become number zero when I switch to another dialog with another XBrowse.

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 5:08 pm
by nageswaragunupudi
I assume you are using different workareas for different browses. We can not use same workarea in different xbrowses.
Switching the xbrowses does not switch workareas (does not change the selected workarea).
XBrowse is also not affected by the currently selected workarea.
XBrowse reads from oBrw:cAlias and writes to oBrw:cAlias.

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 5:13 pm
by Enrico Maria Giordano
Yes, I'm using different workareas. But the browses are dinamically created so I can't use any alias, I need that the current workarea is the one of the browse with the focus.

Can it be done?

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 5:19 pm
by nageswaragunupudi
Can it be done?
Can be done, as long as you programmatically ensure that you are not creating a new Xbrowse for the same alias for which you already created another Xbrowse.

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 5:24 pm
by Enrico Maria Giordano
Yes, I'm sure of that because the aliases are generated by the program. So, what do you suggest for switching the workarea on focus change? Please note that bGotFocus seems not to be enough.

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 6:22 pm
by nageswaragunupudi
There is no need to switch workareas.
XBrowse has nothing to do with currently selected workarea.

If you still have any problem, please provide a small sample.

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 7:08 pm
by Enrico Maria Giordano
Scenario: two nomodal dialogs (or windows) each with its own browse. The code behind them are the same and relies on the current workarea (this is not my choice). How can I get this working without a way to automatically switch the workarea when a dialog gains the focus?

EMG

Re: XBrowse and nomodal dialogs

Posted: Fri Oct 09, 2020 8:23 pm
by cnavarro
Dear Enrico
I do not think I fully understand the problem that it raises. Can you better explain to me what you need
Here are two non-modal dialogs with xbrowse
Image