What DataWindow method is invoked when the user closes the window by checking the "X" in the upper-right?
Trying to insert an "Are you sure?" confirmation in some of the data-entry windows.
Thanks everyone.
Closing Datawindow method
Closing Datawindow method
Joe Curran
Ohio USA
Ohio USA
Closing Datawindow method
Joe,
VO calls the QueryClose method. See the Windows Properties dialog, then click the dotted button to generate the QueryClose event call such as:
Set lAllowClose to TRUE to close the window.
Jamal
VO calls the QueryClose method. See the Windows Properties dialog, then click the dotted button to generate the QueryClose event call such as:
Code: Select all
method QueryClose(oEvent) class YourWindow
local lAllowClose as logic
lAllowClose := super:QueryClose(oEvent)
//Put your changes here
return lAllowClose
Jamal
Closing Datawindow method
Thank you, Jamal.
Did this. Didn't work.
I inserted a pop-up text box in place of "// Put your changes here". Nothing. Am I missing something?
Here's the problem I'm trying to fix: I've been getting complaints from some users (who in turn complain to their higher-ups) that their data-entry isn't saving. That is almost certainly because they're closing the window by clicking the "X" rather than by hitting our "Save and Exit" button. So they need a reminder.
Did this. Didn't work.
I inserted a pop-up text box in place of "// Put your changes here". Nothing. Am I missing something?
Here's the problem I'm trying to fix: I've been getting complaints from some users (who in turn complain to their higher-ups) that their data-entry isn't saving. That is almost certainly because they're closing the window by clicking the "X" rather than by hitting our "Save and Exit" button. So they need a reminder.
Joe Curran
Ohio USA
Ohio USA
Closing Datawindow method
Hi Joe,
AFAIK closing with the X ignores the QueryClose() method.
I'm disabling that X with:
Wolfgang
AFAIK closing with the X ignores the QueryClose() method.
I'm disabling that X with:
Code: Select all
method EnableSysClose( lEnable as logic ) as void pascal class GeneralDataWindow
if lEnable == false
EnableMenuItem( GetSystemMenu( self:Handle(), FALSE ), SC_CLOSE , _or( MF_BYCOMMAND, MF_GRAYED ) )
else
EnableMenuItem( GetSystemMenu( self:Handle(), FALSE ), SC_CLOSE , _or( MF_BYCOMMAND, MF_ENABLED ) )
endif
return
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Closing Datawindow method
HI,
Here's a snippet from one of my datawindows that asks a question if on saved:
METHOD QueryClose( oCE ) CLASS bTakeoffWin
LOCAL nRtn AS DWORD
LOCAL lAllowClose AS LOGIC
LOCAL nLen AS DWORD
LOCAL nCounter AS DWORD
LOCAL oCol AS bDataColumn
LOCAL nX AS LONGINT
LOCAL nY AS LONGINT
LOCAL nH AS LONGINT
LOCAL nW AS LONGINT
LOCAL oSize AS Dimension
LOCAL oOrigin AS Point
lAllowClose := SUPER:QueryClose( oCE )
IF lAllowClose
IF SELF:lNeedSave
IF !SELF:lIsClosing
SELF:lIsClosing := TRUE
nRtn := PCE_YESNOCANCELBOX( SELF, 'Takeoff', 'Takeoff has been changed, save changes?' )
DO CASE
CASE nRtn == BOXREPLYYES
lAllowClose := SELF:SaveData()
CASE nRtn == BOXREPLYNO
lAllowClose := TRUE
SELF:lNeedSave := FALSE
CASE nRtn == BOXREPLYCANCEL
lAllowClose := FALSE
ENDCASE
SELF:lIsClosing := FALSE
ELSE
lAllowClose := FALSE
ENDIF
ELSE
lAllowClose := TRUE
ENDIF
IF lAllowClose
SELF:lInit := TRUE
ENDIF
IF lAllowClose
.......
PCE_YESNOCANCELBOX is just a wrapper around the textbox:
FUNCTION PCE_YESNOCANCELBOX( oObj AS OBJECT, cTitle AS STRING, cQuestion AS STRING ) AS DWORD
LOCAL nRtn AS DWORD
LOCAL oTB AS textbox
oTB := textbox{ oObj, cTitle ,cQuestion }
oTB:Type := BOXICONQUESTIONMARK + BUTTONYESNOCANCEL
nRtn := ( oTB:Show() )
oTB:Destroy()
RETURN nRtn
Here's a snippet from one of my datawindows that asks a question if on saved:
METHOD QueryClose( oCE ) CLASS bTakeoffWin
LOCAL nRtn AS DWORD
LOCAL lAllowClose AS LOGIC
LOCAL nLen AS DWORD
LOCAL nCounter AS DWORD
LOCAL oCol AS bDataColumn
LOCAL nX AS LONGINT
LOCAL nY AS LONGINT
LOCAL nH AS LONGINT
LOCAL nW AS LONGINT
LOCAL oSize AS Dimension
LOCAL oOrigin AS Point
lAllowClose := SUPER:QueryClose( oCE )
IF lAllowClose
IF SELF:lNeedSave
IF !SELF:lIsClosing
SELF:lIsClosing := TRUE
nRtn := PCE_YESNOCANCELBOX( SELF, 'Takeoff', 'Takeoff has been changed, save changes?' )
DO CASE
CASE nRtn == BOXREPLYYES
lAllowClose := SELF:SaveData()
CASE nRtn == BOXREPLYNO
lAllowClose := TRUE
SELF:lNeedSave := FALSE
CASE nRtn == BOXREPLYCANCEL
lAllowClose := FALSE
ENDCASE
SELF:lIsClosing := FALSE
ELSE
lAllowClose := FALSE
ENDIF
ELSE
lAllowClose := TRUE
ENDIF
IF lAllowClose
SELF:lInit := TRUE
ENDIF
IF lAllowClose
.......
PCE_YESNOCANCELBOX is just a wrapper around the textbox:
FUNCTION PCE_YESNOCANCELBOX( oObj AS OBJECT, cTitle AS STRING, cQuestion AS STRING ) AS DWORD
LOCAL nRtn AS DWORD
LOCAL oTB AS textbox
oTB := textbox{ oObj, cTitle ,cQuestion }
oTB:Type := BOXICONQUESTIONMARK + BUTTONYESNOCANCEL
nRtn := ( oTB:Show() )
oTB:Destroy()
RETURN nRtn
Closing Datawindow method
Hello Wolfgang, Joe,
I use the QueryClose all over. And it is is certainly called when I close the datawindow with the "X". Here I have a method CheckChanged using a variable lChanged which is set to True in the EditChange. If true is passed to CheckChanged my program asks if changes should be saved. On Yes, my RecordSave method is called. Both are methods from my DataWindow subclas, the latter is a general way to save control contents in the underlying DBF.
Joe, did you probably add the method to a window being part of a tab window? That won't work, the QueryClose should be of the Tab window (and you can call queryClose methods of the datawindows within that tabwindow from there).
You might also want to read Jamal's question way back, in 2004, and Chris Pyrga's' replies:
https://groups.google.com/g/comp.lang.c ... TLAtIk2GIJ
Dick
In VO?AFAIK closing with the X ignores the QueryClose() method.
I use the QueryClose all over. And it is is certainly called when I close the datawindow with the "X". Here I have a method CheckChanged using a variable lChanged which is set to True in the EditChange. If true is passed to CheckChanged my program asks if changes should be saved. On Yes, my RecordSave method is called. Both are methods from my DataWindow subclas, the latter is a general way to save control contents in the underlying DBF.
Joe, did you probably add the method to a window being part of a tab window? That won't work, the QueryClose should be of the Tab window (and you can call queryClose methods of the datawindows within that tabwindow from there).
You might also want to read Jamal's question way back, in 2004, and Chris Pyrga's' replies:
https://groups.google.com/g/comp.lang.c ... TLAtIk2GIJ
Dick
Closing Datawindow method
Joe,
It works for me! Take a look at the attached sample AEF. If you still have an issue, post a sample AEF that shows the problem.
Jamal
It works for me! Take a look at the attached sample AEF. If you still have an issue, post a sample AEF that shows the problem.
Jamal
OhioJoe wrote:Thank you, Jamal.
Did this. Didn't work.
I inserted a pop-up text box in place of "// Put your changes here". Nothing. Am I missing something?
Here's the problem I'm trying to fix: I've been getting complaints from some users (who in turn complain to their higher-ups) that their data-entry isn't saving. That is almost certainly because they're closing the window by clicking the "X" rather than by hitting our "Save and Exit" button. So they need a reminder.
Closing Datawindow method
thank you, everyone.
Jamal, Dick: You're right. There's no reason this shouldn't work. But after reading that old post, I think the problem might be in the Dispatch() method of the inherited class.
I'll get to work on these solutions and report back.
Jamal, Dick: You're right. There's no reason this shouldn't work. But after reading that old post, I think the problem might be in the Dispatch() method of the inherited class.
I'll get to work on these solutions and report back.
Joe Curran
Ohio USA
Ohio USA