Page 1 of 3
Dialog NOWAIT lost focus at activation!
Posted: Mon Aug 18, 2008 6:12 pm
by JC
Why I execute a activation of dialog like this at bellow, the window behind my application is focused?
Code: Select all
ACTIVATE DIALOG oDlg VALID .F. NOWAIT CENTERED
Posted: Mon Aug 18, 2008 6:27 pm
by Antonio Linares
Have you tried to do:
oDlg:SetFocus()
after ACTIVATE DIALOG oDlg ?
Maybe your program execution is giving the focus to some other window, control, etc. as NONMODAL will not wait.
Posted: Mon Aug 18, 2008 6:58 pm
by JC
Antonio Linares wrote:Have you tried to do:
oDlg:SetFocus()
after ACTIVATE DIALOG oDlg ?
Maybe your program execution is giving the focus to some other window, control, etc. as NONMODAL will not wait.
This my code:
Code: Select all
DEFINE DIALOG oDlg RESOURCE "WAIT_DIALOG" OF oWnd
oDlg:lHelpIcon := .F.
oDlg:cargo := .F.
REDEFINE SAY oSay ID 101 OF oDlg FONT oFontBoldGrande
ACTIVATE DIALOG oDlg VALID .F. NOWAIT CENTERED
oSay:setText( "Waiting..." )
oSay:refresh()
oDlg:setFocus()
But, Him set the focus to the window behind my application and, after my execution (is a DO WHILE command), the focus is restored to my application.
Posted: Mon Aug 18, 2008 7:06 pm
by Antonio Linares
JĂșlio,
Please test this example and check where the focus is placed:
test.prg
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "A window"
ACTIVATE WINDOW oWnd ;
ON INIT BuildNonModal()
return nil
function BuildNonModal()
local oDlg
DEFINE DIALOG oDlg TITLE "A non modal dialog"
ACTIVATE DIALOG oDlg NOWAIT CENTERED
return nil
Posted: Mon Aug 18, 2008 7:23 pm
by JC
Dear Antonio, I provide a small example of my situation for you... I send to your email. Please check it!
Thank you very much!
Posted: Mon Aug 18, 2008 7:29 pm
by JC
Please, execute the example with a window behind the .exe
Like a MS-DOS window!!
Posted: Tue Aug 19, 2008 6:04 am
by Antonio Linares
Our example runs the same if there is an open window in the background.
We wait for your example, thanks
Posted: Tue Aug 19, 2008 11:25 am
by JC
Antonio Linares wrote:Our example runs the same if there is an open window in the background.
We wait for your example, thanks
I have already sent to you Antonio. But, take the link to download:
http://rapidshare.com/files/138461123/nonmodal.zip.html
I think I explained to you that the wrong way, sorry... The main window is that it loses the focus when the dialog is closed!
When the dialog nonmodal is ended, the focus goes to any other different window of main window, like a MS-DOS window behind the .EXE
Please do my example with a another window behind the .EXE like the MS-DOS window!
With my application, the effect appears like a blink!
Posted: Wed Aug 20, 2008 12:17 pm
by JC
I need some help for this!
Someone?
Posted: Wed Aug 20, 2008 3:23 pm
by James Bott
Julio,
I can't figure out what you are trying to do. I looked at your code and you are creating a non-modal dialog and then trying to make it act like a modal dialog by disabling the main window. What is the point? Why not use a modal dialog. A modal dialog automatically disables the main window until it is closed. If you do this then you don't have a problem.
James
Posted: Wed Aug 20, 2008 3:27 pm
by JC
James Bott wrote:Julio,
I can't figure out what you are trying to do. I looked at your code and you are creating a non-modal dialog and then trying to make it act like a modal dialog by disabling the main window. What is the point? Why not use a modal dialog. A modal dialog automatically disables the main window until it is closed. If you do this then you don't have a problem.
James
James, is it! But, I need to execute a code out of the modal dialog and I think it is the unique way to do! Then, I have disabled the window for execute the code.
The main window opens the dialog non-modal and the non-modal dialog disable the main window. The main window execute a code and close the dialog. Something like this!
Exists another way to do it?
Posted: Wed Aug 20, 2008 3:49 pm
by James Bott
Julio,
>Exists another way to do it?
Just execute your code from a modal dialog. The main window will remain disabled until the dialog is closed.
James
Posted: Wed Aug 20, 2008 4:02 pm
by JC
James Bott wrote:Julio,
>Exists another way to do it?
Just execute your code from a modal dialog. The main window will remain disabled until the dialog is closed.
James
Ok James, but the code will be execute by the main window, not by the non-modal dialog

For this, a modal dialog will not permit the execution... right?
Posted: Wed Aug 20, 2008 4:12 pm
by James Bott
Julio,
>Ok James, but the code will be execute by the main window, not by the non-modal dialog
>For this, a modal dialog will not permit the execution... right?
Here is a working example:
Code: Select all
#include "fivewin.ch"
function main()
local oWnd
define window oWnd
activate window oWnd on init doit()
return nil
function doit()
local oDlg, oBtn
define dialog oDlg
@ 1,1 button oBtn action msgInfo("Test process called from modal dialog")
activate dialog oDlg
return nil
James
Posted: Wed Aug 20, 2008 4:58 pm
by JC
James Bott wrote:Julio,
>Ok James, but the code will be execute by the main window, not by the non-modal dialog
>For this, a modal dialog will not permit the execution... right?
Here is a working example:
Code: Select all
#include "fivewin.ch"
function main()
local oWnd
define window oWnd
activate window oWnd on init doit()
return nil
function doit()
local oDlg, oBtn
define dialog oDlg
@ 1,1 button oBtn action msgInfo("Test process called from modal dialog")
activate dialog oDlg
return nil
James
Please James, try to download this mini-example... You will understanding my question! And thank for you patience!
http://rapidshare.com/files/138461123/nonmodal.zip.html