Konnte leider die neuen Verbesserungen (die sehr interessant + nützlich klingen
) noch nicht mit meinem Projekt testen.
Denn im Moment hänge ich leider bei der weiteren Integration des DynamicDialogs Moduls bei einem Fehler "Dialog window not found!" fest, welcher immer ab dem zweiten Öffnen des gleichen Dialog-Fenters auftritt. Ein zweites/drittes/etc. Öffnen kommt hier in relativ kurzen Zeitabständen (5 - 20 sek) vor, da es sich um ein sich selbständig öffnendes & schließendes Info-Fenster mit der Ergebnisauswertung zur letzten Antwort in einem lfd. Quiz handelt.
Und das komische ist, dass der Fehler immer dann auftritt, wenn ich den standardmäßigen Befehlsablauf gemäß DynamicDialogs Beispielen verwende (der bei mir ja auch mit anderen Dialog-Fenstern funktioniert):
Code: Alles auswählen
; 1) DynamicDialogs command for creating/opening the Dialog window, based on the previously created XML definition:
If Not OpenDialogWindow(#QuizShowResultDialog, XML$, #QuizResultWin, "", #PB_Ignore, #PB_Ignore, 100, 200, WindowID(#QuizWin), #DialogError_MsgBox)
Debug "Error opening the Dialog 'QuizResultWindow'"
Debug "Error: " + DialogError(#QuizShowResultDialog)
;FreeDialog(#QuizShowResultDialog)
UnuseModule DynamicDialogs ; we don't need the Module-Functions anymore
ProcedureReturn
EndIf
Der gleiche XML-Definitions-Code führt zu keinen Fehlern, wenn ich ihn stattdessen mit folgendem (bis zur Integration von DynamicDialogs verwendeten) Code aufrufe:
Code: Alles auswählen
; 2) PB-native creating/opening of the Dialog window, based on the previously - by DynamicDialogs - created XML definition:
xml = CatchXML(#PB_Any, @XML$, StringByteLength(XML$))
If Not xml
Debug "Catching and parsing the XML string failed!"
Debug "Error: " + DialogError(#QuizShowResultDialog)
CallDebugger
FreeDialog(#QuizShowResultDialog)
ProcedureReturn
EndIf
Debug "Catched XML string:"
Debug "--------------------------------------------------------------"
Debug XML$
If Not CreateDialog(#QuizShowResultDialog)
Debug "Dialog creation failed!"
Debug "Error: " + DialogError(#QuizShowResultDialog)
CallDebugger
ProcedureReturn
Else
Debug "Dialog successfully created!"
EndIf
If Not OpenXMLDialog(#QuizShowResultDialog, xml, "", 0, 0, 300, 200, WindowID(#QuizWin))
Debug "Open Dialog failed!"
Debug "Error: " + DialogError(#QuizShowResultDialog)
CallDebugger
FreeDialog(#QuizShowResultDialog)
FreeXML(xml)
ProcedureReturn
Else
Debug "Dialog successfully opened!"
EndIf
Ich bin da gerade etwas ratlos und finde den Fehler nicht. Der zuvor erfolgreich geöffnete Dialog wird jeweils mit
geschlossen. Daran sollte es also auch nicht liegen...
Kann es manchmal sein, dass
OpenDialogWindow(...) irgendetwas macht/speichert, dass
sich nicht mit wiederholten Aufrufen verträgt?
Hier der Vollständigkeit halber noch die Dialog-Definition im "DynamicDialogs [plain]" Stil:
Code: Alles auswählen
UseModule DynamicDialogs ; we need the 'main'-Modul for standard functions
UseModule DynamicDialogs_plain ; we need the 'plain'-Modul for XML-Elements
SetXMLOutputFormat(#XMLout_Indent, 5)
SetXMLOutputFormat(#XMLout_AlignLineBreak, #True)
ClearXML()
Window(#QuizResultWin, "", "", #PB_Window_BorderLess|#PB_Window_WindowCentered) ; there is no window title
Frame(#QuizResultFrame, "", Language("QuizResultQuestion"))
vBox(#Expand_No, #alignCenter, 5)
Text(#QuizResultTitle, "", title$, 0, #PB_Default, #PB_Default, #alignCenter, "", 0, 0, DialogGadgetTextSize(title$, #Font_Big, 0))
If AnswerStatus = #False ; If the user gave a false answer, we will additionally display this false answer here:
Text(#QuizResultFalseAnswer, "", "(" + QuizStatistics()\QuizAnswer$ + ")", 0, #PB_Default, #PB_Default, #alignCenter)
EndIf
Empty(#PB_Default, 10)
Text(#QuizResultAnswer, "", Language("QuizResultCorrectAnswer"))
If image ; 1) if there is an image to display:
hBox(#Expand_No, #alignCenter, 10)
Empty() ; ...and some more space
; directly including the ImageID doesn't work, so we need to set the image after dialog creation using SetGadgetState()...
Image(#QuizResultCorrectImage, "", 0, 0, imagewidth, imageheight, #alignCenter, "", 0, 0, "disabled='yes'") ; flags='#PB_Image_Border'/>"
If QuizStatistics()\QuizAddInfoAnswer$ <> "" ; there was saved a list of all possible answers with their item values (e.g. up-to 5 countries with their area in qkm), 'CRLF$' was used for multiline...
vBox(#Expand_No, #alignCenter, 5)
EndIf
Text(#QuizResultCorrectText, "", QuizAnswers()\Answer, 0, #PB_Default, #PB_Default, #alignCenter, "", 0, 0, DialogGadgetTextSize(QuizAnswers()\Answer, #Font_Big, 10))
If QuizStatistics()\QuizAddInfoAnswer$ <> "" ; there was saved a list of all possible answers with their item values (e.g. up-to 5 countries with their area in qkm), 'CRLF$' was used for multiline...
timer * 3 ; triple the time, how long this information window will be displayed....
Editor(#QuizResultAddInfoAnswer, "", ReplaceString(QuizStatistics()\QuizAddInfoAnswer$, "\n", CRLF$), #PB_Editor_ReadOnly|#PB_Editor_WordWrap)
; XML$ + " " + DialogCreateEditorGadget(QuizStatistics()\QuizAddInfoAnswer$, #QuizResultAddInfoAnswer) + LF$ +
EndVBox()
EndIf
EndHBox()
Else ; 2) if there is no image to display:
Text(#QuizResultCorrectText, "", QuizAnswers()\Answer, 0, #PB_Default, #PB_Default, #alignCenter, "", 0, 0, DialogGadgetTextSize(QuizAnswers()\Answer, #Font_Big, 10))
EndIf
; Now we display the ProgressBar showing the user, how long it will take until the
; Quiz continues...
Empty(#PB_Default, 10) ; ...and some more space
Text(#QuizResultTimerText, "", Language("QuizResultGoingOn"))
ProgressBar(#QuizResultTimerProgress, "", 0, timer, 0, #PB_Default, fontheight)
EndVBox()
EndFrame()
EndWindow()
UnuseModule DynamicDialogs_plain ; we don't need the XML-Elements anymore
; from now on we really need the functions from the 'main'-Modul 'DynamicDialogs'
XML$ = GetXML()
Debug XML$
; 1) DynamicDialogs command for creating/opening the Dialog window, based on the previously created XML definition:
If Not OpenDialogWindow(#QuizShowResultDialog, XML$, #QuizResultWin, "", #PB_Ignore, #PB_Ignore, 100, 200, WindowID(#QuizWin), #DialogError_MsgBox)
Debug "Error opening the Dialog 'QuizResultWindow'"
Debug "Error: " + DialogError(#QuizShowResultDialog)
;FreeDialog(#QuizShowResultDialog)
UnuseModule DynamicDialogs ; we don't need the Module-Functions anymore
ProcedureReturn
EndIf
UnuseModule DynamicDialogs ; we don't need the Module-Functions anymore
Leider nicht direkt lauffähig, da vollständig aus meinem PRojekt übernommen.... sorry!
Vorgenannter Code "produziert" folgenden XML-Code, der beim ersten Anlauf erfolgreich ein Dialog-Fenster öffnet (was dann wie o.g. geschlossen wird), jedoch im zweiten Anlauf beim nächsten zu öffnenden Dialog die o.g. Fehlermeldung bringt:
<window id='6' name='Win_4831624499168' flags='#PB_Window_BorderLess | #PB_Window_WindowCentered'>
<frame id='146' text='Ergebnis der letzten Frage:'>
<vbox expand='no' align='center' spacing='5'>
<singlebox expand='horizontal' align='center' margin='0' colspan='0' rowspan='0'>
<singlebox expand='vertical' align='center' margin='0'>
<text id='147' text='Ihre Antwort war richtig!' width='282' height='31' />
</singlebox>
</singlebox>
<empty height='10'/>
<text id='149' text='Die korrekte Antwort lautete:' margin='0'/>
<hbox expand='no' align='center' spacing='10'>
<empty/>
<singlebox expand='horizontal' align='center' margin='0' colspan='0' rowspan='0'>
<singlebox expand='vertical' align='center' margin='0'>
<image id='151' width='81' height='54' disabled='yes'/>
</singlebox>
</singlebox>
<vbox expand='no' align='center' spacing='5'>
<singlebox expand='horizontal' align='center' margin='0' colspan='0' rowspan='0'>
<singlebox expand='vertical' align='center' margin='0'>
<text id='150' text='Libanon' width='112' height='41' />
</singlebox>
</singlebox>
<editor id='152' text='1. Libanon (594,68 Einwohner je qkm) 2. Kambodscha (86,77 Einwohner je qkm) 3. Norwegen (16,08 Einwohner je qkm) 4. Gabun (6,37 Einwohner je qkm) ' flags='#PB_Editor_ReadOnly | #PB_Editor_WordWrap' margin='0'/>
</vbox>
</hbox>
<empty height='10'/>
<text id='153' text='Gleich geht es weiter...' margin='0'/>
<progressbar id='154' min='0' max='9000' height='20' margin='0'/>
</vbox>
</frame>
</window>
QuizResultWindow dialog freed!
<window id='6' name='Win_721614509551' flags='#PB_Window_BorderLess | #PB_Window_WindowCentered'>
<frame id='146' text='Ergebnis der letzten Frage:'>
<vbox expand='no' align='center' spacing='5'>
<singlebox expand='horizontal' align='center' margin='0' colspan='0' rowspan='0'>
<singlebox expand='vertical' align='center' margin='0'>
<text id='147' text='Ihre Antwort war falsch!' width='274' height='31' />
</singlebox>
</singlebox>
<singlebox expand='horizontal' align='center' margin='0'>
<singlebox expand='vertical' align='center' margin='0'>
<text id='148' text='(Moldawien)'/>
</singlebox>
</singlebox>
<empty height='10'/>
<text id='149' text='Die korrekte Antwort lautete:' margin='0'/>
<hbox expand='no' align='center' spacing='10'>
<empty/>
<singlebox expand='horizontal' align='center' margin='0' colspan='0' rowspan='0'>
<singlebox expand='vertical' align='center' margin='0'>
<image id='151' width='86' height='54' disabled='yes'/>
</singlebox>
</singlebox>
<singlebox expand='horizontal' align='center' margin='0' colspan='0' rowspan='0'>
<singlebox expand='vertical' align='center' margin='0'>
<text id='150' text='Costa Rica' width='135' height='41' />
</singlebox>
</singlebox>
</hbox>
<empty height='10'/>
<text id='153' text='Gleich geht es weiter...' margin='0'/>
<progressbar id='154' min='0' max='3000' height='20' margin='0'/>
</vbox>
</frame>
</window>
Error opening the Dialog 'QuizResultWindow'
Error: Dialog window not found
Wäre für jeglich Ideen & Hilfestellungen dankbar!
Unabhängig davon bieten die o.g. Beispiele evtl. auch "Anschauungsunterricht" für etwas komplexere Dialog-Definitionen mittels DynamicDialogs und integrierten Bedingungen (weil nicht jedes Gadget immer gebraucht wird).