There are two versions of the new Vista TaskDialog functions, a more simple TaskDialog function (like in this post) and a more robust version with a lot more flexability (like text boxs and stuff...) called TaskDialogIndirect. Discovering these begins with accessing the correct version of COMCTL32.dll.
There are two versions of COMCTL32.dll on Windows Vista systems, one (version 5) which is a “legacy” control DLL, and one (version 6) which contains all of the new controls for Windows Vista, the legacy control version is the one installed by default and used mostly, the new version 6 is called by Vista apps. Your application needs to “opt in” to version 6, and to do so you will need to specify a manifest file. So to use the new Vista TaskDialog function you do something like this:
First the code:
Code: Select all
;Windows Vista TaskDialog for PureBasic
;by SFSxOI 27 Jan 2008
;version 1.0
;variables
nHWND.l
hInstance.l
cTitle.s
cDescription.s
cContent.s
pnButton.l
nIcon.l
nResult.l
; CASE test values for button clicks
#IDOK = 1
#IDCANCEL = 2
#IDABORT = 3
#IDRETRY = 4
#IDIGNORE = 5
#IDYES = 6
#IDNO = 7
#IDCLOSE = 8
Enumeration ;_TASKDIALOG_COMMON_BUTTON_FLAGS
#TDCBF_OK_BUTTON = 1 ;selected control Return value IDOK
#TDCBF_YES_BUTTON = 2 ;selected control Return value IDYES
#TDCBF_NO_BUTTON = 4 ;selected control Return value IDNO
#TDCBF_CANCEL_BUTTON = 8 ;selected control Return value IDCANCEL
#TDCBF_RETRY_BUTTON = 16 ;selected control Return value IDRETRY
#TDCBF_CLOSE_BUTTON = 32 ;selected control Return value IDCLOSE
EndEnumeration
;Icons
#TD_ICON_BLANK = 100
#TD_ICON_WARNING = 101
#TD_ICON_QUESTION = 102
#TD_ICON_ERROR = 103
#TD_ICON_INFORMATION = 104
#TD_ICON_BLANK_AGAIN = 105
#TD_ICON_SHIELD = 106
Procedure.l x_Ansi2Uni(string.s)
*out = AllocateMemory(Len(string)*2 * 2)
MultiByteToWideChar_(#CP_ACP, 0, string, -1, *out, Len(string))
ProcedureReturn *out
EndProcedure
Procedure Task_Dialog(nHWND, hInstance, cTitle_x, cDescription_x, cContent_x, dwCommonButtons.l, nIcon_x)
Libef = LoadLibrary_("comctl32.dll")
pnButton.l
If Libef
*Task_Dialog_Func = GetProcAddress_(Libef, "TaskDialog")
If *Task_Dialog_Func
CallFunctionFast(*Task_Dialog_Func, nHWND, hInstance, cTitle_x, cDescription_x, cContent_x, dwCommonButtons.l, nIcon_x, @pnButton.l)
EndIf
EndIf
FreeLibrary_(Libef)
ProcedureReturn pnButton
EndProcedure
cTitlex = x_Ansi2Uni("Task Dialog")
cDescriptionx = x_Ansi2Uni("This is a Task Dialog")
cContentx = x_Ansi2Uni("This is some content to see and something else to add in the Task Dialog to explain something or maybe give some directions and stuff.")
;TaskDialog function takes Unicode
pnButton = Task_Dialog(0, #Null, cTitlex, cDescriptionx, cContentx, #TDCBF_OK_BUTTON | #TDCBF_YES_BUTTON | #TDCBF_CANCEL_BUTTON | #TDCBF_CLOSE_BUTTON, #TD_ICON_INFORMATION)
Select pnButton
Case #IDOK
Debug "You clicked the OK button"
Case #IDYES
Debug "you clicked the Yes button"
Case #IDCANCEL
Debug "You clicked the Cancel button"
Case #IDCLOSE
Debug "You clicked the Close button"
EndSelect
Code: Select all
1 24 "H:\purebasic 4.10\Vista interfaces functions\TaskDialog.manifest"
And then you need the manifest file. This is the code for the manifest file. Copy and paste the below into a text file and save it in your application directory as TaskDialog.manifest
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Microsoft.TestApps.TaskDialog"
type="win32"
/>
<description>TaskDialog Test Application</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
http://i268.photobucket.com/albums/jj24 ... dialog.png