bgotfocus from dialog in MDI enverronnement

Post Reply
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

bgotfocus from dialog in MDI enverronnement

Post by Frank Demont »

Hello,

Having 2 dialogs in a MDI envorronement , i try to use the actual values from the first dialog in the second.

In the second dilaog , bgotfocus is set , supposing that when in the first dialog lCheck is changed , the second dialog must first receive focus (clicking on it) , and execute bgotfocus.

This seems not to be the case. I have no idea when this block is executed.

How can the second dialog SEE that in the first dialog lCheck is changed ??

Frank

Code: Select all

# include "fivewin.ch"
STATIC oWnd
function Main(datadir , cAlias , cSeek)
SET _3DLOOK ON
DEFINE WINDOW oWnd FROM 0, 0 TO 24, 80 MDI;
	TITLE "Test" COLOR "W/BG";
	MENU  BuildMenu(oWnd)
	SET MESSAGE OF oWnd TO "TEST MDI" CLOCK DATE KEYBOARD NOINSET
ACTIVATE WINDOW oWnd MAXIMIZED
return nil
*******************************************
function BuildMenu(OoWnd)
local oMenu 
	MENU oMenu
		MENUITEM "&Test";
		ACTION Dialog1()
	ENDMENU
return oMenu
*************************************************
PROC Dialog1()
***************
LOCAL  oDlg
LOCAL oGet , oBut , oCheck
LOCAL nVar := 1000 , lCheck := .T.
nVar := 1000
DEFINE DIALOG oDlg FROM 10,20 TO 30,100 OF oWnd TITLE "Dialog 1"
	@ 5 ,5 GET oGet VAR nVar OF oDlg SIZE 40,10
	@ 6 ,5 CHECKBOX oCheck VAR lCheck PROMPT "Dialog 2 can be Changed" OF oDlg SIZE 140 , 10
	@ 7,5 BUTTON oBut PROMPT "Dialog 2" OF oDlg ACTION Dialog2(oDlg)
ACTIVATE DIALOG oDlg //CENTER
RETURN
***************************************************************
PROC Dialog2(oDDlg)
*******************
LOCAL nVar , oDlg
LOCAL oGet , oBut
LOCAL aControls := oDDlg:aControls
LOCAL lCheck := .T.
nVar := 2000
DEFINE DIALOG oDlg FROM 0,0 TO 15,75 OF oWnd TITLE "Dialog 2"
oDlg:bGotfocus := {||lCheck := aControls[2]:Varget() , oDlg:Update() , tracelog(lCheck , aControls[2]:Varget())}
@ 5 ,5 GET oGet VAR nVar OF oDlg SIZE 40,10 WHEN lCheck UPDATE
@ 10,5 BUTTON oBut OF oDlg ACTION Dialog2(oDlg)
ACTIVATE DIALOG oDlg CENTER
RETURN
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

You may supply lCheck to the function that creates the second dialog:

@ 7,5 BUTTON oBut PROMPT "Dialog 2" OF oDlg ACTION Dialog2(oDlg, @lCheck )

Passing it by reference lets you change it from the second one.

Is that what you are looking for or am I missing something ? thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply