Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

Closing Datawindow method 10 Jan 2022 21:16 #21071

  • OhioJoe
  • OhioJoe's Avatar
  • Topic Author


  • Posts: 108
  • 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

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 10 Jan 2022 22:23 #21072

    • Jamal


  • Posts: 269
  • Joe,

    VO calls the QueryClose method. See the Windows Properties dialog, then click the dotted button to generate the QueryClose event call such as:
    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

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 11 Jan 2022 19:42 #21077

    • OhioJoe
    • OhioJoe's Avatar
    • Topic Author


  • Posts: 108
  • 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

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 11 Jan 2022 20:05 #21078

    • wriedmann
    • wriedmann's Avatar


  • Posts: 2878
  • Hi Joe,
    AFAIK closing with the X ignores the QueryClose() method.
    I'm disabling that X with:
    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

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 11 Jan 2022 21:08 #21079

    • GlenT
    • GlenT's Avatar


  • Posts: 28
  • 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

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 11 Jan 2022 21:17 #21080

    • ic2


  • Posts: 1221
  • 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:

    groups.google.com/g/comp.lang.clipper.vi...rF2hI/m/86TLAtIk2GIJ

    Dick

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 11 Jan 2022 21:38 #21081

    • Jamal


  • Posts: 269
  • Joe,

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

    File Attachment:

    File Name: CloseWindo...tApp.AEF
    File Size:59 KB

    2022-01-11...5-02.mp4


    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.

    Attachments:

    Please Log in or Create an account to join the conversation.

    Closing Datawindow method 11 Jan 2022 21:54 #21082

    • OhioJoe
    • OhioJoe's Avatar
    • Topic Author


  • Posts: 108
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1