Page 4 of 7 FirstFirst 1234567 LastLast
Results 121 to 160 of 248

Thread: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

  1. #121
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    323

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    thanks fafalone, it works now

  2. #122
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    323

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    found that, it works fine in vba now...

  3. #123
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    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?

  4. #124
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    227

    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.

  5. #125
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Quote Originally Posted by Cube8 View Post
    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.

  6. #126

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.

  7. #127
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    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.
    Last edited by AAraya; Aug 23rd, 2019 at 11:35 AM.

  8. #128

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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

  9. #129

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.

  10. #130
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    445

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    VB: VB6 sp6
    OS: Win7 / Win10

    Quote Originally Posted by fafalone View Post
    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:

    Name:  Screenshot - 01.10.2019 , 07_53_23.png
Views: 1500
Size:  8.2 KB

    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
    Last edited by Mith; Sep 30th, 2019 at 08:09 PM. Reason: added some more infos

  11. #131
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    445

    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

  12. #132

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Thanks for letting me know, fix will be included in the next release.

  13. #133
    Addicted Member gilman's Avatar
    Join Date
    Jan 2017
    Location
    Bilbao
    Posts
    176

    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

  14. #134

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.

  15. #135
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    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.

  16. #136

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.
    Last edited by fafalone; Mar 14th, 2020 at 04:39 AM.

  17. #137
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Thanks faf, works like a charm.

  18. #138

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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:

    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.
    Last edited by fafalone; Mar 21st, 2020 at 11:08 PM.

  19. #139
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    323

    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
    <dependency>
    <dependentAssembly>
    <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
    </dependentAssembly>
    </dependency>

  20. #140
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    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?

  21. #141
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Quote Originally Posted by AAraya View Post
    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.

  22. #142

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.

  23. #143
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Quote Originally Posted by fafalone View Post
    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?

  24. #144

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.
    Last edited by fafalone; Mar 29th, 2020 at 09:08 PM.

  25. #145
    New Member
    Join Date
    Oct 2015
    Posts
    12

    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!
    Last edited by zeilo; Jul 12th, 2020 at 10:04 AM.

  26. #146
    Lively Member
    Join Date
    Oct 2016
    Posts
    108

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    is it possible to have multiple TDF_INPUT_BOX or multiple TDF_DATETIME

  27. #147

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.

  28. #148
    Addicted Member
    Join Date
    Jan 2010
    Posts
    250

    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....
    Last edited by jedifuk; Jan 15th, 2021 at 10:21 PM.

  29. #149
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    You also need to manifest your compiled .exe.

  30. #150
    Addicted Member
    Join Date
    Jan 2010
    Posts
    250

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Quote Originally Posted by Steve Grant View Post
    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

  31. #151
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    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

  32. #152

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.
    Last edited by fafalone; Jan 16th, 2021 at 08:36 PM.

  33. #153
    Addicted Member
    Join Date
    Jan 2010
    Posts
    250

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Quote Originally Posted by Steve Grant View Post
    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

    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

  34. #154
    Addicted Member
    Join Date
    Jan 2010
    Posts
    250

    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

  35. #155
    New Member
    Join Date
    Apr 2014
    Posts
    12

    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?

  36. #156
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    227

    Re: [VB6] TaskDialogIndirect - Complete class implementation of Vista+ Task Dialogs

    Quote Originally Posted by Little John View Post
    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.

  37. #157
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    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.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  38. #158

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    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.

  39. #159
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    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.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  40. #160
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    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
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

Page 4 of 7 FirstFirst 1234567 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width