-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
thanks fafalone, it works now
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
found that, it works fine in vba now...
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
fafalone - thanks so much for making this available. I'll put it to good use modernizing my message boxes!
I am seeing a problem however which is a bit unsettling. When I run the demo for a while, one of two problems will happen - MZTools will crash or the VB6 IDE will lock up. I'm concerned that this may point to some instability in the code somewhere - memory leaks, unreleased handles, subclassing which is unsafe in the IDE, etc... Have you or anyone else seen instability issues running this code?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I think MZTools is a bit unstable. I have used it in the past (before even fafalone released this class) and I also had some issues.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
Cube8
I think MZTools is a bit unstable. I have used it in the past (before even fafalone released this class) and I also had some issues.
I have not seen this issue before with MZTools. It happens only when running this demo. Looking at the code I see that it uses subclassing. I've always found subclassing to be a bit wonky and dangerous when run from the IDE. I've added code which checks if it's running in the IDE and if so, don't execute the subclassing related code. I'll monitor if this resolves the issue - so far it has.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Its possible theres some issue with subclassing in the IDE... it's hard to track though when its something that would be tough to reproduce. I've been meaning to swap out the subclassing methods on this project to eliminate the requirement for a extra module anyway, sounds like a good excuse for me to just do that, as the self-subclass technique seems much more stable in the IDE in any case.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I discovered two problems in your custom flag values - they both conflict with already defined values.
Custom flag TDF_DATETIME conflicts with the existing TDF_SIZE_TO_CONTENT (&H1000000)
Custom flag TDF_USE_SHELL32_ICONID conflicts with the existing TDF_NO_SET_FOREGROUND (&H10000)
The first one is the one which caused me to discover the problem. When setting the dialog to size to content, a datetime control was appearing on the dialog.
I've changed the values for these two custom flags to the next available values:
TDF_USE_SHELL32_ICONID = &H4000000
TDF_DATETIME = &H8000000
And all works fine on my end.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
It seems I omitted TDF_NO_SET_FOREGROUND because it's new to Win8 and I must have copied the Win7 SDK,
But it any case, it seems I completely forgot about the nearly finished next version, in which I had already corrected the conflicts :eek:
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
cTaskDialog 1.1 Released!
The flag issues mentioned by AAraya have been fixed along with several other improvements, including now being self-contained without a .bas needed.
Code:
'NEW IN VERSION 1.1
'--The cTaskDialog class is now entirely self-contained- using Paul Caton/LaVolpe's self-sub
' self-callback routines to eliminate the need for a module or presence of the TaskDialog__Procs.
'--Additional left-right-center alignment for custom controls has been added. For the additions,
' they are only relevent if the control is being used with a fixed width. Given this, automatic
' prevention of only allowing 1 control per location has been disabled-- however, it is the on
' the caller to ensure there's no overlap.
'--To further aid in this, you can now specify a manual offset with .(control)OffsetX that is
' added to the default offset after alignment calculation. Note that for right alignment, to get
' the control farther to the left, you'd want to make this a negative number.
'--ComboText now also a let that sets the text. This does not add an item and cannot set an image
' if an imagelist is in use; for those features use ComboSetCurrentState
'--Added Get/Let for Combo dropdown width (.ComboDropWidth). Returns 0 unless previously set. Can
' modify an open dialog.
'--Bug fix: TDF_NO_SET_FOREGROUND flag, which was added in Windows 8, was missing.
'--Bug fix: Alignment issues with certain flags with the DateTime control when placed in the footer.
'--Bug fix: Flag conflicts with built in ones and omitted flags. Fixed.
-
1 Attachment(s)
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
VB: VB6 sp6
OS: Win7 / Win10
Quote:
Originally Posted by
fafalone
cTaskDialog 1.1 Released!
i found a bug using the Flag TDF_INPUT_BOX:
i specifed a file name for the InputText that is larger than the width of the showed input textbox and i cannot scroll to the end of the file name:
Attachment 171343
currently the file name is truncated inside the textbox.
any idea how to scroll to the end of the file name inside the textbox?
BTW: this problem also occurs with v1.0
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
i solved the problem myself:
add the new line to the class header:
Code:
Private Const ES_AUTOHSCROLL As Long = &H80&
at the Sub AddInputBox() alter the line:
Code:
dwStyle = WS_VISIBLE Or WS_CHILD Or WS_TABSTOP Or ES_LEFT
to:
Code:
dwStyle = WS_VISIBLE Or WS_CHILD Or WS_TABSTOP Or ES_LEFT Or ES_AUTOHSCROLL
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thanks for letting me know, fix will be included in the next release.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I have download the project but it has fail to load in the IDE because the file mIcon.bas isn't in the zip
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Wow I have no idea how that version got the names mixed up. The mTDSample.bas included in the zip is the only module you need; you can just add that or re-download it, I updated it.
In the vbp it had Module=mTDSample; mIcon.bas, so showed as mTDSample on my screen... but I don't know how the project was even loading on my end given that I deleted the old module... that's an odd one.
Sorry about that.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hi faf, I am still using 0.7 as that provides all I need except for two things. The most important: how do I pre-check the verification checkbox? Secondly the default button has no effect. I've tried 1.1 and I still can't pre-check. I've been trying clickverification 1.
Cheers to you.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
The easy way to pre-check that button is to use TDF_VERIFICATION_FLAG_CHECKED as one of the .Flags
ClickVerification has a bug I just noticed anyway; it's using TDM_CLICK_BUTTON, which is a regular button click that will close the dialog, where it should have TDM_CLICK_VERIFICATION. If you still wanted to use that method instead just switch the variable name, and it has to be called while the dialog is active, so in the _DialogCreated event or somewhere else.
==
And for the default button, are you using .CommonButtons or custom buttons? If custom, it should just be the straightforward button id. But for CommonButtons, there was a bug in 0.7 that was subsequently fixed as of v1.0; in 0.7 the Enum that pops up is TDBUTTONS, but to set a different default for common buttons, you need to specify the button by its TDRESULT value. So for the 'No' button you'd use TD_NO instead of TDCBF_NO_BUTTON.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thanks faf, works like a charm.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
cTaskDialog 1.2 Released!
This version has some important improvements to functionality, including a very significant expansion of multi-page functionality, and some bug fixes, one of them critical.
R2: A quick same-night update was made to fix an issue where the footer icon would go blank if it was changed during runtime if it was part of a mutli-page dialog.
Code:
'Version 1.2 Release 2 (R2)
'--Bug fix: Quick bug fix for footer icons not redrawing when changed during runtime.
'NEW IN VERSION 1.2
'--Since it turns out, when you navigate to a new page, it doesn't activate the new TaskDialog
' object, it just takes the settings and applies them to the original object. So the outcome
' of this was that only the settings that are part of the native TaskDialog would be applied,
' and see also the bugfix related to sending messages to active dialogs. Any of the custom
' features wouldn't get applied. All settings are transferred now.
' NOTE: Since this has to be done by overwriting the current configuration set, if you move
' back to an earlier page, you'll need to reset the settings first. All of them, not just
' customizations.
'--Added InputBoxTextAlign property to set left/right/center alignment.
'--Bug fix: Flag for DateTime and Slider were assigned same value.
'--Bug fix: Input box should have had ES_AUTOHSCROLL set.
'--Bug fix: In ClickVerification, it used the message for a button click, which led to either
' closing the dialog or doing nothing, instead of TDM_CLICK_VERIFICATION, the correct
' message to send for modifying the checkbox through code.
'--Bug fix: Navigating to a new page zero'd the hWnd on the expectation it would change, but
' this expectation was incorrect. It shouldn't be zero'd and any action applied should
' be sent to the main TaskDialog object, the API messages will apply to the current
' page. E.g. TaskDialog1 is the first page, which loads a second page with object
' TaskDialog2. When navigating to TaskDialog2, TaskDialog1 receives a Navigated() event,
' and if TaskDialog2 has a marquee progress bar, call TaskDialog1.ProgressStartMarquee.
In the Demo project, there's a new 'Advanced Multi Page Dialog' button that has a setup with 3 screens:
https://i.imgur.com/PEhwXbE.jpg
This shows a number of ways of doing things with multiple pages, including interacting with custom controls. When using multiple pages, be sure to set the .PageIndex property, because every event is handled in the main dialog, so you'll want to check which page is sending the button click. Also shown is going back to an earlier page; note that this requires resetting the configuration of the dialog again, because your initial settings for the page were overwritten when it navigated, which loads the new page into the original-- it doesn't actually load a new dialog.
It uses a login dialog borrowed from another example, showing how you can use the pageindex to still handle updating the current dialog. Then finally, it shows taking data from that login page (or the first page skipping the log in), and using it to set the text of the last page; and how to start the marquee on the last page.
While it's a little complicated to get the hang of, you can get some really fancy multi-dialog systems set up to accomplish a wide variety of tasks, especially now with the new handling methods that allowing use of the customizations and really anything more than dead simple things.
I'll definitely make some better examples in the future, building up from the base like with the original stuff.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
i would like to add manifest into vb6.exe to avoid declare changing in IDE
Quote:
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I use the TDF_ENABLE_HYPERLINKS and TDF_EXEC_HYPERLINKS flags to create hyperlinks in my dialogs which take the user to a web page. This works great.
Is there a way to have a click on one of these hyperlinks to fire a routine in my own code? If not, is there some other way to do so with this control?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
AAraya
I use the TDF_ENABLE_HYPERLINKS and TDF_EXEC_HYPERLINKS flags to create hyperlinks in my dialogs which take the user to a web page. This works great.
Is there a way to have a click on one of these hyperlinks to fire a routine in my own code? If not, is there some other way to do so with this control?
I decided to create a custom button for this. Works great.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
When you click a hyperlink, the TaskDialog_HyperlinkClick fires; you can do whatever you want there, you don't need to call ShellExecute. Make sure you're not using the TDF_EXEC_HYPERLINKS flag, because that sets the dialog to call ShellExecute on its own.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
fafalone
When you click a hyperlink, the TaskDialog_HyperlinkClick fires; you can do whatever you want there, you don't need to call ShellExecute. Make sure you're not using the TDF_EXEC_HYPERLINKS flag, because that sets the dialog to call ShellExecute on its own.
Thanks! Did not know that. I'm happy with my custom button in this case but this might come in handy down the road.
I don't see that in my version - you must have added that after version 1?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Don't see what?
The HyperlinkClick event has been there since the very beginning; the TDF_EXEC_HYPERLINKS flag was added in Version 0.5.1. Although it does seem I neglected to ever mention that in the changelog.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
If the Input Text control is left empty by the user, the Get InputText Property returns the default value of InputText (saved into module variable sEditText) when the dialog was initiated.
Original
Code:
Public Property Get InputText() As String
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
End If
End If
InputText = sEditText
End Property
Proposed
Code:
Public Property Get InputText() As String
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
Else
sEditText = vbNullString
End If
End If
InputText = sEditText
End Property
Best Regards!
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
is it possible to have multiple TDF_INPUT_BOX or multiple TDF_DATETIME
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
It's certainly possible to do, but the control as is isn't set up for that.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
hi guys, i know this is stupid and newbie question. I manage to embeded manifest vb6.exe.manifest to my IDE vb6, and apply this taskdialog during design time
But after I compile and run time..Error 453, Unable to point entry to comctl32.dll
Can someone guide me, how can i manage to show this taskdialog in runtime
thanks
UPDATE : never mind, i figured it out, never play with manifest exe before....:)
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
You also need to manifest your compiled .exe.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
Steve Grant
You also need to manifest your compiled .exe.
thanks, i figured it out by applying .res file into my project IDE, and compile it. after that another appname.exe.res in same folder
all things work well...on WINDOWS 7...but when I tried to use it on Windows 10... some controls error. I checked it and raised error "invalid property value" on VKUSERCONTROLS (free controls which apply xp style and support unicode)..
But why no error on Windows 7, still confuse
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Be careful with VKuserControls they only partially support Unicode. The textboxes for example do not. I have also found that those controls are not as stable as I would like on Win10
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
If your project already has a manifest, you can use something like Krool's Common Controls replacement; they'll apply the newer visual styles in a manifested app and all support Unicode.
Also, your manifest for your exe goes in the .res file, then you add that to your project in the IDE, it gets compiled in, and that's it. You don't need to keep the .res file with your compiled .exe, or an external manifest file, once there's one embedded in the exe.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
Steve Grant
Be careful with VKuserControls they only partially support Unicode. The textboxes for example do not. I have also found that those controls are not as stable as I would like on Win10
that is something for my next task. I used vkusercontrols on all my forms to gain xp styles..think I need to switch to standard controls
Quote:
If your project already has a manifest, you can use something like Krool's Common Controls replacement; they'll apply the newer visual styles in a manifested app and all support Unicode.
thank you..this is what I intend to do
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Also, your manifest for your exe goes in the .res file, then you add that to your project in the IDE, it gets compiled in, and that's it. You don't need to keep the .res file with your compiled .exe, or an external manifest file, once there's one embedded in the exe.[/QUOTE]
I am really newbie in manifest things..guess everything always require first step..I will try it..
Out of thread : I don't know if someone can do something with VB6 language, maybe upgrade to support 64bit. I still saw a lot of potential with VB, I am looking at Twinbasic, hopefully every VB programmer wishes will come into this TwinBasic
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
hi fafalone,
for a special purpose I would like to run the dialog vbModeless.
Is that possible somehow?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Quote:
Originally Posted by
Little John
hi fafalone,
for a special purpose I would like to run the dialog vbModeless.
Is that possible somehow?
Just don't assign anything to hWndParent property.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Just found this incredible project some time ago and been playing with it, getting more and more advanced. One of the most useful CodeBank items I would say. One thing I'm missing though is the ability to have an "ItemData" property for the ComboBox as it's not always useful or convenient to identify items in a sequential numeric order like in a ListIndex. I don't know if it's possible to extend the combo itself in that way but something like an ID as with .AddCustomButton would do. The use case for this is typically if you read combo items from a DB.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Definitely possible, just a few small changes. Not sure when I'll be ready with a new version, but the way you'd go about it is to add an lParam: Add the bolded code in the functions below:
Code:
Private Type ctdComboItem
sText As String
iImage As Long
iOverlay As Long
lpData As Long
End Type
Public Sub ComboAddItem(sText As String, Optional iImage As Long = -1, Optional iOverlay As Long = -1, Optional lParam As Long = 0)
If aComboItems(0).sText = "" Then
aComboItems(0).sText = sText
aComboItems(0).iImage = iImage
aComboItems(0).iOverlay = iOverlay
aComboItems(0).lpData = lParam
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
If hCombo Then
CBX_InsertItem hCombo, sText, iImage, iOverlay, lParam
End If
End Sub
Public Property Get ResultComboData() As Long: ResultComboData = aComboItems(nComboIdx).lpData: End Property
I'll have to test it later but that's about the extent of what you'd need, just an extra field to store a long that's either the data itself or a pointer/key for where to get it. I added it to the combo itself just in case there's a need, but storing it in the local structure that holds the items should be enough.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Thanks, I will test this code in implementation with my program. In my use, ItemData as used with ordinary VBCombo is typically a primary key ID for an item read from a database in code and not a value that a user normally would supply/submit. So when reading the items captions from the DB it may be a partial set, or sorted alphabetically (or on other parameter), so identification by 'listindex' would not be very efficient or even possible. For now I have worked around it by adding an external dynamic array storing the data in listindex order but of course it's much better to have all this logic inside the class and control. Nothing fancy really, just the ability to store a long with each combo item.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Looking at the code, I wonder if also these changes aren't needed?
Code:
Public Sub zzComboGetItemData(lMax As Long, sText() As String, iImage() As Long, iOverlay() As Long, lParam() As Long)
Attribute zzComboGetItemData.VB_MemberFlags = "40"
Dim nct As Long
nct = UBound(aComboItems)
lMax = nct
ReDim sText(nct)
ReDim iImage(nct)
ReDim iOverlay(nct)
ReDim lParam(nct)
Dim i As Long
For i = 0 To UBound(aComboItems)
sText(i) = aComboItems(i).sText
iImage(i) = aComboItems(i).iImage
iOverlay(i) = aComboItems(i).iOverlay
lParam(i) = aComboItems(i).lpData
Next i
End Sub
and
Code:
Dim cbT() As String, cbI() As Long, cbO() As Long, cbD() As Long, nct As Long
cTD.zzComboGetItemData nct, cbT, cbI, cbO, cbD
ReDim aComboItems(nct)
For i = 0 To nct
aComboItems(i).sText = cbT(i)
aComboItems(i).iImage = cbI(i)
aComboItems(i).iOverlay = cbO(i)
aComboItems(i).lpData = cbD(i)
Next i
Then also the use of this variable need to be updated as it's uses the same Type structure?
Code:
Private tComboInit As ctdComboItem
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I think this addition also needs to be made
Code:
Public Sub Init()
'resets the entire module
...
tComboInit.iOverlay = 0
tComboInit.lpData = 0
I'm also experimenting with adding a 'NewIndex" property as that can be useful in some cases. For that I have added to the above code
Code:
tComboInit.iOverlay = 0
tComboInit.lpData = 0
nComboNewIndex = 0
and this in declaration
Code:
Private nComboIdx As Long
Private nComboNewIndex As Long
property
Code:
Public Property Get ComboHeight() As Long: ComboHeight = cyCombo: End Property
Public Property Get ComboNewIndex() As Long: ComboNewIndex = nComboNewIndex: End Property
Public Property Let SliderAlign(nAlign As TDInputBoxAlign): nSliderAlign = nAlign: End Property
and finally I made these changes to ComboAddItem and at the same time cut down on the use of UBound() to make the code a tad more efficient
Code:
Public Sub ComboAddItem(sText As String, Optional iImage As Long = -1, Optional iOverlay As Long = -1, Optional lParam As Long = 0)
If aComboItems(0).sText = "" Then
aComboItems(0).sText = sText
aComboItems(0).iImage = iImage
aComboItems(0).iOverlay = iOverlay
aComboItems(0).lpData = lParam
Exit Sub
End If
nComboNewIndex = UBound(aComboItems) + 1
ReDim Preserve aComboItems(nComboNewIndex)
aComboItems(nComboNewIndex).sText = sText
aComboItems(nComboNewIndex).iImage = iImage
aComboItems(nComboNewIndex).iOverlay = iOverlay
aComboItems(nComboNewIndex).lpData = lParam
If hCombo Then
CBX_InsertItem hCombo, sText, iImage, iOverlay, lParam
End If
End Sub
Maybe you prefer the repeated calls to UBound as your coding style, I just try to avoid unnecessary calls :-)
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hi again, I think I have found something at least I concider to be a bug.
In the ProcessCallback function, if the combostyle is editable and the combo text field is left empty when submitting the dialog (in this case clicking a custom button)
Code:
Case TDN_DESTROYED
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
End If
End If
If hCombo Then
sComboText = GetComboTextW(hEditCombo)
the sComboText variable will get assigned a Chr$(0) so you can never make the test
Code:
If len(Trim$(.ResultComboText)) > 0 Then
or
Code:
If Trim$(.ResultComboText) = "" Then
so I think the returned string somehow needs to be tested for Chr$(0) and removed if exists.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
ah good call, I'd tend to fix it at the source, GetComboText was adding a 1 to the length even if it was 0. Can't recall if the extra 1 is needed for anything or not, but in case:
Code:
Private Function GetComboTextW(hEdit As Long) As String
Dim bytS() As Byte
Dim ch As Long
ch = SendMessageW(hEdit, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If ch = 0& Then Exit Function
ch = ch + 1
ReDim Preserve bytS(ch)
ch = SendMessageW(hEdit, WM_GETTEXT, ch, ByVal VarPtr(bytS(0))) * 2 - 1
If ch >= 0 Then
ReDim Preserve bytS(ch)
End If
GetComboTextW = CStr(bytS)
End Function
The return on that len=0 for empty boxes.
Will also add the other parts of the extra data you found, thanks.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hi, I'm doing some quality control of my code as I'm setting up unit testing, and wonder is this a bug?
Code:
Public Property Get DefaultRadioButton() As Long: DefaultButton = uTDC.nDefaultRadioButton: End Property
shouldn't it be
Code:
Public Property Get DefaultRadioButton() As Long: DefaultRadioButton = uTDC.nDefaultRadioButton: End Property
?
in cTaskDialog
EDIT/ADDING:
and same with this
Code:
Public Property Get DateTimeAlign() As TDInputBoxAlign: ComboAlign = nDateTimeAlign: End Property
to be
Code:
Public Property Get DateTimeAlign() As TDInputBoxAlign: DateTimeAlign = nDateTimeAlign: End Property
and this
Code:
Public Property Get DateTimeAlignInButtons() As TDControlAlign: DateTimeAlignInFooter = nDTButtonAlign: End Property
to be
Code:
Public Property Get DateTimeAlignInButtons() As TDControlAlign: DateTimeAlignInButtons = nDTButtonAlign: End Property
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
ooou, another one maybe, at least the code doesn't make sense to me.
Code:
Public Sub EnableButton(ButtonID As Long, lEnable As Long)
'lEnable=0 disable; <>0 enable
...
Else
Dim lnew() As Long
ReDim lnew(0)
Dim i As Long, k As Long
For i = 0 To UBound(lBtnDis)
If lBtnDis(i) <> ButtonID Then
ReDim Preserve lnew(k)
lnew(k) = lBtnDis(i)
End If
Next
lBtnDis = lnew
End If
...
End Sub
doesn't variable k need to be incremented here? and is the first ReDim of lnew() really necessary?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Good catches, I'll update the project when I have a chance.
1st redim is probably not neccessary but I've gotten burned by trying to refer to ubound(array) only to be told it's out of bounds so many times I've gotten in the habit of immediately putting redim(0) after declaring an array since it will usually help and doesn't hurt.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Here is another one, SimpleDialog shouldn't it be 'As TDRESULT' rather than 'As TDBUTTONS' ? As it is now the intellisense gives wrong suggestions, which doesn't match with what's returned.
-
2 Attachment(s)
string conversion problem with StrConv
cTaskDialog v1.2 R2
i have a string conversion problem when using the class on a chinese windows system.
The function StrConv converts the characters from a string wrong:
BEFORE:
Attachment 182042
AFTER:
Attachment 182043
Everyone should avoid to use the function StrConv if your app will run on a windows system with unicode language like chinese, russian etc.
Do you have a replacement for the StrConv-function?
Maybe a self-written function to convert the wide-unicode-string to a VB-String?
The StrConv is used here in your code:
Code:
Public Property Get InputText() As String
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
Else
sEditText = vbNullString
End If
End If
InputText = sEditText
End Property
Code:
Case TDN_DESTROYED
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
End If
End If
-
Re: string conversion problem with StrConv
I fixed the problem with the wrong text conversion!
Now the TaskDialog returns the correct unicode string!
Can you add the fix to your next release?
I added this API declaration:
Code:
Private Declare Function SendMessageW2 Lib "user32" Alias "SendMessageW" (ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
And changed the code from:
Code:
Case TDN_DESTROYED
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
End If
End If
to
Code:
Case TDN_DESTROYED
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, StrPtr(sText))
sEditText = Left$(sText, InStr(sText, Chr$(0)) - 1)
End If
End If
and i changed this code:
Code:
Public Property Get InputText() As String
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW(hEditBox, WM_GETTEXT, lLen, ByVal sText)
sEditText = StrConv(sText, vbFromUnicode)
Else
sEditText = vbNullString
End If
End If
InputText = sEditText
End Property
to
Code:
Public Property Get InputText() As String
If hEditBox Then
Dim lLen As Long, sText As String
lLen = SendMessageW(hEditBox, WM_GETTEXTLENGTH, 0, ByVal 0&) * 2
If lLen Then
sText = Space$(lLen)
Call SendMessageW2(hEditBox, WM_GETTEXT, lLen, StrPtr(sText))
sEditText = Left$(sText, InStr(sText, Chr$(0)) - 1)
Else
sEditText = vbNullString
End If
End If
InputText = sEditText
End Property
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
If I set the .ComboStyle = cbtDropdownList property, then the .ResultComboText property always returns empty.
.ResultComboIndex returns correctly.
Code:
With TaskDialog1
.Init
.MainInstruction = "Duplicates"
.Content = "If you want to exclude an Artists name from the search:"
.Flags = TDF_COMBO_BOX
.AddCustomButton 100, "Continue"
.CommonButtons = TDCBF_CANCEL_BUTTON
.ComboStyle = cbtDropdownList 'cbtDropdownEdit
.IconMain = IDI_QUESTION
.Title = "cTaskDialog Project"
.ComboSetInitialState "", 5
.ComboSetInitialItem 1
.ComboAddItem "Item 1"
.ComboAddItem "Item 2"
.ComboAddItem "Item 3"
.ParenthWnd = Me.hwnd
.ShowDialog
Label1.Caption = .ResultComboText
Labe2.Caption = .ResultComboIndex
End With
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
@Mith, thanks, will add to next release.
@Visualman: This is expected behavior. .ResultComboText is only meant to return the text of a regular combobox, not the item text for the DropdownList style. If you need to refer back to the item text for a dropdownlist item, you can store the entries in a module-level variable before adding them to the class, then access that variable based on the returned index.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hi
Kindly some one help with setting up Progressbar for Taskdialog.
I cannot figureout how to interact with progress to update it after it shows in my Sub.
You cannot open it as non-blocking so you can update progress manulayy whenever I need as required during my code is running.
-
1 Attachment(s)
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
There's an example of that in the set of examples in the first couple posts:
Attachment 185737
Quote:
The TaskDialog supports having a progress bar, both regular and marquee. To enable it, include the TDF_SHOW_PROGRESS_BAR or the TDF_SHOW_MARQUEE_PROGRESS_BAR flag (you can switch back and forth between them while the dialog is open if you want). Getting it to show up is the easy part, linking it to actual events in your program is where it gets a little tricky. There's some events that are provided that will help out...
TaskDialog_DialogCreated is triggered when the dialog is displayed, then all the buttons, the radio buttons, the expando button, the checkbox, and hyperlinks all have events when the user clicks them. In addition to that, TaskDialog_Timer is sent approximately every 200ms and includes a variable telling you how many ms has elapsed since the dialog appeared, or since it was reset with the .ResetTimer() call. The example shows a basic counter, but you can go further and enable/disable buttons and use hyperlinks to control things too.
Code:
Private bRunProgress As Boolean
Private lSecs As Long
With TaskDialog1
.Init
.MainInstruction = "You're about to do something stupid."
.Content = "Are you absolutely sure you want to continue with this really bad idea? I'll give you a minute to think about it."
.IconMain = TD_INFORMATION_ICON
.Title = "cTaskDialog Project"
.Footer = "Really, think about it."
.Flags = TDF_USE_COMMAND_LINKS Or TDF_SHOW_PROGRESS_BAR Or TDF_CALLBACK_TIMER
.AddCustomButton 101, "YeeHaw!" & vbLf & "Put some additional information about the command here."
.AddCustomButton 102, "NEVER!!!"
.AddCustomButton 103, "I dunno?"
.VerifyText = "Hold up!"
bRunProgress = True
.ShowDialog
End With
Private Sub TaskDialog1_DialogCreated(ByVal hWnd As Long)
If bRunProgress Then
Timer1.Interval = 1000
Timer1.Enabled = True
TaskDialog1.ProgressSetRange 0, 60
End If
End Sub
Private Sub TaskDialog1_Timer(ByVal TimerValue As Long)
If lSecs > 60 Then
Timer1.Enabled = False
bRunProgress = False
Else
TaskDialog1.ProgressSetValue lSecs
TaskDialog1.Footer = "You've been thinking for " & lSecs & " seconds now..."
End If
End Sub
Private Sub TaskDialog1_VerificationClicked(ByVal Value As Long)
If Value = 1 Then
Timer1.Enabled = False
bRunProgress = False
Else
bRunProgress = True
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
lSecs = lSecs + 1
End Sub
-
1 Attachment(s)
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hi
Thanks for your quick response. This is what I have already explored and workin gok for examples for progressbars we have.
But my issue is I have subs in a Module (one example is attached for Microsoft Access). If I run the Taskdialog before the actual tasks in my subs, I cannot go back to update the progress as Taskdialog does not let even if I don't bind hwnd to nothing.
Secondly If I take all my sub into Taskdialog timer event, it's all gets crazy.
Is there no way to just open the dialog and then within my sub I just update the progress wheneve something is completed.
I'm using Statusbar progress monitor in my sub but I wan t to replace it with Taskdialog as I repaced all other messagebox with it.
Regards
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Just like the MsgBox, the TaskDialog isn't asynchronous so the only option that doesn't involve doing it through the timer callback would be running it in a different thread. Which is very difficult in VB6 and I don't know if it can even be done in VBA; perhaps this kind of progress dialog is more appropriate for the task?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
This project now has a Universal version that works in twinBASIC x86/x64 and VBA7 x84/x64, in addition to VB6 and VBA6.
For now I'm leaving the version in this thread up, but the next feature update will use the universal codebase (you could drop in cTaskDialog.cls and modTDHelper from the universal codebase into the VB6 version in this thread too).
[twinBASIC/VB6/VBA7] TaskDialogIndirect: cTaskDialog universal implementation x86/x64
There's a neat workaround for the fact alignment issues make it difficult to call in VBA7x64 :)
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Hello, I'm here to report something.
This line (2361)
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 Long, Optional hinst As Long) As TDBUTTONS
Shouldn't it be
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 Long, Optional hinst As Long) As TDRESULT
If you go with the former, you'll get the wrong result. Like when you expect the result to be Cancel, you'll get Yes instead.
Thank you.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
Yup you're right. I've been meaning to revisit this project to get the universal version working; will fix in next release.
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
I am trying to do a dialog with .Flags = TDF_COMBO_BOX Or TDF_INPUT_BOX Or TDF_DATETIME
all of them with the align set to TDIBA_Content
Looks like it will not work
is there any way around it?
-
Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs
It's not currently supported... it was very difficult to account for all positioning issues with just a single custom control; having multiple ones in the same area would greatly increase the complexity, and I haven't accounted for that in the current version. You can have any single custom control with any combination of built in controls, but just the one for now.
It *might* work ok if you put them in different alignment slots (ComboAlignInContent, InputAlignInContent, DateTimeAlignInContent), but I can't promise that.