-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Yes; specify the window (e.g. Me.hwnd when calling from a Form/UC) as the parent with .ParentHwnd, and use the TDF_POSITION_RELATIVE_TO_WINDOW flag in .dwFlags;
Code:
With TaskDialog1
.Flags = TDF_POSITION_RELATIVE_TO_WINDOW
.ParenthWnd = Me.hWnd
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thank you, it works.
The crucial point is:
.Flags = TDF_POSITION_RELATIVE_TO_WINDOW
Without this it doesn't work.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Project Updated - Version 1.4 (Universal Compatibility)
After review, I've included the undocumented additional common buttons that were used in the AccessUI version (thanks!). The following .CommonButtons are now available, with their return value given in parentheses:
Code:
TDCBF_ABORT_BUTTON (TD_ABORT)
TDCBF_IGNORE_BUTTON (TD_IGNORE)
TDCBF_TRYAGAIN_BUTTON (TD_TRYAGAIN)
TDCBF_CONTINUE_BUTTON (TD_CONTINUE)
TDCBF_HELP_BUTTON **This will raise the Help Event, and will not close the dialog.**
The Help button works everywhere, *including MS Access*. Unfortunately, the AccessUI version had a typo; the release had 16384 which isn't anything-- but it looks like they just had a typo originally, there's a comment '104857 which of course makes no sense... but if you convert these values to hex, you find &H10000, &H20000, &H40000, and &H80000 for the other new buttons... &H100000 is **1048576** in decimal-- so they just cut off a digit when copying it down. &H100000 works in Access, I checked.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thank you very much. Note that I had to delete all the 'PtrSafe' to test it on my VB6.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Apologies, I had the wrong version of mTDSample.bas in the zip. I've updated now to include the correct one and double checked it's fine in VB6.
(PS- You shouldn't have needed to remove them from anything besides mTDSample.bas; everywhere else they werre fine-- they appear in red, but are inside conditional compilation blocks so the VB6 compiler doesn't see them; that's now the case with mTDSample.bas too).
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thanks a lot. Yes you're right, I had only changed mTDSample.bas. New version is fine. Cheers.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Incredibly impressive project! Great work. Thanks for this fafalone!
Is there a way to make all of the fonts size 11?
Is there a way to make this function non-modal? I could never get a messagebox to work that would allow processing while waiting for the user to press OK.
Code:
Public Function SimpleDialog(sMessage As String, Optional dwBtn As TDBUTTONS = TDCBF_OK_BUTTON, Optional sTitle As String, Optional sMainText As String, Optional dwIco As TDICONS, Optional hWndOwner As LongPtr, Optional hInst As LongPtr) As TDRESULT
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
The font is controlled by the system unfortunately... since it's a Direct2D painted window I don't know any way to easily change that (besides changing it system-wide). You could change it for the custom controls, but that's it.
The simple dialog function should be nonmodal just by omitting hWndOwner.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hi, I just upgraded/updated my cTaskDialog implementation from ver. 1.2R2 to 1.4U and when trying to compile my project I notice that somehow the ability to add itemData to combobox when adding an item has got lost. We
added this function back in 2021 if you remember?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Did that ever make it into an official release? It's not in the 1.2 R2 release zip but I did find a dev version with it. Anyway, you can add back the same changes in that post, just using LongPtr for the lParam instead of Long. I'll update the release tonight.
'
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I have a zip here it was added to but not sure if it's an official or not, maybe not. I was forced to take a break from VB6 for 2 years and just back some weeks ago so haven't kept up with all changes.
Waiting for the update as I see there has been other changes as well so better let you put it together ;-)
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Alright I posted a beta version, try it out, if everything works right that will be just the final version.
https://github.com/fafalone/cTaskDia...log-1.4.1-beta
The project now requires mTDHelper.bas in addition to cTaskDialog.cls; this was to to be able to use a single subclassing method that also worked in VBA 64bit and twinBASIC 64bit ('Universal compatibility' means you can use the .cls/.bas complete unmodified across the entire VB6 language world; VB6, VBA6, VBA7 32bit, VBA 64bit, twinBASIC 32bit, and twinBASIC 64bit.)
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Ok thanks, I will test it. I will also try to add my "ComboNewIndex" property, which I use in my code already. It makes it possible to check against a stored value and re-initialize a certain list item from last run. Simply put, a combobox (and listbox as well) isn't complete without a newitem property.
Not sure how much time I'll have to test all this now though as I will leave for a road trip early next week and may be gone for a month, with limited computer and internet capabilities.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Going through the code I am just wondering if these changes aren't needed as well (my additions in Bold, and red to make it easier to see)?
Code:
Public Sub Init()
'resets the entire module
mPageIndex = 0
...
ReDim aComboItems(0)
tComboInit.sText = ""
tComboInit.iImage = 0
tComboInit.iOverlay = 0
tComboInit.lpData = 0
nCbType = 0
and
Code:
Private Sub AddComboBox(nType As ComboType)
Dim lEditX As Long, lEditY As Long, cxEdit As Long, cyEdit As Long
Dim lOffX As Long
Dim tRC As RECT
m_HasCustomControl = True
...
If himlCombo Then
Call SendMessageW(hCombo, CBEM_SETIMAGELIST, 0, ByVal himlCombo)
End If
For I = 0 To UBound(aComboItems)
CBX_InsertItem hCombo, aComboItems(i).sText, aComboItems(i).iImage, aComboItems(i).iOverlay, aComboItems(i).lpData
Next I
If bCBInitValid Then
Dim cbxi As COMBOBOXEXITEMW
and
Code:
Public Sub ComboSetInitialState(sText As String, Optional iImage As Long = -1, Optional iOverlay As Long = -1, Optional lParam As LongPtr = 0)
bCBInitValid = True
tComboInit.sText = sText
tComboInit.iImage = iImage
tComboInit.iOverlay = iOverlay
tComboInit.lpData = lParam
End Sub
Then there are some functions starting with zzCombo... but not really sure what they are about as zz is often used for subclassed stuff (from what I remember) but not sure if it's the case here or if it's something for development/testing or what.
Anyway, still a bit VB6 rusty, so I may have missed something or got the above wrong. It's a big and complex, but very useful, class.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Here is my implementation of a NewIdex property as well, very simple and few lines of code:
DEclaration part
Code:
Private nComboIdx As Long
Private nComboNewIndex As Long
We only need a Get property
Code:
Public Property Get ComboHeight() As Long: ComboHeight = cyCombo: End Property
Public Property Get ComboNewIndex() As Long: ComboNewIndex = nComboNewIndex: End Property
And the asigment of value in the
Code:
Public Sub ComboAddItem(...)
If aComboItems(0).sText = "" Then
aComboItems(0).sText = sText
aComboItems(0).iImage = iImage
aComboItems(0).iOverlay = iOverlay
aComboItems(0).lpData = lParam
nComboNewIndex = 0
Exit Sub
End If
ReDim Preserve aComboItems(UBound(aComboItems) + 1)
aComboItems(UBound(aComboItems)).sText = sText
aComboItems(UBound(aComboItems)).iImage = iImage
aComboItems(UBound(aComboItems)).iOverlay = iOverlay
aComboItems(UBound(aComboItems)).lpData = lParam
nComboNewIndex = UBound(aComboItems)
If hCombo Then
As long as not the ability to insert an item in the middle of the list, it could stay this simple...
Also, would like to point out that you have introduced as backward incompatibility issue by changing
Code:
Public Enum TDBUTTONS
to
Code:
Public Enum TASKDIALOG_COMMON_BUTTON_FLAGS
As this Enum is likely to be used in project code using cTaskDialog.cls
Not a big problem as it throws a compile error but it shoul dbe noted in the change log to not leave programmers dazed and :confused:
EDIT: My wrong on the latter, it was because my code was based on 1.2R2, before
Code:
Version 1.2.6 Universal
'Bug fix: SimpleDialog return TDBUTTONS insted of TDRESULT
which made should have been written " SimpleDialog returned TDBUTTONS insted of TDRESULT" :D
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
CBX_InsertItem definitely needs to include it yeah; but tComboInit isn't an actual item; it's just to set the edit box.
ComboNewIndex... I'm not sure the name really captures what it represents; just seems like it would be better as a ComboItemCount property, but then I'd figured the user inserted the items... they should know how many... I'll add it though.
And yeah should have mentioned the enum name change, sorry. It was changed for correctness; that's the official name in the Windows SDK and on MSDN.
I've updated the beta with these changes; https://github.com/fafalone/cTaskDia...log-1.4.1-beta
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Project Update - cTaskDialog 1.5 Universal Compatibility Version
This version adds the features requested by 7edm above for Combo Item lpData and ComboNewIndex, and now also no longer requires a manifest for comctl32 6.0. While it's still preferable if you use one, in response to this issue/request, I've added code that uses the SxS Activation Context API to briefly activate comctl6 for the call to TaskDialogIndirect (or TaskDialog, in .SimpleDialog), since it's impractical to ask people you distribute VBA files to to have modified Office exes. It uses code from my twinBASIC Control Panel Applet demo, originally used to get comctl6 Visual Styles in a standard DLL where the host exe didn't have a manifest, which now works with this courtesy of a great tip from VBF user VanGoghGaming.
It works like this... it's first prepared in Class_Initialize:
Code:
hActCtx = INVALID_HANDLE_VALUE
If (IsComCtl6 = False) And (useropt_no_force_comctl6 = False) Then
hShell32 = LoadLibrary("shell32.dll")
szSys = Environ$("WINDIR") & "\System32"
Dim ctx As ACTCTX
ctx.cbSize = LenB(ctx)
ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID Or ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID Or ACTCTX_FLAG_HMODULE_VALID
ctx.hModule = hShell32
ctx.lpResourceName = 124
ctx.lpAssemblyDirectory = StrPtr(szSys)
hActCtx = CreateActCtx(ctx)
End If
Then the TaskDialogIndirect call is wrapped by:
Code:
If hActCtx <> INVALID_HANDLE_VALUE Then 'we need to activate comctl32.dll 6.0
Dim lActCtxCookie As LongPtr
ActivateActCtx hActCtx, lActCtxCookie
End If
hr = TaskDialogIndirect(uTDC, pnButton, pnRadButton, pfVerify)
If hActCtx <> INVALID_HANDLE_VALUE Then
DeactivateActCtx 0, lActCtxCookie 'Deactivate, because we don't want to interfere with the rest of the app
End If
It's then release when the class terminates.
Project also on GitHub.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
the latest version for vb6
Private Sub Command13_Click()
Dim td As TDBUTTONS 'User Defined Type not Defined
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Sorry I renamed that enum to the actual SDK/MSDN name, TASKDIALOG_COMMON_BUTTON_FLAGS. I updated the zip and GitHub Form1.frm but that's the only change.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
fafalone
ComboNewIndex... I'm not sure the name really captures what it represents; just seems like it would be better as a ComboItemCount property, but then I'd figured the user inserted the items... they should know how many... I'll add it though.
[/url]
VB6 builtin and Common Controls ComboBox & ListBox both contains the property "NewIndex", which is the ListIndex of the last added item, which not necessarily is the same as the count if an item was added somewhere among existing items, which isn't an isse here at present at least. I prefixed it with Combo as you have used that style but I think NewIndex part shouldn't change as it's a well known (well not by you obviously :eek: ) world in the context.
So note, it's not the same as the list count but is meant to be used for direct code operations in connection with an item being added..
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
fafalone
Project Update - cTaskDialog 1.5 Universal Compatibility Version
This version adds the features requested by 7edm above for Combo Item lpData and ComboNewIndex, and now also no longer requires a manifest for comctl32 6.0. While it's still preferable if you use one, in response to
this issue/request, I've added code that uses the SxS Activation Context API to briefly activate comctl6 for the call to TaskDialogIndirect (or TaskDialog, in .SimpleDialog), since it's impractical to ask people you distribute VBA files to to have modified Office exes. It uses code from my twinBASIC Control Panel Applet demo, originally used to get comctl6 Visual Styles in a standard DLL where the host exe didn't have a manifest, which now works with this courtesy of a great tip from VBF user VanGoghGaming.
It works like this... it's first prepared in Class_Initialize:
Code:
hActCtx = INVALID_HANDLE_VALUE
If (IsComCtl6 = False) And (useropt_no_force_comctl6 = False) Then
hShell32 = LoadLibrary("shell32.dll")
szSys = Environ$("WINDIR") & "\System32"
Dim ctx As ACTCTX
ctx.cbSize = LenB(ctx)
ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID Or ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID Or ACTCTX_FLAG_HMODULE_VALID
ctx.hModule = hShell32
ctx.lpResourceName = 124
ctx.lpAssemblyDirectory = StrPtr(szSys)
hActCtx = CreateActCtx(ctx)
End If
Then the TaskDialogIndirect call is wrapped by:
Code:
If hActCtx <> INVALID_HANDLE_VALUE Then 'we need to activate comctl32.dll 6.0
Dim lActCtxCookie As LongPtr
ActivateActCtx hActCtx, lActCtxCookie
End If
hr = TaskDialogIndirect(uTDC, pnButton, pnRadButton, pfVerify)
If hActCtx <> INVALID_HANDLE_VALUE Then
DeactivateActCtx 0, lActCtxCookie 'Deactivate, because we don't want to interfere with the rest of the app
End If
It's then release when the class terminates.
Project also on GitHub.
how to use ActCtx tech to add get more manifest features?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
@7edm, got it. Forgot those existed honestly. The new version covers that ok though?
@loquat, the code shows you how; you just need to activate it before the calls that create whatever you want the manifest loaded by CreateActCtx to apply to. I've never tried this with Forms though; you'd probably need it activated before the form is loaded at all. What specifically are you trying to do?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I don't know if it makes any difference in this case but I would avoid using "Environ" or any other VB6 string functions that are not Unicode-capable. GetSystemDirectoryW should do the trick here.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Pretty sure a lot more than cTaskDialog would break if someone installed Windows to a non-ANSI path, if that's even allowed. I'll change it just in case but low priority so it will be in the next update but not updating just for that.
-
1 Attachment(s)
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Rename controls' name on VB6 Form1.frm from Commandxx to meaningful names like cmdWithSliderBasicSlider
Attachment 192015
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
fafalone
@loquat, the code shows you how; you just need to activate it before the calls that create whatever you want the manifest loaded by CreateActCtx to apply to. I've never tried this with Forms though; you'd probably need it activated before the form is loaded at all. What specifically are you trying to do?
like ocx regfree/XPThemes/Administrator rights
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
For themes, you just have to activate the manifest with ActivateActCtx prior to CreateWindowEx being called; for a VB Form that's probably prior to the form loading at all but I'm not sure.
You can't change admin status during runtime.
Regfree OCX is a problem because the manifest you're loading has to come from somewhere... this method allows you to dynamically load a manifest from somewhere other than the exe, it doesn't eliminate the requirement all together.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
fafalone
I'll change it just in case but low priority so it will be in the next update but not updating just for that.
You could eliminate it altogether since the "ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID" flag is not needed in this scenario. :p
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Great code fafalone! I know that the font size of the main content in the cTaskDialog is controlled by the system, but is there a simple way to allow for making parts of the text (BOLD)? This is possible with a standard (msgbox) using a little code. Is there any code adjustments that would allow using the "@" sign, or any other character, as an identifier of bold vs regular text in the (.content) section of a dialog layout? Thanks in advance!
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Not that I'm aware of... the problem is it's that DirectUI opaque crap, so it's hard to customize.
But between also having a main instruction area and footer etc; you can design emphasis other ways. If not you'd probably need to make a one off custom form made up to look like the dialog.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I've been using this in VB6 and I noticed that in all the Input Box examples you can tab out of the input box, but you can't tab back into it.
Is there a fix for this?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Kind of surprised even tabbing out works... I guess since the TextBox has it as a parent, but then the dialog doesn't know about outside child controls. I'll try a few things but the big problem with these dialog boxes is everything is on a single hwnd so you can't for instance subclass individual controls to take over WM_KILLFOCUS.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thanks for this excellent project, fafalone.
It would be nice if the tabbing in was fixed, but it's not a big deal.
Don't spend too much time messing with it :)
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Project Update - cTaskDialog 1.6 Universal Compatibility Version
Version 1.6 Universal adds .InputPasswordChar to set any character as the password char and correctly updates an active dialog if needed, custom icon support for the Abort/Ignore/Try Again/Continue/Help common buttons, and a number of long overdue bug fixes.
Code:
'Version 1.6.2 (1.6 R2)
'-Common button icon for Help should not have been excluded.
'Version 1.6.0
'-Add property InputPasswordChar to set a custom password char.
' Set as a Unicode AscW value (Integer). The black dot is the default.
'-Common button icons now supported for Abort, Ignore, Try Again, and Continue.
'-Bug fix: Custom button icons off by one if radio buttons present
'-Bug fix: Shell32 Icon IDs could fail without explicitly loading shell32.dll.
'-Demos: twinBASIC Password demo updated to show use of the VerifyText checkbox to
' toggle whether the password is visible by using .InputPasswordChar
'Version 1.5.3 (1.5 R3)
'-Bug fix: Public const in class.
'
'Version 1.5.2 (1.5 R2)
'-Changed missed Debug.Print statements to DebugAppend and set useropt_dbg_PrintToImmediate
' to False by default, so the class will no longer print debug messages unless changed.
'-Helper module has been condensed back to the original compact form; it was only expanded
' while trying to find a VBA bug workaround now solved by MagicalTDInitFunction.
'-Bug fix: zzGetCommonButtonIcon and ResultComboData Long instead of LongPtr.
'-Corrected misc spelling mistakes highlighted by the AccessUI version :)
Project also on GitHub