Announcement

Collapse
No announcement yet.

Priorities

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Priorities

    Easy question:
    Will my INI File save before the exit is complete?
    Something tells me not, my messagebox does not appear....
    I'd hate to duplicate code, I could make a function to do the saving...

    Code:
                 Case %IDM_SAVE
                      'SAve file here
                      g_IsSaved = %TRUE
                      lResult = MessageBox(CbHndl,g_IniFile & " was saved",ByVal StrPtr(g_szCCS),ByVal %MB_ICONINFORMATION)
    
    
                 Case %IDM_EXIT
                      If IsFalse g_IsSaved Then
                         lResult = MessageBox(CbHndl,"Save changes? Y/n",ByVal StrPtr(g_szCCS),ByVal %MB_ICONINFORMATION Or %MB_YESNO)
                         If lResult = %IDYES Then
                            'Save INI File
                            Control Send CbHndl,%IDM_SAVE, %BM_CLICK,0,0
                         End If
                      End If
                      Dialog End CbHndl,1
    ------------------
    Scott

    [This message has been edited by Scott Turchin (edited April 30, 2001).]
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    #2
    In certain cases, Windows may ignore calls to MessageBox since it could interfere with the current message execution, however, it would seem unlikely to be occurring in the case you present above. A quite run through the debugger should show what is actually happening.

    There are other solutions involving a semi-direct call to the procedure with %BN_CLICKED via CallWindowProc(), but I would not recommend this.



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


      #3
      INI's are VERY late updated, has nothing to do with smartdrv.
      Use NULL's as parameter to flush/force.

      ------------------
      hellobasic

      Comment


        #4
        Scott,

        This annoying behaviour is documented in MSDN KB ID: Q68827
        Just do this any time you want to force a save -
        Code:
        WritePrivateProfileString byval %NULL, byval %NULL, byval %NULL, byval strptr( sIniFile )
        Zippety Software, Home of the Lynx Project Explorer
        http://www.zippety.net
        My e-mail

        Comment


          #5
          Yikes, in Win2k they prefer that you use an INI file but it won't write to it?


          Where does this statement go? Ie in the save or in the exit?


          Scott

          ------------------
          Scott
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


            #6
            Where does this statement go? Ie in the save or in the exit?
            Yes. (No, that's not a wise-butt reply).

            You may want to add a flag variable such as IniSaveNeeded. When that is TRUE, you'd want to save your INI file (with our without a user prompt) on WM_CLOSE, WM_QUERYENDSESSION and on the explicit IDM_EXIT.

            MCM
            (Oops! Just noticed you already DO have a flag variable)


            [This message has been edited by Michael Mattias (edited May 01, 2001).]
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


              #7
              Scott,

              I think Michael provided the answer, but just call it any time
              you want to force a save or flush the ini contents to disk.
              Whether that means on exit or during the program is entirely up
              to yourself.

              Personally, I now tend bypass the API calls for reading / writing
              ini files, and just code those actions manually. That way, you
              don't get caught by this problem. PB's neat string functions make
              this very easy.

              HTH !
              Zippety Software, Home of the Lynx Project Explorer
              http://www.zippety.net
              My e-mail

              Comment


                #8
                Originally posted by Paul Noble:

                Personally, I now tend bypass the API calls for reading / writing
                ini files, and just code those actions manually. That way, you
                don't get caught by this problem. PB's neat string functions make
                this very easy.
                HTH !
                If anyone takes this aproach, make very sure that your program does not use API calls for access at any time, or it *will* come back and bite you.
                Yes, I'm speaking from experience


                ------------------
                Best Regards
                Peter Scheutz

                [This message has been edited by Peter Scheutz (edited May 01, 2001).]
                Best Regards
                Peter Scheutz

                Comment


                  #9
                  Guys,

                  I also do prefer to hand manage my INI files. I use only PB statements (no APIs - thanks Peter, I'll continue to do so!). This way I also use an INI file for some non-traditional tasks. For instance, when I need to read-modify-write the file, I can do it inside an unique lock-unlock block. I'm not sure this task could be done with the standard WritePrivateProfileString and the other related API calls (different instances of the program would overlap their read and write accesses to the file). The second reason I like to hand hand manage my INI files is to override the default NT settings, for which it uses the registry.

                  Well, all this sounds good. But is it? Has anyone any comment to add?

                  Aldo

                  ------------------
                  Rgds, Aldo

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎