Results 1 to 8 of 8

Thread: [RESOLVED] [2005] New, Open, Save, Save As and Exit

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Resolved [RESOLVED] [2005] New, Open, Save, Save As and Exit

    Hi!!

    In programs like Notepad, Word, Excel, PowerPoint, etc. Not considering the fact that some of these programs support multiple opened documents at the same time, they all share similarities in "new", "open", "save", "save as" and "exit" functions/subs, let me explain:

    If you click in "new":
    • a)There is a document opened, the program asks if you wanna save the current document. This only happens if the current document is different from the last time it was saved (if it was never saved, then its "different"). And you are given three options:
      • "Yes" - he saves the file, then resets
      • "No" - just resets
      • "Cancel" - doesnt do anything
    • There is no document opened, he "resets" all the configurations (font size, type, etc), well makes a new document


    If you click "open":
    • There is a document opened, happens a) again:
      • "Yes" - he saves the document, then opens your file
      • "No" - just opens your file
      • "Cancel" - doesnt do anything
    • Theres no opened document, he opens your file.


    If you click "Save":
    • You have never saved, neither you are editing a document opened in the program. That means you opened the program and start to create the document - he goes to "save as"
    • You opened the document with the program or you already "made" a "save as", he saves your document in the file where you first opened it.


    If you click "Save as" - you just save the document in the path chosen by you.

    If you click "Exit"
    • There is a document opened, happens a) again:
      • "Yes" - he saves the document, then exits program
      • "No" - just exits program
      • "Cancel" - doesnt do anything
    • Theres no opened document, he exists program



    Well, so I can achieve this I use a openfiledialog, savefiledialog and string that hold a path to a file (the opened or the save as file).
    When u click save and it has to save your document in the file where you first opened it:
    • I delete the file where you first opened it.
    • Create a new file, with the same name and in the same path (because i use the string with the path value), this file "was" the "values" of the current document.

    And to detect either it has to ask if you wanna save or not (in the a) case):
    • I create a temporary file with the "values of the current document
    • I compare if that file and the last saved document (the one "in" string path) are equal, if they are different it asks.


    My question inst there any template to make this, maybe in a more sophisticated and efficient way?
    Last edited by Lasering; Feb 26th, 2008 at 04:25 PM.
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width