Closing Datawindow method

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
User avatar
OhioJoe
Posts: 131
Joined: Wed Nov 22, 2017 12:51 pm
Location: United States

Closing Datawindow method

Post by OhioJoe »

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.
Joe Curran
Ohio USA
Jamal
Posts: 320
Joined: Mon Jul 03, 2017 7:02 pm

Closing Datawindow method

Post by Jamal »

Joe,

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

Set lAllowClose to TRUE to close the window.

Jamal
User avatar
OhioJoe
Posts: 131
Joined: Wed Nov 22, 2017 12:51 pm
Location: United States

Closing Datawindow method

Post by OhioJoe »

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.
Joe Curran
Ohio USA
User avatar
wriedmann
Posts: 3757
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Closing Datawindow method

Post by wriedmann »

Hi Joe,
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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
GlenT
Posts: 33
Joined: Fri Sep 25, 2015 7:35 pm

Closing Datawindow method

Post by GlenT »

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
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Closing Datawindow method

Post by ic2 »

Hello Wolfgang, Joe,
AFAIK closing with the X ignores the QueryClose() method.
In VO?

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
Jamal
Posts: 320
Joined: Mon Jul 03, 2017 7:02 pm

Closing Datawindow method

Post by Jamal »

Joe,

It works for me! Take a look at the attached sample AEF.

[The extension aef has been deactivated and can no longer be displayed.]

[The extension mp4 has been deactivated and can no longer be displayed.]

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.
User avatar
OhioJoe
Posts: 131
Joined: Wed Nov 22, 2017 12:51 pm
Location: United States

Closing Datawindow method

Post by OhioJoe »

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.
Joe Curran
Ohio USA
Post Reply