;Autor: SFSxOI #IDOK = 1 #IDCANCEL = 2 #IDABORT = 3 #IDRETRY = 4 #IDIGNORE = 5 #IDYES = 6 #IDNO = 7 #IDCLOSE = 8 #TD_WARNING_ICON = 65535 ;MAKEINTRESOURCEW(-1) #TD_ERROR_ICON = 65534 ;MAKEINTRESOURCEW(-2) #TD_INFORMATION_ICON = 65533 ;MAKEINTRESOURCEW(-3) #TD_SHIELD_ICON = 65532 ;MAKEINTRESOURCEW(-4) #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 Enumeration ;_TASKDIALOG_FLAGS #TDF_ENABLE_HYPERLINKS = 1 #TDF_USE_HICON_MAIN = 2 #TDF_USE_HICON_FOOTER = 4 #TDF_ALLOW_DIALOG_CANCELLATION = 8 #TDF_USE_COMMAND_LINKS = 16 #TDF_USE_COMMAND_LINKS_NO_ICON = 32 #TDF_EXPAND_FOOTER_AREA = 64 #TDF_EXPANDED_BY_DEFAULT = 128 #TDF_VERIFICATION_FLAG_CHECKED = 256 #TDF_SHOW_PROGRESS_BAR = 512 #TDF_SHOW_MARQUEE_PROGRESS_BAR = 1024 #TDF_CALLBACK_TIMER = 2048 #TDF_POSITION_RELATIVE_TO_WINDOW = 4096 #TDF_RTL_LAYOUT = 8192 #TDF_NO_DEFAULT_RADIO_BUTTON = 16384 #TDF_CAN_BE_MINIMIZED = 32768 EndEnumeration Enumeration ; _TASKDIALOG_NOTIFICATIONS #TDN_CREATED = 0 #TDN_NAVIGATED = 1 #TDN_BUTTON_CLICKED = 2 ; wParam = Button ID #TDN_HYPERLINK_CLICKED = 3 ; lParam = (LPCWSTR)pszHREF #TDN_TIMER = 4 ; wParam = Milliseconds since dialog created Or timer reset #TDN_DESTROYED = 5 #TDN_RADIO_BUTTON_CLICKED = 6 ; wParam = Radio Button ID #TDN_DIALOG_CONSTRUCTED = 7 #TDN_VERIFICATION_CLICKED = 8 ; wParam = 1 If checkbox checked 0 If Not lParam is unused And always 0 #TDN_HELP = 9 #TDN_EXPANDO_BUTTON_CLICKED = 10 ; wParam = 0 (dialog is now collapsed) wParam != 0 (dialog is now expanded) EndEnumeration Enumeration ; _TASKDIALOG_ELEMENTS #TDE_CONTENT #TDE_EXPANDED_INFORMATION #TDE_FOOTER #TDE_MAIN_INSTRUCTION EndEnumeration Enumeration ; _TASKDIALOG_ICON_ELEMENTS #TDIE_ICON_MAIN #TDIE_ICON_FOOTER EndEnumeration 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 Enumeration ; _TASKDIALOG_MESSAGES #TDM_NAVIGATE_PAGE = #WM_USER+101 #TDM_CLICK_BUTTON = #WM_USER+102 ; wParam = Button ID #TDM_SET_MARQUEE_PROGRESS_BAR = #WM_USER+103 ; wParam = 0 (nonMarque) wParam != 0 (Marquee) #TDM_SET_PROGRESS_BAR_STATE = #WM_USER+104 ; wParam = new progress state #TDM_SET_PROGRESS_BAR_RANGE = #WM_USER+105 ; lParam = MAKELPARAM(nMinRange nMaxRange) #TDM_SET_PROGRESS_BAR_POS = #WM_USER+106 ; wParam = new position #TDM_SET_PROGRESS_BAR_MARQUEE = #WM_USER+107 ; wParam = 0 (stop marquee) wParam != 0 (start marquee) lparam = speed (milliseconds between repaints) #TDM_SET_ELEMENT_TEXT = #WM_USER+108 ; wParam = element (TASKDIALOG_ELEMENTS) lParam = new element text (LPCWSTR) #TDM_CLICK_RADIO_BUTTON = #WM_USER+110 ; wParam = Radio Button ID #TDM_ENABLE_BUTTON = #WM_USER+111 ; lParam = 0 (disable) lParam != 0 (enable) wParam = Button ID #TDM_ENABLE_RADIO_BUTTON = #WM_USER+112 ; lParam = 0 (disable) lParam != 0 (enable) wParam = Radio Button ID #TDM_CLICK_VERIFICATION = #WM_USER+113 ; wParam = 0 (unchecked) 1 (checked) lParam = 1 (set key focus) #TDM_UPDATE_ELEMENT_TEXT = #WM_USER+114 ; wParam = element (TASKDIALOG_ELEMENTS) lParam = new element text (LPCWSTR) #TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = #WM_USER+115 ; wParam = Button ID lParam = 0 (elevation Not required) lParam != 0 (elevation required) #TDM_UPDATE_ICON = #WM_USER+116 ; wParam = icon element (TASKDIALOG_ICON_ELEMENTS) lParam = new icon (hIcon If TDF_USE_HICON_* was set PCWSTR otherwise) EndEnumeration Structure TASKDIALOG_BUTTON nButtonID.l pszButtonText.l EndStructure Structure TASKDIALOGCONFIG cbSize.l hwndParent.l hInstance.l dwFlags.l dwCommonButtons.l pszWindowTitle.l StructureUnion hMainIcon.l pszMainIcon.l EndStructureUnion pszMainInstruction.l pszContent.l cButtons.l pButtons.l nDefaultButton.l cRadioButtons.l pRadioButtons.l nDefaultRadioButton.l pszVerificationText.l pszExpandedInformation.l pszExpandedControlText.l pszCollapsedControlText.l StructureUnion hFooterIcon.l pszFooterIcon.l EndStructureUnion pszFooter.l pfCallback.l lpCallbackData.l cxWidth.l EndStructure Macro MAKEINTRESOURCE(I) ; forum code (I) EndMacro Macro MakeLong(loWord, hiWord) ; forum code - Flype ( hiWord << 16 | loWord ) EndMacro Macro MAKEWPARAM(loWord, hiWord) ; forum code - Flype MakeLong(loWord, hiWord) EndMacro Macro MAKELPARAM(loWord, hiWord) ; forum code - Flype MakeLong(loWord, hiWord) EndMacro Macro MAKELRESULT(loWord, hiWord) ; forum code - Flype MakeLong(loWord, hiWord) EndMacro Procedure.l x_Ansi2Uni(string.s) ; forum code - Droopy I think *out = AllocateMemory(Len(string)*2 * 2) MultiByteToWideChar_(#CP_ACP, 0, string, -1, *out, Len(string)) ProcedureReturn *out EndProcedure Procedure.s x_Uni2Ansi(Pointer) ; forum code - Droopy I think Buffer.s=Space(512) WideCharToMultiByte_(#CP_ACP,0,Pointer,-1,@Buffer,512,0,0) ProcedureReturn Buffer EndProcedure Procedure Task_DialogIndirect(m_config) Global m_selectedButtonId.l, m_selectedRadioButtonId.l, m_verificationChecked.l Libef = LoadLibrary_("comctl32.dll") If Libef *Task_Dialog_Func = GetProcAddress_(Libef, "TaskDialogIndirect") If *Task_Dialog_Func CallFunctionFast(*Task_Dialog_Func, m_config, @m_selectedButtonId, @m_selectedRadioButtonId, @m_verificationChecked) EndIf EndIf FreeLibrary_(Libef) ProcedureReturn EndProcedure #ID_BUTTON_INSTALL_SINGLE_USER = 1000 #ID_BUTTON_INSTALL_MULTI_USER = 1001 #ID_BUTTON_DO_NOT_INSTALL = 1002 Procedure TDCallback(handle, notification, wParam, lParam, userdata) ; just did lParam = userdata for example ; the URL is really passed in lParam ; but I wanted to also use the lpCallbackData in the ; TASKDIALOGCONFIG structure for example purposes. ; notice something here also, the URL is really a ANSII string but ; lpCallbackData takes a pointer and the callback gets whats in ; lpCallbackData but lParam and userdata are used here as long. lParam = userdata Select notification Case #TDN_HYPERLINK_CLICKED ShellExecute_(#Null,"open",lParam,#NULL$,#NULL$,#SW_SHOWMAXIMIZED) no_closeDialog = #True Case #TDN_BUTTON_CLICKED ; got a button click now filter for which button If wParam = #ID_BUTTON_INSTALL_SINGLE_USER no_closeDialog = #True ; do something here like call another pocedure after we filter the buttons ; like MyDoSomethingProc(button#, , no_closeDialog) ; no_closeDialog = #True - if the callback returns false the dialog closes ; this is not the exact setup, its for example purposes Debug "Sorry, You can only install this client on a Tuesdays." EndIf If wParam = #ID_BUTTON_INSTALL_MULTI_USER ; do something here like call another pocedure after we filter the buttons Debug "You may only install the client multi-user version if your name is Bud!" no_closeDialog = #True EndIf If wParam = #ID_BUTTON_DO_NOT_INSTALL Debug"OK, fine...be that way then, see if I care :)" no_closeDialog = #False EndIf Case #TDN_RADIO_BUTTON_CLICKED Debug "#TDN_RADIO_BUTTON_CLICKED" no_closeDialog = #True Case #TDN_VERIFICATION_CLICKED Debug "#TDN_VERIFICATION_CLICKED" no_closeDialog = #True Case #TDN_EXPANDO_BUTTON_CLICKED Debug "Now, just why do you want to peek in here..hmmmm?" no_closeDialog = #True EndSelect ; this is not the exact setup, its for example purposes ; normally this procedure returns #S_OK for the entire pocedure ; but since we ae not using a real window here and this ; is only an example we just return no_closeDialog ; in our example where a #False or #S_OK will close the dialog. ; In an actual application, to prevent the Task Dialog from ; closing the application must return #True ProcedureReturn no_closeDialog EndProcedure Procedure Install_Stuff_Example() stTaskConfig.TASKDIALOGCONFIG ZeroMemory_(@stTaskConfig,SizeOf(TASKDIALOGCONFIG)) stTaskConfig\cbSize = SizeOf(TASKDIALOGCONFIG) stTaskConfig\hwndParent = #Null stTaskConfig\hInstance = #Null stTaskConfig\pszMainIcon = #TD_ICON_SHIELD stTaskConfig\dwFlags = #TDF_ALLOW_DIALOG_CANCELLATION | #TDF_USE_COMMAND_LINKS | #TDF_EXPAND_FOOTER_AREA | #TDF_ENABLE_HYPERLINKS WindowTitle = x_Ansi2Uni("Vista TaskDialog Example for PureBasic") MainInstruction = x_Ansi2Uni("Do you want to install messenger client?") Content = x_Ansi2Uni("This client is needed to communicate with third party applications.") ExpandedInformation = x_Ansi2Uni("Task Dialog By SFSxOI for PureBasic, PureBasic Web Site") http$ = "http://www.purebasic.fr/english/viewtopic.php?t=30801" ExpandedControlText = x_Ansi2Uni("Show concise") CollapsedControlText = x_Ansi2Uni("More information") VerificationText = x_Ansi2Uni("Do not prompt me again") stTaskConfig\pszWindowTitle = WindowTitle stTaskConfig\pszMainInstruction = MainInstruction stTaskConfig\pszContent = Content stTaskConfig\pszExpandedInformation = ExpandedInformation stTaskConfig\pszExpandedControlText = ExpandedControlText stTaskConfig\pszCollapsedControlText = CollapsedControlText stTaskConfig\pszVerificationText = VerificationText stTaskConfig\cButtons = 3 Dim buttons.TASKDIALOG_BUTTON(2) buttons(0)\nButtonID = #ID_BUTTON_INSTALL_SINGLE_USER buttons(0)\pszButtonText = x_Ansi2Uni("Install single user client software.") buttons(1)\nButtonID = #ID_BUTTON_INSTALL_MULTI_USER buttons(1)\pszButtonText = x_Ansi2Uni("Install network client software.") buttons(2)\nButtonID = #ID_BUTTON_DO_NOT_INSTALL buttons(2)\pszButtonText = x_Ansi2Uni("Do not install.") stTaskConfig\pButtons = @buttons(0)\nButtonID stTaskConfig\nDefaultButton = #ID_BUTTON_INSTALL_SINGLE_USER stTaskConfig\pfCallback = @TDCallback() ; register the callback stTaskConfig\lpCallbackData = @http$ ; our web link to pass to the callback Task_DialogIndirect(@stTaskConfig) EndProcedure Install_Stuff_Example()