Page 2 of 7 FirstFirst 12345 ... LastLast
Results 41 to 80 of 248

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

  1. #41

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

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

    Forgot to ask..have you looked at the enumwindows and bm_setimage on vista? Are the button hwnds not returned by enumchildwindows?

  2. #42
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    hWnds are always returned, regardless of the system. The only way a 'control' hWnd won't be returned is if the control is not an actual window but is owner-drawn on the DC, kinda like VB's Image & Label controls.

    What would've made any workarounds completely unnecessary is if the dialog would've put the button IDs in the control's ControlID property, then we could've just used GetWindowLong(GWL_ID) within EnumChildWindows to return the hWnd for each button ID.

    The screenshot I posted with the icon-only sample was on Vista.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #43
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Curious, have you found a clean way of displaying the command links without icons & without the green arrows?

    My workaround works, but feel it should be easier. Again, maybe just a Vista thing? But the flag TDF_USE_COMMAND_LINKS_NO_ICON doesn't work.

    I created a 1x1 4bit 100% transparent icon (B&W, 1 bit, didn't work for whatever reason). Code was modified a bit further to allow user-defined width so that if say a 32x32 icon was used on 1 or more command links, then a 32bit wide transparent icon could be used for command links with "no icons" so that all the link captions have the same left margin
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #44

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

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

    The flag works fine on my system (Win7 x64).. and MSDN makes no mention of it being new... so I'm not sure what the issue is for you.

  5. #45
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

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

    Never got it to work from day 1. I'll have to try on Win7 another time. Probably an early bug & not fixed until Win7? I've read other posts on the net of ppl having similar issues

    Edited: Got it to work & found the problem. When both that flag and the TDF_USE_COMMAND_LINKS were added, the latter overrode the former. Now that I see how these links captions don't line up when one has an icon and one doesn't, gotta admit, I like my 'transparent icon" solution to align them up
    Last edited by LaVolpe; Oct 28th, 2014 at 10:08 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #46
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

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

    So the magic of the project, why not update it? This is the final version of it?

  7. #47

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

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

    All of the native features of task dialogs have been implemented, so anything else would be another customization.

    I'm definitely open to suggestions though if there's something you'd like to see the class be able to do natively. Or if you can suggest an easier way to implement some of the more complex features, I know some of it is a little tough. And of course I'll fix any bugs that are identified.

    Let me know

  8. #48
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    679

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

    Hi fafalone,

    tested this in one windows 10 workstation. Generates an error
    453 Can't find DLL entry point TaskDialogIndirect in comctl32.dll.

    Question - any idea what might cause of this (possibly manifest error)?

    Edit... Yes, that was the reason for the error.. Forgot to add manifest to project and then compiled exe didn't use comctl 6 version and was unable to find entry point.
    Last edited by Tech99; Nov 2nd, 2016 at 05:35 AM.

  9. #49

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

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

    Yeah even direct API calls need a manifest the way they set it up for backwards compatibility.

    ---------------------------------------------
    Unrelated, but in the main post is everyone else seeing tiny images (besides the header image)? When I first made it they appeared full sized, and the images themselves haven't changed.. but now they're tiny on both Firefox and Chrome. Is this a Firefox change or a VBForums change, and could it be fixed without giving up the table layout?
    Edit: Nevermind, figured out I could fix it by using td="width: 75%"
    Last edited by fafalone; Nov 2nd, 2016 at 07:33 PM.

  10. #50

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

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

    Quote Originally Posted by LaVolpe View Post
    [...]
    The colored header? Niffty but limited. A few undocumented preset icons (I don't have the code in front of me, but believe they are -6, -7, -8, -9 (may be off by 1). The colors are blue, red, green, yellow, gray. When one of those icons assigned, header only, header gets filled in & applies the associated icon. To replace the icon simply set the header icon to another icon or zero to remove it. But see TDM_UPDATE_ICON documentation for restrictions
    Revisited this today; have you actually tried replacing it with another icon? It doesn't actually seem to work. Passing 0 to get no icon works fine, but passing another icon index doesn't; I tried a bunch of different values, making sure to pass through MAKEINTRESOURCE, and even tried without doing that. Just curious if it worked for you and I'm missing something?

    Edit: Nevermind, was missing that I had been defaulting the hInstance to App.hInstance instead of 0.
    That leaves the big question; how to replace it with a custom icon via an hIcon? You can definitely get a custom icon in there by using App.hInstance since the gradient is part of the system resource it loads.. but given the pain involved in getting nice icons into VB resource files (as icons, specifically the icon group used here), maybe its easier.

    Shield icon from gradient replaced with custom icon stored in application resource file:
    Last edited by fafalone; Nov 3rd, 2016 at 09:15 PM.

  11. #51
    New Member
    Join Date
    Nov 2016
    Location
    Bali, Indonesia
    Posts
    14

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

    Hi, how i can implement your td.res resource file in my existing project becuase i already have *.res file on my project and vb not allowed to add more than one *.res file.
    Thanks

  12. #52

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

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

    If you're using La Volpe's manifest creator you can select an existing resource file instead of creating a new one; that will insert the manifest into your resource file, or you can do that manually with another resource editor.

  13. #53

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

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

    Ok, so I decided that no, I have not gone far enough with rarely used features. I want to move forward with making dropdown menu buttons work.
    Ran into a problem though;
    I'm not getting BCN_DROPDOWN in the WndProc after subclassing the taskdialog's hwnd to it.
    If use SetParent to make sure that's the immediate parent, not only do I still not get BCN_DROPDOWN, but it breaks the button (left click doesn't close the dialog, and even if i did that manually it would be a bigger pain because i'd have to manage the return codes)
    Heck I'm not even getting BCN_DROPDOWN when I subclass the button hwnd itsself.

    Edit: Muahaha I got it. For some reason, while my normal split buttons fire a WM_NOTIFY with BCN_DROPDOWN, with the task dialog I don't get that but do get BCM_SETDROWNDOWNSTATE, which is all I need:
    Last edited by fafalone; Nov 3rd, 2016 at 10:13 PM.

  14. #54
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Hi Fafalone, like many others, I am using this constantly now. However I really could use a Textbox to input a string as well. The Inputbox is so old fashioned and I have seen a textbox on a friends CodeJock version of the TaskDialog. Any chance?

    Steve.

  15. #55

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

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

    There's no native option to have a textbox, so it's probably a custom control. Bolting a textbox onto the Windows task dialogs is certainly possible, but in a stable, reliable manner? Tricky, to say the least. But the even bigger problem would be positioning. Figuring out where the box could be placed given the vast array of options and changing number of lines based on text length?
    Really far better off just making a regular form, although I'll look into maybe doing something like replacing the content area with one? or better ideas?

    Edit:
    I was able to work out adding one in a stable manner; it was a little tricky because it was locked and ugly when I tried to create it as a child of the main taskdialog window, but it worked perfectly when I tied it to the DirectUIHWND class (the class already has an EnumChildWindows call for other features),


    Also set it up to return like the other results; i.e. .ResultMain .ResultVerify .ResultRadio and now .ResultInput too
    Pressing Enter even works, returning with the current/default button.
    So now the biggest challenge left is figuring out where to position it. How to set it to be in what location and present this as a user-friendly option.
    Suggestions?

    Code:
            hEditBox = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "", _
                          WS_VISIBLE Or WS_CHILD Or WS_BORDER Or ES_LEFT, _
                          20, 100, 150, 22, _
                         hUI, IDD_EDIT1, App.hInstance, ByVal 0&)
            Dim hFont As Long
            hFont = GetStockObject(DEFAULT_GUI_FONT)
            If hFont Then
                SendMessageW hEditBox, WM_SETFONT, hFont, ByVal 0&
            End If

    Edit 2:
    I've got some good ideas going now, check this out:
    Default placement, without a main instruction:

    and with:

    Only requiring the addition of a custom flag, .Flags = TDF_INPUT_BOX

    Then check this bad boy out:


    Made with
    Code:
    With TaskDialogPW
        .Init
        .MainInstruction = "Authorization Required"
        .Content = "The password is: password"
        .Flags = TDF_INPUT_BOX
        .InputIsPassword = True
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .SetButtonElevated TD_OK, 1
        .SetButtonHold TD_OK
        .Footer = "Enter your password then press OK to continue."
        .IconFooter = TD_INFORMATION_ICON
        .IconMain = TD_SHIELD_ERROR_ICON
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    
    
    Private Sub TaskDialogPW_ButtonClick(ByVal ButtonID As Long)
    If ButtonID = TD_OK Then
        If TaskDialogPW.InputText = "password" Then
            TaskDialogPW.CloseDialog
            'and do whatever
        Else
            TaskDialogPW.Footer = "Wrong password, please try again."
            TaskDialogPW.IconFooter = TD_ERROR_ICON
        End If
    End If
    End Sub
    I still don't really know what to do about figuring out placement elsewhere, which can be really important if there's no footer area or common buttons to align it with (how it's being done now)
    And even with this placement; it won't work with the Verify checkbox or the dropdown for more info control..

    Ok so I think I've got it worked out... there's 3 alignment options.. the one above, aligned to the buttons

    this one, aligned to the footer icon (or just plain bottom if there is no footer, but it's meant to be used with the icon)


    and what I'm planning on making the default, aligned to be just above the common buttons and width-aligned with the dialog, content-align:
    Last edited by fafalone; Feb 3rd, 2017 at 05:16 AM.

  16. #56
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    I went round to see my mate just now to get him to show the Dialog with a Textbox for input and get it fresh in my mind. His textbox stays in the white area just below the Content Text. This leaves the space to the left of the buttons for the Checkbox. I tried putting a long string of text in the content and the textbox just moved down (always in the white though) as it should.

    They say a picture is worth a thousand words so;

  17. #57

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

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

    Yup that's precisely how the default alignment option I've set works (I think I put in that edit with the 3-alignment-option pictures after your post, so re-read above too). It ensures there's always one line break to make sure the edit box isn't on top of the text; alignment like that would just be two. My textbox position is based on the buttons, so it doesn't matter how many lines the content text takes up; it will just always be there in the white space between the end of content and the gray area.

    Here's how it would look as of right now:



    The only real difference is the size of the gap (besides the theme elements; I'm on Win7, the buttons, check, and title will look like yours on Win8+)... but I can't adjust it any further upwards without a major complication to detect a double-crlf and adjust a whole bunch of alignment stuff accordingly.
    So hopefully it's ok with that spacing.

    Edit - ok ok I made the adjustment, now if it ends with a double-break it will align like this


    Simple to call:
    Code:
    With TaskDialog1
        .Init
        .MainInstruction = "Duplicates"
        .Content = "If you want to exclude an Artists name from the search:" & vbCrLf & vbCrLf
        .Flags = TDF_INPUT_BOX Or TDF_VERIFICATION_FLAG_CHECKED
        .AddCustomButton 100, "Continue"
        .CommonButtons = TDCBF_CANCEL_BUTTON
        .IconMain = TD_SHIELD_ICON
        .Title = "cTaskDialog Project"
        .InputText = "Enter Artist name here." 'Will be selected by default
        .VerifyText = "Exclude Jingles"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    End With
    Should be able to post the update later today, just gotta clean things up, now that I'm done with a massive fall down the rabbit hole where I made the position automatically adjust to an expanded info click-- much much harder than it seemed going in, but now working.
    Last edited by fafalone; Feb 3rd, 2017 at 09:45 AM.

  18. #58

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

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

    cTaskDialog 0.7 Released!

    Two new features:
    The first is just a minor option, a custom flag, TDF_KILL_SHIELD_ICON to remove the shield icon but keep the gradient background.

    But the big one: INPUT BOXES!
    Now you can take advantage of a wide range of TaskDialog options with a TextBox to retrieve user input, with the new custom flag TDF_INPUT_BOX

    First, a basic input box with the default positioning:
    Code:
    With TaskDialog1
        .Init
        .MainInstruction = "Hello World"
        .Content = "Input Required"
        .Flags = TDF_INPUT_BOX
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .IconMain = TD_INFORMATION_ICON
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    
        Label5.Caption = .ResultInput
        If .ResultMain = TD_OK Then
            Label1.Caption = "Yes Yes Yes!"
        Else
            Label1.Caption = "Cancelled."
        End If
    End With

    We can also position it next to the buttons:
    Code:
    With TaskDialog1
        .Init
        .MainInstruction = "Input Required"
        .Content = "Tell me what I want to know!" & vbCrLf '& vbCrLf
        .Flags = TDF_INPUT_BOX
        .InputAlign = TDIBA_Buttons
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .IconMain = TD_INFORMATION_ICON
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog

    The last placement option is to use it as footer input. It's designed to use the normal footer icon, but have a textbox instead of a label:
    Code:
    With TaskDialog1
        .Init
        .Content = "Something somesuch hows-it what-eva" '& vbCrLf
        .Flags = TDF_INPUT_BOX 'Or TDF_USE_SHELL32_ICONID
        .InputAlign = TDIBA_Footer
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .IconFooter = TD_INFORMATION_ICON
        .VerifyText = "Check here if you want to provide extra info below:"
        .Title = "cTaskDialog Project"
        .Footer = "$input"
        .ParenthWnd = Me.hWnd
        .ShowDialog

    Here's a practical example showing it with default text (which is pre-selected automatically):
    Code:
    With TaskDialog1
        .Init
        .MainInstruction = "Duplicates"
        .Content = "If you want to exclude an Artists name from the search:" & vbCrLf & vbCrLf
        .Flags = TDF_INPUT_BOX Or TDF_VERIFICATION_FLAG_CHECKED 'Or TDF_USE_SHELL32_ICONID
        .AddCustomButton 100, "Continue"
        .CommonButtons = TDCBF_CANCEL_BUTTON
        .IconMain = TD_SHIELD_ICON
        .Title = "cTaskDialog Project"
        .InputText = "Enter Artist name here."
        .VerifyText = "Exclude Jingles"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    Note the spacing; there's always a single line break like the first one (appended if not present), but using a double-break relaxes the spacing a bit.
    If CommandLinks are being used, the default alignment (content) places the textbox between the content and the first commandlink:
    Code:
    With TaskDialog1
        .Init
        .MainInstruction = "You're about to do something stupid."
        .Content = "First, tell me why?"
        .IconMain = TD_INFORMATION_ICON
        .Title = "cTaskDialog Project"
        .Flags = TDF_USE_COMMAND_LINKS Or TDF_INPUT_BOX
        .AddCustomButton 101, "YeeHaw!" & vbLf & "Put some additional information about the command here."
        .AddCustomButton 102, "NEVER!!!"
        .AddCustomButton 103, "I dunno?"
        
        .ShowDialog
    There's also compatibility with the expanded-info control in the default positioning. The position of the box is automatically adjusted when the expando control is clicked.
    Finally here's a detailed practical application that shows some more features. The textbox can be set as a password box. We can then combine that with a button hold, so now when enter or ok is pressed, we check the input and only let OK execute if it's a match- while cancel still closes it right away.
    Code:
    Set TaskDialogPW = New cTaskDialog
    With TaskDialogPW
        .Init
        .MainInstruction = "Authorization Required"
        .Content = "The password is: password"
        .Flags = TDF_INPUT_BOX
        .InputIsPassword = True
        .InputAlign = TDIBA_Buttons
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .SetButtonElevated TD_OK, 1
        .SetButtonHold TD_OK
        .Footer = "Enter your password then press OK to continue."
        .IconFooter = TD_INFORMATION_ICON
        .IconMain = TD_SHIELD_ERROR_ICON
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    Then we need to handle the ok button click to check the password:
    Code:
    Private Sub TaskDialogPW_ButtonClick(ByVal ButtonID As Long)
    If ButtonID = TD_OK Then
        If TaskDialogPW.InputText = "password" Then
            TaskDialogPW.CloseDialog
        Else
            TaskDialogPW.Footer = "Wrong password, please try again."
            TaskDialogPW.IconFooter = TD_ERROR_ICON
        End If
    End If
    End Sub

    That about covers the main features. One last minor thing, the CueBanner can be set with .InputCueBanner, but isn't visible at first since focus is set on the textbox so the user can start typing right away without clicking first.
    Last edited by fafalone; Mar 29th, 2020 at 09:12 PM. Reason: (Removed invalid attachment)

  19. #59
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    OMG! You are amazing Faf! Talk about excellent service. That is exactly what the doctor ordered, with one tiny caveat. Can I be cheeky and ask for the textbox to have both its current 3D look and also like the picture I submitted which is just flat with a blue (I think) border.

    Even if you choose to ignore my cheek , very well done from the UK.

    Steve.

  20. #60

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

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

    Well THAT level of detail I hope I can at least leave to you... especially since it's just a standard edit control that appears different in different versions of Windows. In the class' AddInputbox sub, the box is created with a CreateWindowEx call. Instead of WS_EX_CLIENTEDGE, try some other styles, 0 for completely flat.. WS_EX_STATICEDGE seems slightly thinner, maybe that's it? You can get all sorts of borders between that and the regular WS_ styles that go with WS_CHILD et al.
    What OS are you on, I'd have to look on that.

    And it was a great idea to have an input box... can't believe I hadn't thought of that when a few posts ago you saw me worrying about dropdown button menus (saving those for the next version!). As soon as you mentioned that I knew it must happen right away.

    Edit:
    Actually, it looks like just removing ES_BORDER should do the trick. That looks more like normal textboxes. I'm going to update the class like that...
    Old:
    New: Win8:

    Yeah the border on Win8 comes out slightly darker... I don't have a Win10 VM set up yet but if normal textboxes look like yours, then so should this.
    Last edited by fafalone; Feb 3rd, 2017 at 04:02 PM.

  21. #61
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Win 10 Home 64. VB6 Pro SP6: That is perfect now thank you. TaskDialogINdirect, ITaskbar3, Dil's notify ctrl that pops out the Win 10 info bar. Who needs CodeJock!!!

    Bless you mate - thank you.

    Steve.

  22. #62
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Hi Faf, some of the things you said above made me think. I now wonder if a Combobox would not be better than a Textbox. You still get the benefits of a Textbox but if you need to present a list then you get the advantages of a Combo. What do you think? Here is a picture of a form I created to dummy it up.
    Last edited by Steve Grant; Feb 4th, 2017 at 06:14 AM.

  23. #63

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

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

    What do I think?

    It must exist! Stand by. Will make it a ComboBoxEx with images too. At least one good point though is a lot of the code can be copied from the textbox.

    Edit
    So far so good...

    Code:
    himlSys = GetSystemImagelist(SHGFI_SMALLICON)
    With TaskDialog1
        .Init
        .MainInstruction = "Duplicates"
        .Content = "If you want to exclude an Artists name from the search:" & vbCrLf & vbCrLf
        .Flags = TDF_VERIFICATION_FLAG_CHECKED Or TDF_COMBO_EDIT
        .AddCustomButton 100, "Continue"
        .CommonButtons = TDCBF_CANCEL_BUTTON
        .IconMain = TD_SHIELD_ICON
        .Title = "cTaskDialog Project"
        .ComboCueBanner = "Cue Banner Text"
        .ComboImageList = himlSys
        .ComboAddItem "Item 1", 2
        .ComboAddItem "Item 2", 3
        .ComboAddItem "Item 3", 4
        .VerifyText = "Exclude Jingles"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    I've even set things up so that you can have both a combo and a textbox, since there's 3 different positions...

    or

    I think I need to add some sizing options...

    Was thinking... i *could* probably add autocomplete too... but it would have to support custom lists... so that would be a large expansion and a dependency for oleexp. Think I'll leave off the main class, but I am going to expose properties for the hWnd's, so it could be attached if someone wanted to go down that road.

    ====
    And I just thought of another idea.. still OTHER controls- was thinking an option for a calendar control would be really useful in particular. With the way I re-did the code for the combo, adding new ones in the same position configurations is standardized now.. a lot of work, but set up so it's fairly modular; can drop a new control in by just adding the flag, slightly changed create routine, and an additional set of variables/properties.

    Edit
    Yeah totally adding a datetime option too.


    Edit2
    Going crazy now... and now up to 2500 lines after adding support for (date or time) AND date + time,


    and of course it's set up like the combo, something that can be added on:
    Last edited by fafalone; Feb 5th, 2017 at 05:43 AM.

  24. #64
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    That looks great!! Here's the things I pick up in your screenshots (allowing for the fact this is just proof of concept).

    The Combo dropdown needs to be width adjusted for long items. Code Below.
    The control in the footer should be spaced away from the Icon, or, of course, we simply don't use the icon at this time.
    Need to ensure the dialog doesn't bloat too much. I use this ALL the time now and, for a simple program, don't want it to increase the size of the program disproportionately.

    Code:
    Option Explicit
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Private Sub AutoSizeDropDownWidth()
        Dim i As Integer, lTempWidth As Long, lWidth As Long
        Const CB_SETDROPPEDWIDTH = &H160
        
        If cboDialog.ListCount = 0 Then Exit Sub
    
        'Get the width of the largest item
        For i = 0 To cboDialog.ListCount - 1
            lTempWidth = cboDialog.Parent.TextWidth(cboDialog.List(i)) 'Ensure that form has the same font/size as combo
            If (lTempWidth > lWidth) Then lWidth = lTempWidth 'Store the longest length in lWidth
        Next
        
        lWidth = (lWidth \ Screen.TwipsPerPixelX) + 20 '+20 to allow for vertical scrollbar
       
        'don't allow drop-down width to exceed screen.width
        If lWidth > Screen.Width \ Screen.TwipsPerPixelX - 20 Then lWidth = Screen.Width \ Screen.TwipsPerPixelX - 20
        SendMessage cboDialog.hWnd, CB_SETDROPPEDWIDTH, lWidth, 0
    End Sub
    Many thanks - Yet again - Steve.

  25. #65

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

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

    The size is really a concern? The difference between 1000 lines and 10000 lines is a few KB, probably smaller than a single icon. (also, this size is par for the course for common controls... e.g. krool's usercontrol for a simple TextBox is 1900 lines, and 6700 for a ListView... so even if I hit 3000 i'd hope you wouldn't avoid the class for that)

    What I am doing is keeping the usage simple, and each thing that's added uses the same simple setup and config... nothing new effects anything old, so if you're not using something you won't be inconvenienced by it. And the way it's designed, very little additional code is actually executed if one of these new features isn't being used.

    (edit: ok, I fixed the spacing. And a weird bug where if you used an edit control in the footer, but no footer icon, the bottom half would be cut off)
    Code:
    himlSys = GetSystemImagelist(SHGFI_SMALLICON)
    Dim hIconF As Long
    hIconF = IconToHICON(LoadResData("ICO_CLIP", "CUSTOM"), 16, 16)
    With TaskDialog1
        .Init
        .MainInstruction = "Schedule Event"
        .Content = "Pick action to schedule. You can also set a name below." & vbCrLf & vbCrLf
        .Flags = TDF_DATETIME Or TDF_COMBO_LIST Or TDF_INPUT_BOX Or TDF_USE_HICON_FOOTER Or TDF_KILL_SHIELD_ICON
        .DateTimeType = dttDateTime
        .DateTimeAlign = TDIBA_Buttons
        .ComboSetInitialItem 0
        .ComboImageList = himlSys
        .ComboAddItem "Do One Thing", 3
        .ComboAddItem "Do Something Else", 4
        .ComboAddItem "Run and hide", 5
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .InputText = "New Event 1"
        .InputAlign = TDIBA_Footer
        .Footer = "$input"
        .IconMain = TD_SHIELD_GRADIENT_ICON
        .IconFooter = hIconF
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    Edit:
    I can do an autosize... but the combobox might not have the same font as the form, and TextWidth would create a dependecy ON a form. I'll have to use something like GetTextExtentPoint32.
    Not sure if making it larger than the combo width is a good UI decision anyway tho.. and it can't be smaller. Might make it optional. Or since the hWnd is exposed the user could always do it themselves in the TaskDialog_Created event.
    Last edited by fafalone; Feb 5th, 2017 at 06:18 AM.

  26. #66
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Quote Originally Posted by fafalone View Post
    The size is really a concern?
    You're right of course, consider me chastised. Sadly I am of the age where when I started 'Lean & Mean' was the only to go and I guess it has stuck. Also there was no criticism of your coding style, as you say the Dialog is beautifully simple to use and an elegant addition to a program.

    Have I missed where I can download this version from, or is it still being polished?

  27. #67

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

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

    Still being polished... wanted to get everything done; the combos, the date/time, and the most complicated, combining a date picker and time picker as a single option; and making sure all the options work. Will update it later this afternoon or tonight.

    Edit
    If it's ok, things are complex enough as it is so I'm going to leave things like drop width to the user; it's a single line anyway:
    Code:
    Private Sub TaskDialog3_DialogCreated(ByVal hWnd As Long)
    Call SendMessage(TaskDialog3.hWndCombo, CB_SETDROPPEDWIDTH, 900&, ByVal 0&)
    End Sub
    Edit2: Ugh, you're going to have to hold out until tomorrow. Ran into quite a few complications handling the date/time ranges and checkboxes, the latter due to a bug that took forever to run down.
    And this other TRULY bizarre bug...
    So the Init function resets all the variables to their initial state, and part of that was clearing all the text fields:
    Code:
        m_sContent = ""
        .pszContent = StrPtr(m_sContent)
        m_sFooter = ""
        .pszFooter = StrPtr(m_sFooter)
    etc etc for every field...
    Well, the TDF_KILL_SHIELD_ICON flag was causing a crash, but only when .Init was called (even if it was still new and hadn't been used yet), and I traced it down to another standard text clear:
    Code:
        m_sExpandedInfo = ""
        .pszExpandedInformation = 0 'StrPtr(m_sExpandedInfo)
    That variable is declared just like all the others, nothing had been assigned to it previously, yet for some reason this caused the dialog to appear as a tiny box no bigger than an icon, with an 'X' that led to a crash or no X and having to ctrl-alt-delete. For the life of me I can't figure out WHY, weirdest bug I've ever seen. Took hours to figure out that line was the cause. Setting it to 0 instead of StrPtr fixed the problem.

    So yeah anyway, just minor bug fixes and final touchups now, but the screen shots and documentation posts are a major effort. Just too tired tonight. It's all working now though, so let the hype build!

    After this release I'm planning some good things for 1.0. Going to add those dropdown buttons I was working on, and since that needs subclassing anyway that can then be used to create events for the new controls, like ComboItemChange, InputBoxChange, etc. Then I'm also going to add more controls... definitely a Slider and picture, will see what else.
    Last edited by fafalone; Feb 5th, 2017 at 11:02 PM.

  28. #68
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    This is not life or death, so take your time and get it exactly as you want it. We both know it's gonna be awesome!

    Steve.

  29. #69

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

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

    Will be worth the wait...
    Check it, snuck one more new thing in for this release...
    Now not only can you entirely kill the icon for the shield gradients like post #65, you can replace it with a resource icon id from your app, or set TDF_USE_SHELL32|IMAGERES_ICONID and use one from those (or a custom module you load yourself with LoadLibrary and set to .hInst):

  30. #70
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Considering how much stuff there is on that dialog, it still manages to look neat and tidy!!!

  31. #71

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

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

    Ehh I couldn't resist doing it now... holding off on the major subclassing thing, but did want to add sliders:


    It's a good thing I did too, because I didn't notice until I had to adjust it's coords, but there was a massive lack of proper alignment when the expando control came into play... I had only handled 1 scenario, there were about a dozen more to make sure things are always positioned correct (you can see this issue starting in the current release; if the inputbox is in the footer position, the position doesn't adjust, and if it's the expand into footer area style, it's in the entirely wrong position, from the get-go when expanded by default is on). There went 7 hours.

  32. #72
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Get some sleep man!!!

  33. #73
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    679

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

    Task dialog, with non editable combobox (TDF_COMBO_LIST) or editable (TDF_COMBO_LIST Or TDF_INPUT_BOX) styles, would be superb.

  34. #74
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

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

    and then you should package it into a nice DLL or OCX.

  35. #75

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

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

    Just to update everyone, I ran into a large number of alignment issues. I really want the new controls to work with the existing options as much as possible, and that means individually lining up every control to each scenario of standard options.

    Things like:
    -Controls placed in the main area are counted by the backend API towards the dialog height, but not the button positions. So it creates a blank area at the bottom when the expando control resizes the dialog. So the dialog has to be manually adjusted on top of control alignment.
    -Expando + verify checkbox alters alignment
    -Radio buttons alter alignment slightly differently than command links
    -Expando controls resizing things effect the alignments in all sorts of unpredicted ways (like not eliminating whitespace originally only existing because of adding two vbCrLf's, even after those are removed and the element updated). There's the principle alignment for each control combined with each native control (and more than one native control for the content area), and the alignment in response to expando controls altering the content or footer area.
    -Some are minor adjustments; some are major and require adjustments beyond just changing x,y; like adding and removing line breaks to create whitespace, each in a different way for each of a dozen option scenarios.

    So as the pictures indicate, the basic work is done, but I'd rather spend a bit more time getting everything to play together nicely than further restrict how the new controls can be used in combination with the existing control options.. It's not hard to do this; just time consuming. Still coming soon; just want to get it right.

    Edit:
    @Tech99, yes both are available... the TDF_COMBO_BOX flag adds a combo control, and the type is determine by a .ComboStyle property to choose either dropdown list or edit list.

    @DEXWERX, really?? a DLL or OCX instead of a class module?? I guess I could provide that option but what's the advantage good enough to be worth the loss of easy customization? All it requires right now is a single class module and a couple callback headers that can go in any standard module.

    Edit 2: The major alignment adjustment process has been completed. Now just putting finishing things off and making demos. It took a while, but the good news is that you can use any combination of existing controls (command links, radio buttons, progress bar, expando button, and verify checkbox) and the new controls; I think I've covered every scenario...
    Config InputBox Combo Date DateTime Slider
    Content-Standard OK OK OK OK OK
    Content-CommandLink OK OK OK OK OK
    Content-Radio OK OK OK OK OK
    Content-CmdLnk+Radio OK OK OK OK OK
    Content-Expando-Std OK OK OK OK OK
    Content-Expando-CmdLnk OK OK OK OK OK
    Content-Expando-Radio OK OK OK OK OK
    Content-Expando-CmdLnk+Radio OK OK OK OK OK
    Content-ExpandoDef-ALL 4 OK OK OK OK OK
    Content-ExpandoTF-ALL 4 OK OK OK OK OK
    Content-Verify-Std OK OK OK OK OK
    Content-Verify-CommandLink OK OK OK OK OK
    Content-Verify-Radio OK OK OK OK OK
    Content-Verify-CmdLnk+Radio OK OK OK OK OK
    Content-Exp+Ver-Std OK OK OK OK OK
    Content-Exp+Ver-CommandLink OK OK OK OK OK
    Content-Exp+Ver-Radio OK OK OK OK OK
    Content-Exp+Ver-CmdLnk+Radio OK OK OK OK OK
    Content-Progress-Std OK OK OK OK OK
    Content-Progress-CmdLnk+Radio OK OK OK OK OK
    Content-Progress-Expando (ALL) OK OK OK OK OK
    (C-E-V w/Default) OK OK OK OK OK
    (C-E-V w/Expand to Footer) OK OK OK OK OK
    Content-No Content Text (ALL) OK OK OK OK OK
    Content-No Main Instr (ALL) OK OK OK OK OK
    --------------------
    Button-Std OK OK OK OK OK
    --------------------
    Footer-Std OK OK OK OK OK
    Footer-Verify OK OK OK OK OK
    Footer-Expando-Std OK OK OK OK OK
    Footer-Expando+Verify OK OK OK OK OK
    Footer-Expando-ToFooter OK OK OK OK OK
    Footer-Expando+Verify-ToFooter OK OK OK OK OK

    (adjusting and testing every one of those is what took so long)
    Last edited by fafalone; Feb 14th, 2017 at 12:19 AM.

  36. #76

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

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

    Update: cTaskDialog 0.8

    After the success of the Input Box in 0.7, version 0.8 of cTaskDialog adds even more useful controls added by custom flag. There's now 4 types of controls:
    TDF_INPUT_BOX The textbox from 0.7
    TDF_COMBO_BOX A combo box that can either be an editable one or a dropdown list. It's a ComboBoxEx (ImageCombo), so it accepts an imagelist in the form of an HIMAGELIST.
    TDF_DATETIME Shows a datetime control; either a single one for date or time, or two controls for date AND time.
    TDF_SLIDER A standard slider control with detailed options for the range and ticks.

    Following in the tradition of the existing control options, you can add one of each of these (up to 3) in the same 3 areas where the inputbox could be placed: in the main content area, next to the buttons (replaces the expando and/or verify controls if placed here), or as the footer (the footer icon shows and is properly aligned, but old footer text is covered). Thanks to some painstaking calculations and testing, all these controls are additional options: you can use any number and combination of the built-in controls along with the new custom ones, including the expando control, and a space for them is automatically created. The creation and usage of the new controls follows the exact same easy format of the rest of the class.

    Here's some selected samples; the attached project contains many additional ones showing the different options.

    Code:
    himlSys = GetSystemImagelist(SHGFI_SMALLICON) 'any image list will do; make your own with ImageList_Create or IImageList
    With TaskDialog3
        .Init
        .MainInstruction = "Duplicates"
        .Content = "If you want to exclude an Artists name from the search:"
        .Flags = TDF_VERIFICATION_FLAG_CHECKED Or TDF_COMBO_BOX
        .AddCustomButton 100, "Continue"
        .CommonButtons = TDCBF_CANCEL_BUTTON
        .IconMain = TD_SHIELD_ICON
        .Title = "cTaskDialog Project"
        .ComboCueBanner = "Cue Banner Text"
        .ComboSetInitialState "", 5
    '    .ComboSetInitialItem 1
        .ComboImageList = himlSys
        .ComboAddItem "Item 1", 6
        .ComboAddItem "Item 2", 7
        .ComboAddItem "Item 3", 8
        .VerifyText = "Exclude Jingles"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    
        Label3.Caption = "Checked? " & .ResultVerify
        Label7.Caption = .ResultComboText
        Label9.Caption = .ResultComboIndex
        If .ResultMain = 100 Then
            Label1.Caption = "Continue!"
        Else
            Label1.Caption = "Cancelled."
        End If
    End With

    Here we add pre-selected users to our password demo. The partial code below shows how dual custom controls are used:
    Code:
        .Flags = TDF_INPUT_BOX Or TDF_COMBO_BOX
        .ComboStyle = cbtDropdownList
        .InputIsPassword = True
        .InputAlign = TDIBA_Buttons
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .SetButtonElevated TD_OK, 1
        .SetButtonHold TD_OK
        .ComboAlign = TDIBA_Content
        .ComboSetInitialItem 0
        .ComboImageList = himlSys
        .ComboAddItem "User 1", 6
        .ComboAddItem "User 2", 7
        .ComboAddItem "User 3", 8
        .Footer = "Enter your password then press OK to continue."
        .IconFooter = TD_INFORMATION_ICON
        .IconMain = TD_SHIELD_ERROR_ICON

    The most basic Date control. This can also be a time control.
    Code:
        .Init
        .MainInstruction = "Hello World"
        .Content = "Pick a day, any day" & vbCrLf & vbCrLf
        .Flags = TDF_DATETIME
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .IconMain = TD_INFORMATION_ICON
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    
        Label11.Caption = .ResultDateTime

    Many common options are supported. This example shows combining the new controls with the built-in ones, and setting a limited range in the date and time controls. When the two controls are used, both the chosen date and time are represented by .ResultDateTime.
    Code:
    Dim dTimeMin As Date, dTimeMax As Date
    
    dTimeMin = DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(13, 0, 0)
    dTimeMax = DateAdd("d", 7, dTimeMin)
    dTimeMax = DateAdd("h", 4, dTimeMax)
    
    With TaskDialog1
        .Init
        .MainInstruction = "Date Ranges"
        .Content = "Pick a time, limited to sometime in the next 7 days, between 1pm and 6pm" & vbCrLf & vbCrLf
        .Flags = TDF_DATETIME Or TDF_USE_COMMAND_LINKS
        .DateTimeType = dttDateTime
        .DateTimeAlign = TDIBA_Content
        .DateTimeSetRange True, True, dTimeMin, dTimeMax
        .DateTimeSetInitial dTimeMin
        .AddCustomButton 101, "Set Date" & vbLf & "Apply this date and time to whatever it is you're doing."
        .CommonButtons = TDCBF_CANCEL_BUTTON
        .IconMain = TD_INFORMATION_ICON
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .ShowDialog
    
        Label11.Caption = .ResultDateTime

    Here's a highly customized slider combined with showing the auto-positioning that allows the expando control to be used, even with built-in controls further upping the complexity.
    Code:
        .Init
        .MainInstruction = "Sliding on down"
        .Content = "Pick a number"
        .Flags = TDF_SLIDER Or TDF_USE_COMMAND_LINKS
        .SliderSetRange 0, 100, 10
        .SliderSetChangeValues 10, 20
        .SliderTickStyle = SldTickStyleBoth
        .SliderValue = 50
        .SliderAlign = TDIBA_Content
        .ExpandedControlText = "ExpandMe"
        .ExpandedInfo = "Expanded"
        .AddCustomButton 100, "CommandLink"
        .CommonButtons = TDCBF_OK_BUTTON Or TDCBF_CANCEL_BUTTON
        .IconMain = TD_INFORMATION_ICON

    Finally, here's an example of using 3 of the new controls together in combination with two of the built-in controls, as well as the option to replace the shield icon with one from shell32.dll, while maintaining the gradient background.
    Code:
    himlSys = GetSystemImagelist(SHGFI_SMALLICON)
    Dim hIconF As Long
    hIconF = IconToHICON(LoadResData("ICO_CLIP", "CUSTOM"), 16, 16)
    With TaskDialog1
        .Init
        .MainInstruction = "Schedule Event"
        .Content = "Pick action to schedule. Provide a date, and optionally a specific time. You can also set a name below."
        .Flags = TDF_DATETIME Or TDF_INPUT_BOX Or TDF_COMBO_BOX Or TDF_USE_HICON_FOOTER Or TDF_USE_SHELL32_ICONID Or TDF_KILL_SHIELD_ICON Or TDF_USE_COMMAND_LINKS
        .DateTimeType = dttDateTimeWithCheckTimeOnly
        .DateTimeAlign = TDIBA_Buttons
        .ComboAlign = TDIBA_Content
        .ComboStyle = cbtDropdownList
        .ComboSetInitialItem 1
        .ComboImageList = himlSys
        .ComboAddItem "Do Thing #1", 2
        .ComboAddItem "Do Thing #2", 7
        .ComboAddItem "Do Thing #3", 8
        .CommonButtons = TDCBF_CANCEL_BUTTON
        .InputText = "New Event 1"
        .InputAlign = TDIBA_Footer
        .IconMain = TD_SHIELD_GRADIENT_ICON
        .IconFooter = hIconF
        .IconReplaceGradient = 276
        .Title = "cTaskDialog Project"
        .ParenthWnd = Me.hWnd
        .AddCustomButton 102, "Schedule" & vbLf & "Additional information here."
        .AddRadioButton 110, "Apply to this account only."
        .AddRadioButton 111, "Apply to all accounts."
        .ShowDialog
    
        Label2.Caption = "Radio: " & .ResultRad
        Label5.Caption = .ResultInput
        Label7.Caption = .ResultComboText
        Label9.Caption = .ResultComboIndex
        Label11.Caption = .ResultDateTime
        If .ResultDateTimeChecked = 0 Then
            Label13.Caption = "Time unchecked."
        Else
            Label13.Caption = "Time checked."
        End If
        If .ResultMain = 102 Then
            Label1.Caption = "Scheduled."
        Else
            Label1.Caption = "Cancelled."
        End If
    End With


    Full update notes from the .cls:
    Code:
    'NEW IN VERSION 0.8
    '--Added ability to use comboxes (normal edit dropdown and dropdown list), date/time pickers,
    '  and sliders like the inputbox controls.
    '--There's still the 3 alignment positions from the inputbox, so you can have controls in each
    '  of these places (however, only 1 of each type is allowed)
    '--When TDF_KILL_SHIELD_ICON is used, there's now an option to replace it with a different icon:
    '   Set .IconReplaceGradient...
    '    1) To an ID in your app's resource file (only works when compiled)
    '    2) Add the TDF_USE_SHELL32_ICONID or TDF_USE_IMAGERES_ICONID flag and use an ID from those
    '    3) Set .hInst to a custom module and use an icon ID from that
    '   Using an hIcon is not supported at this time.
    '--Bug fix: Using TDF_KILL_SHIELD_ICON and calling .Init crashed the app
    '--Bug fix: Using an InputBox at the footer position, the bottom half was cut off if no
    '           footer icon was set.
    '--Bug fix: Input box position adjusted for expando only if in the content position, now adjusts
    '           if in footer position too. Prevented this bug in all other controls.
    '--Bug fix: If input box was in footer position, and expanded info was expanded automatically
    '           and into the footer area, the input box would be in the wrong position. Fixed and
    '           prevented for new controls.
    'KNOWN ISSUE: If the slider control is placed in the footer position and an expando control is
    '             set to expand into the footer area, the transparent background on the slider is
    '             lost (turns white) until it's clicked. It's a very unusual and specific situation,
    '             so not going to delay this version while I come up with a fix.
    'TODO:
    'The next version will be 1.0. There's a couple major features planned, including images and more
    'events (for the custom controls). Maybe more controls; like dropdown menus on the buttons.
    'I'm very aware this class needs substantial cleanup, that's also being saved for 1.0
    ' So please go easy on the sloppiness!!! :)
    Last edited by fafalone; Mar 29th, 2020 at 09:17 PM. Reason: Removed invalid attachment link

  37. #77
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

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

    Excellent work from the UK! Much more than the doctor ordered.

    Tiny problem, if you push the expando button you see some strange resizing going on. (Win 10 any way).

    Steve.

  38. #78

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

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

    Yeah the expando button changes the built-in control positions and the size of the dialog, so the custom controls have to be moved too and the API doesn't do it on its own. The API actually counts the custom controls when calculating the dialog height, but forgets about it when the buttons are arranged. So the result was an incorrectly sized dialog with a giant blank space; so I resize to the correct dimensions. The reason for the delay is that it does some weird fading thing... if you don't delay the resize/reposition on a timer, the APIs that get the RECT's return the original value, and you need the new value to correctly position everything; and figuring it out in advance would be a huge undertaking: figuring out not only the RECT size based on the font and text length, with line breaks and everything, but also MS's word-wrapping and dialog-sizing algorithms.

    I'm open to better solutions. There might be a way in the next version where the whole thing is going to be subclassed; but for now things have to be resized and repositioned like they are. The only alternatives are giant blank spots and/or things winding up on top of eachother; so it's that or simply disable the custom controls when the expando button is present.. the awkwardness seemed better.

    Edit

    Coming Soon To A Dialog Near You....

    +Split button and logo image...


    +Logo can also be placed top right... Edit: Got transparency working (to the background color).
    +InputBoxes, ComboBoxes, and Sliders aligned next to the buttons scale in width to take up the available area (automatically adjusted based on furthest-left button)
    +The footer position is still fixed by default, but if you specify a width of -1 it will scale
    +InputBox/Combo/Slider have an added option to manually specify a fixed width
    +Focus placed on the control in the content area (or button area then footer if none) so the inputbox isn't automatically focused if it's a secondary control

    Edit2

    +New alignment options fix widths in dialogs with no main icon, and footer right-align option (in addition to left and center) allow footer text to be shown too.
    Last edited by fafalone; Feb 16th, 2017 at 08:37 PM.

  39. #79
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    679

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

    Thansk fafalone.

    Tested this 0.8 version briefly.

    Taskdialog created with...

    Code:
    TaskDialog1
        .Init
        .ParenthWnd = frmMain.hWnd
        .MainInstruction = "Testing"
        .Content = "Does this work."
        .IconMain = IDI_QUESTION 
        .Title = App.EXEName   '"cTaskDialog Project"
        .flags = TDF_USE_COMMAND_LINKS 'TDF_USE_COMMAND_LINKS_NO_ICON
    'etc...
    do not work, error (TaskDialogIndirect ret=0x80070715) returns when IDI_QUESTION icon is defined. Version 0.6 did work, with IDI_QUESTION icon.
    Last edited by Tech99; Feb 17th, 2017 at 12:44 AM.

  40. #80

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

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

    Yeah there's been an issue with the IDI_QUESTION and IDI_APPLICATION icons...

    In order to display Icon resources from your compiled project's resource file, or from Shell32.dll or Imageres.dll, the hInstance must be set to App.hInstance or the handle of those DLLs. Changing to the class doing App.hInstance by default is what broke the IDI_'s.

    So if you want to use IDI_QUESTION or IDI_APPLICATION, add .hInst = 0 - but note you won't be able to use an icon from your .res file, shell32, or imageres in the other spot (header and footer).

    If you want to permanently change the default, change uTDC.hInstance in Class_Initialize and Init to 0. On the whole I thought displaying resource icons was more important to have as the default, although I'm definitely open to feedback: The two possible scenarios are
    A) You can use an icon from your .res Icon resources just by using it's number, but then must set .hInst = 0 if you want to use IDI_ (0.8), or
    B) You can use IDI_, but then must set .hInst = App.hInstance if you want to use a .res file Icon index (0.6)
    So is (B) better?

    PS- As suggested by the above, if the TDF_USE_SHELL32_ICONID or TDF_USE_IMAGERES_ICONID flags are set, you can't use IDI_ e.g. use a shell32 index for the main icon and IDI_QUESTION for the footer
    Last edited by fafalone; Feb 17th, 2017 at 03:08 AM.

Page 2 of 7 FirstFirst 12345 ... 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