GetFunction fails...but just in this code
Posted: Tue Feb 28, 2023 9:04 pm
I have a modified code of the TaskDialog-Code which worked fine until now. Now it doesn't work anymore, so I thought this would be a bug in 6.01 Beta 4, but the code from the forum still works. My code fails at line 77, when GetFunction is called (it returns 0). Can anybody tell my why?
Also, the original code, which still works (and is not so different from my one): viewtopic.php?p=355016#p355016
The most interesting part for me is, that the GetFunction-line is identical to the one in the original. Also loading the library works fine.
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
EnableExplicit
CompilerEndIf
#TD_WARNING_ICON = -1
#TD_ERROR_ICON = -2
#TD_INFORMATION_ICON = -3
#TD_SHIELD_ICON = -4
#TDF_USE_COMMAND_LINKS = $10 ;Commandlinks statt normale Buttons verwenden
#TDF_ENABLE_HYPERLINKS = $1 ;Links automatisch anzeigen
#TDF_USE_HICON_MAIN = $2 ;Eigenes Icon verwenden
#TDF_USE_HICON_FOOTER = $4 ;Icon in den Footer verschieben (?)
#TDF_EXPAND_FOOTER_AREA = $40 ;Erweiterter Text wird im Footer angezeigt
#TDF_EXPANDED_BY_DEFAULT = $80
#TDF_VERIFICATION_FLAG_CHECKED = $100
#TDF_SHOW_PROGRESS_BAR = $200
#TDF_SHOW_MARQUEE_PROGRESS_BAR = $400
#TDF_CALLBACK_TIMER = $800 ;Callback-Funktion etwa alle 200ms aufrufen
#TDF_POSITION_RELATIVE_TO_WINDOW = $1000 ;Position relativ zu ParenthWnd
#TDF_NO_DEFAULT_RADIO_BUTTON = $4000
#TDF_CAN_BE_MINIMIZED = $8000
#TD_ICON_NONE = 0
#TD_ICON_SHIELD_COLORED_GREY = 65527
#TD_ICON_SHIELD_OK_COLORED = 65528
#TD_ICON_SHIELD_ERROR_COLORED = 65529
#TD_ICON_SHIELD_WARNING_COLORED = 65530
#TD_ICON_SHIELD_COLORED = 65531
#TD_ICON_SHIELD = 65532
#TD_ICON_SHIELD_QUESTION = 65533
#TD_ICON_ERROR = 65534
#TD_ICON_QUESTION = 65535
Structure TASKDIALOGCONFIG
cbSize.l
hwndParent.i
hInstance.i
dwFlags.l
dwCommonButtons.l
*pszWindowTitle
StructureUnion
hMainIcon.i
*pszMainIcon
EndStructureUnion
*pszMainInstruction
*pszContent
cButtons.l
*pButtons.TASKDIALOG_BUTTON
nDefaultButton.l
cRadioButtons.l
*pRadioButtons.TASKDIALOG_BUTTON
nDefaultRadioButton.l
*pszVerificationText
*pszExpandedInformation
*pszExpandedControlText
*pszCollapsedControlText
StructureUnion
hFooterIcon.i
*pszFooterIcon
EndStructureUnion
*pszFooter
*pfCallback
*lpCallbackData
cxWidth.l
EndStructure
Structure TASKDIALOG_BUTTON
nButtonID.l
*pszButtonText
EndStructure
Global fVerifyx, SelRadiox
Procedure Task_DialogIndirect(tdlgx)
Protected ClickedButtonx,Libef=OpenLibrary(#PB_Any,"comctl32.dll"),*Task_Dialog_Func
If Libef
*Task_Dialog_Func = GetFunction(Libef, "TaskDialogIndirect")
Debug *Task_Dialog_Func
If *Task_Dialog_Func
CallFunctionFast(*Task_Dialog_Func, tdlgx, @ClickedButtonx, @SelRadiox, @fVerifyx)
EndIf
EndIf
CloseLibrary(Libef)
If ClickedButtonx<1000
ProcedureReturn 0
Else
ProcedureReturn ClickedButtonx-1000
EndIf
EndProcedure
Global Dim TD_Buttons.TASKDIALOG_BUTTON(8)
Define tdcount
For tdcount=0 To ArraySize(TD_Buttons())
TD_Buttons(tdcount)\nButtonID=tdcount+1001
Next
Global Dim TD_RADIOButtons.TASKDIALOG_BUTTON(8)
For tdcount=0 To ArraySize(TD_RADIOButtons())
TD_RADIOButtons(tdcount)\nButtonID=tdcount+1001
Next
Procedure TaskDialog(title.s,flags,icon,headline.s,text.s,bCount,defbutton,rcount,defradio,checkbox.s,expando.s,expand.s,collapse.s,footericon,footer.s,Parent=0)
Protected tdlg.TASKDIALOGCONFIG
tdlg\cbSize = SizeOf(tdlg)
tdlg\hwndParent = Parent;#Null
tdlg\hInstance = #Null
tdlg\dwFlags = flags
tdlg\dwCommonButtons = #Null
tdlg\pszWindowTitle = @title
tdlg\hMainIcon = icon
tdlg\pszMainInstruction = @headline
tdlg\pszContent = @text
tdlg\cButtons = bCount
tdlg\pButtons = @TD_Buttons(0)\nButtonID
tdlg\cRadioButtons = rcount
tdlg\pRadioButtons = @TD_RADIOButtons(0)\nButtonID
tdlg\nDefaultButton = defbutton
tdlg\nDefaultRadioButton = defradio
tdlg\pszVerificationText = @checkbox
tdlg\pszExpandedInformation = @Expando
tdlg\pszExpandedControlText = @expand
tdlg\pszCollapsedControlText = @collapse
tdlg\hFooterIcon = footericon
tdlg\pszFooter = @footer
tdlg\pfCallback = #Null
ProcedureReturn Task_DialogIndirect(tdlg)
EndProcedure
If #PB_Compiler_IsMainFile
Define eintext.s,enttext.s,backtext.s,ClickedButton
eintext.s="iTAC einfügen"+#LF$+"Fügt alle erforderlichen Daten für die iTAC-Anbindung ein. Erstellt außerdem eine Pre-Datei, die aber manuell angepasst werden muss."
TD_Buttons(0)\pszButtonText = @eintext
enttext.s="iTAC entfernen"+#LF$+"Entfernt alle iTAC-relevanten Daten und stellt den Normalzustand mit DMC wieder her."
TD_Buttons(1)\pszButtonText = @enttext
backtext.s="Zurück"+#LF$+"Keine Änderungen vornehmen"
TD_Buttons(2)\pszButtonText = @backtext
TD_RADIOButtons(0)\pszButtonText = @"Radio 1"
TD_RADIOButtons(1)\pszButtonText = @"Radio 2"
TD_RADIOButtons(2)\pszButtonText = @"Radio 3"
ClickedButton = TaskDialog("iTAC-Optionen",#TDF_USE_COMMAND_LINKS|#TDF_EXPAND_FOOTER_AREA,#TD_ICON_SHIELD_OK_COLORED,"Wählen Sie eine iTAC-Option aus:","Der iTAC kann eingefügt oder entfernt werden.",3,3,0,0,"","","","",0,"")
;fVerifyx -> Checkbox gecheckt
;SelRadiox -> Gewählter Radiobutton (1. Index ist 1)
;ClickedButton -> Gewählter Button (1. Index ist 1)
EndIf
The most interesting part for me is, that the GetFunction-line is identical to the one in the original. Also loading the library works fine.