Announcement

Collapse
No announcement yet.

General question

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

  • General question

    I have this OPTIONS dialog box, in the "OK" button I do this, so that it will do the apply button.

    One of the options is to display the log in reverse order, so what I do is re-read the file, redisplay it with the reverse order flag set.

    That works, but SOMETIMES, nad not OFTEN if I JUST click "OK" instead of APPLY, (sometimes, not all the time) it hesitates for a second then does NOT do the update.

    is it possible my Dialog End cbhndl,1 is taking place while the function call is executed to re-read the log file???

    Code:
    '
    'In optionsproc:
            Case %IDOK, 130 'OK
                'Click the Apply button
                If IsWindowEnabled(GetDlgItem(CbHndl,%IDAPPLY)) Then
                   SendMessage GetDlgItem(CbHndl,%IDAPPLY) , %BM_CLICK, 0, 0
                End If
                Dialog End CbHndl, 1
                Exit Function
    
    
            Case %IDAPPLY
                'Does a bunch of ini or registry stuff, then to the root fo the problem:
    
                'This will encrypt/decrypt the log file based on use encryption settings
                EncryptLogFile 'Decrypts or re-crypts
    
                'This puts the refresh on the screen
                SendMessage g_hListView, %LVM_DELETEALLITEMS,0,0
                g_Result = ReadLogFile() 'This displays/updates Listview
                Control Disable CbHndl, %IDAPPLY
                'Now indicate that we are done once through here and do not do items again with OK button
                Function = 0
                Exit Function
    ------------------
    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

  • #2
    Possibly... why not disable the OK button while the APPLY handler is running, and reenable it when it finishes?

    This would make the dialog more "friendly" as the user is barred from making any futher changes while APPLY is running. Ditto for the CANCEL button.

    Also, change the cursor to an hour-glass while it runs.

    You could also disable the dialog while you are doing the updating, but this is not a very tidy way to do it as you will probably have to jump through a few hoops to *ensure* you get app focus back when you reenable the dialog.

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

    Comment


    • #3
      I took the EncryptLogFile function out of IDAPPLY and the problem went away...so what I think is this:

      A) EncryptLogFile runs, opens file, closes file, encrypts, opens file closes file...
      Even with it open->Encrypt->Seek 1->Put, Close it still happened.

      B) ReadLogFile occurs, opens file, reads it.


      I think it's timing between the two functions fighting over the same file.....it's not quite closed I think..


      Another case of PB being too fast for me hehe...but it's OK, it's my code...

      So, at least I have the function narrowed down, this function allows the user to decide NOT to encrypt the file, so it decrypts it....
      Perhaps we don't need that option....hmmmmmmm...


      Works fine now, without that option in there.

      Code:
      Function EncryptLogFile() As Long
      'Determine a) Is file already encrypted
      Local hFile As Long
      Local sTmp      As String
      sTmp = g_sClipText
      
      Replace $CRLF With "|" In sTmp
      hFile = FreeFile
      Open g_sFileSpec For Binary As #hFile
      If IsTrue g_UseEncryption Then
         Put$ #hFile, RC4NcryptString(ByVal sTmp,g_wnKey,0)
      Else
         Put$ #hFile, sTmp
      End If
      Close hFile
      End Function
      ------------------
      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

      Working...
      X