From: Phil bayard on
Thanks for the answers

I've tried to use the EditChange by subclassing the DataWindows class
and setting some of the methods.

METHOD EditChange (oControlEvent ) CLASS cDataWindow

SUPER:EditChange(oControlEvent)

if (oControlEvent:Control:ValueChanged .and. self:IsChecked)
isChanged := true
endif

return nil



METHOD Show (kShowState ) CLASS cDataWindow

SUPER:Show(kShowState)
self:IsChecked := true

return nil


METHOD QueryClose( oEvent ) CLASS cDataWindow
LOCAL lAllowClose AS LOGIC

If self:isChecked
if self:isChanged
IF QMESSAGE(trad(self,"Wanna save the changes ?"),self)
self:ltosave:=true
lAllowClose := SUPER:QueryClose(oEvent)
ELSE
lAllowClose := SUPER:QueryClose(oEvent)
ENDIF
else
lAllowClose := SUPER:QueryClose(oEvent)
endif

else
IF QMESSAGE(trad(self,"Wanna save the changes ?"),self)
self:ltosave:=true
lAllowClose := SUPER:QueryClose(oEvent)
ELSE
lAllowClose := SUPER:QueryClose(oEvent)
ENDIF
endif
self:isChanged := false
self:IsChecked := false

RETURN lAllowClose


Seems to work well with a single DataWindows but it doesn't work with
this case :

Windows A got a bBrower with some items. Double click in the bbrowser
open a new tabbed windows B (with differents cDataWindows). Nothing is
asked when i close the windows B, but when i close the windows A, it
does.

And nothing is correctly saved because the edit windows B is already
closed and the informations are gone. Well, it's a special case so i
will try to get the isChanged value of the tabbed windows before
closing the Main windows B.

Anyway, thanks again for all your answers.
From: John Martens on
As you say: you can check in your tabbed window also in QueryClose if
the subwindows are checked before closeing the tabbed window.

John


Op 6-4-2010 11:44, Phil bayard schreef:
> Thanks for the answers
>
> I've tried to use the EditChange by subclassing the DataWindows class
> and setting some of the methods.
>
> METHOD EditChange (oControlEvent ) CLASS cDataWindow
>
> SUPER:EditChange(oControlEvent)
>
> if (oControlEvent:Control:ValueChanged .and. self:IsChecked)
> isChanged := true
> endif
>
> return nil
>
>
>
> METHOD Show (kShowState ) CLASS cDataWindow
>
> SUPER:Show(kShowState)
> self:IsChecked := true
>
> return nil
>
>
> METHOD QueryClose( oEvent ) CLASS cDataWindow
> LOCAL lAllowClose AS LOGIC
>
> If self:isChecked
> if self:isChanged
> IF QMESSAGE(trad(self,"Wanna save the changes ?"),self)
> self:ltosave:=true
> lAllowClose := SUPER:QueryClose(oEvent)
> ELSE
> lAllowClose := SUPER:QueryClose(oEvent)
> ENDIF
> else
> lAllowClose := SUPER:QueryClose(oEvent)
> endif
>
> else
> IF QMESSAGE(trad(self,"Wanna save the changes ?"),self)
> self:ltosave:=true
> lAllowClose := SUPER:QueryClose(oEvent)
> ELSE
> lAllowClose := SUPER:QueryClose(oEvent)
> ENDIF
> endif
> self:isChanged := false
> self:IsChecked := false
>
> RETURN lAllowClose
>
>
> Seems to work well with a single DataWindows but it doesn't work with
> this case :
>
> Windows A got a bBrower with some items. Double click in the bbrowser
> open a new tabbed windows B (with differents cDataWindows). Nothing is
> asked when i close the windows B, but when i close the windows A, it
> does.
>
> And nothing is correctly saved because the edit windows B is already
> closed and the informations are gone. Well, it's a special case so i
> will try to get the isChanged value of the tabbed windows before
> closing the Main windows B.
>
> Anyway, thanks again for all your answers.
From: Stephen Quinn on
Phil

You should read your code a bit

> If self:isChecked
Why this test??
It doesn't change the result at all.

You can get the same result with

METHOD QueryClose( oEvent ) CLASS cDataWindow

LOCAL lAllowClose AS LOGIC

if self:isChanged .AND.QMESSAGE(trad(self,"Wanna save the changes
?"),self)
self:ltosave:=true
endif
lAllowClose := SUPER:QueryClose(oEvent)

// Why bother with these as your closing the window anyway.
self:isChanged := false
self:IsChecked := false
// What happens when lAllowClose is FALSE (ie the window doesn't close)
// and you later want to close the window & save your data they'll be the
// wrong values the second time around

RETURN lAllowClose

CYA
Steve