by ZvezdanD » Wed Aug 05, 2009 7:03 pm
If I use QuerySongs and ProcessMessages in the RadioButton's event handler, none control is responsible, even the dialog box could not be moved, until the first click anywhere on that dialog box - after that click everything works fine. CheckBoxes don't have such problem. Here is the test script, you could find it under the Edit menu, (the first radio button works normally because it is without problematic code, the check box also works normally even with same problematic code):
Code: Select all
Option Explicit
Dim rdbTest1
Sub OnStartUp()
Dim mnuTest
Set mnuTest = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
mnuTest.Caption = "Zvezdan's Test"
mnuTest.OnClickFunc = "TestForm"
mnuTest.UseScript = Script.ScriptPath
End Sub
Sub TestForm(Item)
Dim oForm
Dim rdbTest2
Dim chkTest
Dim btnClose
Dim i
Set oForm = SDB.UI.NewForm
oForm.Common.SetRect 100, 100, 300, 200
oForm.BorderStyle = 3
oForm.FormPosition = 4
oForm.Caption = "Zvezdan's Test"
Set rdbTest1 = SDB.UI.NewRadioButton(oForm)
rdbTest1.Common.SetRect 10, 10, 100, 21
rdbTest1.Caption = "Normal"
Script.RegisterEvent rdbTest1.Common, "OnClick", "rdbTest1_OnClick"
Set rdbTest2 = SDB.UI.NewRadioButton(oForm)
rdbTest2.Common.SetRect 10, 40, 100, 21
rdbTest2.Caption = "With ProcessMessages"
Script.RegisterEvent rdbTest2.Common, "OnClick", "rdbTest2_OnClick"
Set chkTest = SDB.UI.NewCheckBox(oForm)
chkTest.Common.SetRect 140, 40, 100, 21
chkTest.Caption = "With ProcessMessages"
Script.RegisterEvent chkTest.Common, "OnClick", "chkTest_OnClick"
Set btnClose = SDB.UI.NewButton(oForm)
btnClose.Caption = "Close"
btnClose.Common.SetRect 120, 120, 80, 22
btnClose.Cancel = True
btnClose.ModalResult = 2
oForm.showModal
End Sub
Sub rdbTest1_OnClick(oItem)
SDB.ProcessMessages
End Sub
Sub rdbTest2_OnClick(oItem)
Dim oSongIter
oItem.Common.Enabled = False
rdbTest1.Common.Enabled = False
Set oSongIter = SDB.Database.QuerySongs("ID > 0")
Do While Not oSongIter.EOF
oSongIter.Next
SDB.ProcessMessages
Loop
Set oSongIter = Nothing
oItem.Common.Enabled = True
rdbTest1.Common.Enabled = True
End Sub
Sub chkTest_OnClick(oItem)
Dim oSongIter
oItem.Common.Enabled = False
Set oSongIter = SDB.Database.QuerySongs("ID > 0")
Do While Not oSongIter.EOF
oSongIter.Next
SDB.ProcessMessages
Loop
Set oSongIter = Nothing
oItem.Common.Enabled = True
End Sub
My Track Redirection script has such problem in its Create Redirections for Duplicates/Folders dialog box, but only if there are many displayed tracks. The test script from above has always reproducible bug.
If I use QuerySongs and ProcessMessages in the RadioButton's event handler, none control is responsible, even the dialog box could not be moved, until the first click anywhere on that dialog box - after that click everything works fine. CheckBoxes don't have such problem. Here is the test script, you could find it under the Edit menu, (the first radio button works normally because it is without problematic code, the check box also works normally even with same problematic code):
[code]Option Explicit
Dim rdbTest1
Sub OnStartUp()
Dim mnuTest
Set mnuTest = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
mnuTest.Caption = "Zvezdan's Test"
mnuTest.OnClickFunc = "TestForm"
mnuTest.UseScript = Script.ScriptPath
End Sub
Sub TestForm(Item)
Dim oForm
Dim rdbTest2
Dim chkTest
Dim btnClose
Dim i
Set oForm = SDB.UI.NewForm
oForm.Common.SetRect 100, 100, 300, 200
oForm.BorderStyle = 3
oForm.FormPosition = 4
oForm.Caption = "Zvezdan's Test"
Set rdbTest1 = SDB.UI.NewRadioButton(oForm)
rdbTest1.Common.SetRect 10, 10, 100, 21
rdbTest1.Caption = "Normal"
Script.RegisterEvent rdbTest1.Common, "OnClick", "rdbTest1_OnClick"
Set rdbTest2 = SDB.UI.NewRadioButton(oForm)
rdbTest2.Common.SetRect 10, 40, 100, 21
rdbTest2.Caption = "With ProcessMessages"
Script.RegisterEvent rdbTest2.Common, "OnClick", "rdbTest2_OnClick"
Set chkTest = SDB.UI.NewCheckBox(oForm)
chkTest.Common.SetRect 140, 40, 100, 21
chkTest.Caption = "With ProcessMessages"
Script.RegisterEvent chkTest.Common, "OnClick", "chkTest_OnClick"
Set btnClose = SDB.UI.NewButton(oForm)
btnClose.Caption = "Close"
btnClose.Common.SetRect 120, 120, 80, 22
btnClose.Cancel = True
btnClose.ModalResult = 2
oForm.showModal
End Sub
Sub rdbTest1_OnClick(oItem)
SDB.ProcessMessages
End Sub
Sub rdbTest2_OnClick(oItem)
Dim oSongIter
oItem.Common.Enabled = False
rdbTest1.Common.Enabled = False
Set oSongIter = SDB.Database.QuerySongs("ID > 0")
Do While Not oSongIter.EOF
oSongIter.Next
SDB.ProcessMessages
Loop
Set oSongIter = Nothing
oItem.Common.Enabled = True
rdbTest1.Common.Enabled = True
End Sub
Sub chkTest_OnClick(oItem)
Dim oSongIter
oItem.Common.Enabled = False
Set oSongIter = SDB.Database.QuerySongs("ID > 0")
Do While Not oSongIter.EOF
oSongIter.Next
SDB.ProcessMessages
Loop
Set oSongIter = Nothing
oItem.Common.Enabled = True
End Sub
[/code]
My Track Redirection script has such problem in its Create Redirections for Duplicates/Folders dialog box, but only if there are many displayed tracks. The test script from above has always reproducible bug.