Announcement

Collapse
No announcement yet.

Strange bug, Very strange

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

  • Strange bug, Very strange

    I have this program, and have added code, and to eliminate this bug I remove or rem out that code but the bug is still there.
    It all started when I put my LicenseAgreement code in under WM_INITDIALOG.
    The licenseagreement opens a NEW dialog and user gets a choice of pressing I Accept or "I do not accept".

    Choosing I accept does this
    Dialog End CbHndl,1
    Choosing I do NOT accept does this:

    Dialog End CbHndl,0

    Now, if they say "No", the LicenseAgreement function ends as it's supposed to and does a Function = RC (Rc is returned from the License Agreement callback via the Dialog End method)


    Now, if th ey choose NO, the application stays in memory.
    I did a Msgbox "DEBUG" at WM_DESTROY and it never gets there...

    I've eliminated it to the code below that states if they do not agree then Dialog End CbHndl,0 for the MAIN program dialog box.


    If I remove that line of code, the app obviously starts and ends properly.

    Is there something about this? I also have a subclass in there, and even attempted to close it before closing the dialog, didn't matter.
    I also tried destroying the font and brush before closing the dialog, didn't matter.

    Why won't my program end if they don't choose to agree???


    Thanks! and I'll post more code if necessary..

    Code:
        Case %WM_INITDIALOG
    
              '------------------------------------------------------------------
              'COLOR STUFF
              hFont1 = MakeFont("Courier New", 10)
    
              GetObject hFont1, SizeOf(lf), ByVal VarPtr(lf)
              'Make the text bold font or normal
              lf.lfWeight = %FW_BOLD
              Lb.lbStyle  = %BLACK_BRUSH
              Control Send CbHndl,%IDLABEL4, %WM_SETFONT, hFont1, %TRUE
    
              '------------------------------------------------------------------
    
             'Subclass the text box
             Control Handle CbHndl, %IDTEXT2  To hText
             gOldSubClassProc = SetWindowLong(hText, %GWL_WNDPROC, CodePtr(SubClassProc))
    
             If IsTrue Val(fh.PasswordFlag) Then Control Disable CbHndl,%IDBUTTON2
             Control Set Text CbHndl, %IDTEXT1, Trim$(fh.UncompressPath)
             If IsTrue Val(fh.PasswordFlag) Then
                Control Set Focus CbHndl,%IDTEXT2
             Else
                 Control Set Focus CbHndl,%IDBUTTON2
             End If
             Control Set Check CbHndl, %IDCHECK1, %TRUE
    
            Control Set Text hDlg,%IDTEXT1,Trim$(fh.UncompressPath)
            If IsTrue Val(fh.LicenseFlag) Then
                If IsFalse DisplayLicenseAgreement() Then
                    MsgBox "You must agree to the license agreement before this file can be uncompressed", %MB_ICONSTOP,g_Python
                    Dialog End CbHndl,1
                End If
            End If
    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    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
    And to get even STRANGER.
    This solves the problem, might be an acceptable workaround simply because I can disable the Uncompress button for half a second


    The timer is hte key, if I set the timer for 250 ms and the users say "I don't agree" then the program ends properly.

    Very strange, could it have something to do with the thread in the program despite that it never even GETS that far? (Does pb load the thread prematurely?)

    Code:
    'Under WM_INITDIALOG:
    
    'Timer is killed immediately upon entering LicenseAgreement Callback function.
    
            If IsTrue Val(fh.LicenseFlag) Then SetTimer CbHndl, %IDT_TIMER1,250, ByVal %NULL
    
        Case %WM_TIMER
            Select Case CbWparam
              Case %IDT_TIMER1
                If IsFalse DisplayLicenseAgreement() Then
                    MsgBox "You must agree to the license agreement before this file can be uncompressed", %MB_ICONSTOP,g_Python
                    Dialog End CbHndl,1
                End If
            End Select
    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    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


    • #3
      scott --
      instead of dialog end use postmessage cbhndl, %wm_syscommand, %sc_close, 0
      also look http://www.powerbasic.com/support/pb...ead.php?t=2988 http://www.powerbasic.com/support/pb...ead.php?t=3160
      a reason is absolutelly clear: dialog is created by dialog new and wm_initdialog in ddt is fictive (ddt engine already said ok to create a dialog).


      ------------------
      e-mail: [email protected]ki.ru

      Comment


      • #4
        DIALOG END cannot be used from within %WM_INITDIALOG.

        Post the dialog a user-defined message, and use DIALOG END there...
        Code:
        CASE %WM_INITDIALOG
           ...
           PostMessage CBHNDL, %WM_USER+999,0,0
        CASE %WM_USER+999&
           DIALOG END CBHNDL
        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          That explains why the timer works.

          Is that a bug? This is one of those strange occurances where I init the dialog and changed my mind (Don't go there if you are thinking what I am hehe)...

          Tanks,

          Scott


          ------------------
          Scott
          mailto:[email protected][email protected]</A>
          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