Page 7 of 7 FirstFirst ... 4567
Results 241 to 268 of 268

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

  1. #241

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Yes; specify the window (e.g. Me.hwnd when calling from a Form/UC) as the parent with .ParentHwnd, and use the TDF_POSITION_RELATIVE_TO_WINDOW flag in .dwFlags;

    Code:
        With TaskDialog1
            .Flags = TDF_POSITION_RELATIVE_TO_WINDOW
            .ParenthWnd = Me.hWnd

  2. #242
    New Member
    Join Date
    Apr 2014
    Posts
    14

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

    Thank you, it works.

    The crucial point is:
    .Flags = TDF_POSITION_RELATIVE_TO_WINDOW

    Without this it doesn't work.

  3. #243

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Project Updated - Version 1.4 (Universal Compatibility)

    After review, I've included the undocumented additional common buttons that were used in the AccessUI version (thanks!). The following .CommonButtons are now available, with their return value given in parentheses:

    Code:
    TDCBF_ABORT_BUTTON     (TD_ABORT)
    TDCBF_IGNORE_BUTTON    (TD_IGNORE)
    TDCBF_TRYAGAIN_BUTTON  (TD_TRYAGAIN)
    TDCBF_CONTINUE_BUTTON  (TD_CONTINUE)
    
    TDCBF_HELP_BUTTON      **This will raise the Help Event, and will not close the dialog.**
    The Help button works everywhere, *including MS Access*. Unfortunately, the AccessUI version had a typo; the release had 16384 which isn't anything-- but it looks like they just had a typo originally, there's a comment '104857 which of course makes no sense... but if you convert these values to hex, you find &H10000, &H20000, &H40000, and &H80000 for the other new buttons... &H100000 is **1048576** in decimal-- so they just cut off a digit when copying it down. &H100000 works in Access, I checked.

  4. #244
    Member
    Join Date
    Mar 2020
    Posts
    39

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

    Thank you very much. Note that I had to delete all the 'PtrSafe' to test it on my VB6.

  5. #245

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Apologies, I had the wrong version of mTDSample.bas in the zip. I've updated now to include the correct one and double checked it's fine in VB6.
    Download Attachment: Attachment 190043

    (PS- You shouldn't have needed to remove them from anything besides mTDSample.bas; everywhere else they werre fine-- they appear in red, but are inside conditional compilation blocks so the VB6 compiler doesn't see them; that's now the case with mTDSample.bas too).

  6. #246
    Member
    Join Date
    Mar 2020
    Posts
    39

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

    Thanks a lot. Yes you're right, I had only changed mTDSample.bas. New version is fine. Cheers.

  7. #247
    Addicted Member
    Join Date
    Feb 2022
    Posts
    189

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

    Incredibly impressive project! Great work. Thanks for this fafalone!
    Is there a way to make all of the fonts size 11?
    Is there a way to make this function non-modal? I could never get a messagebox to work that would allow processing while waiting for the user to press OK.
    Code:
    Public Function SimpleDialog(sMessage As String, Optional dwBtn As TDBUTTONS = TDCBF_OK_BUTTON, Optional sTitle As String, Optional sMainText As String, Optional dwIco As TDICONS, Optional hWndOwner As LongPtr, Optional hInst As LongPtr) As TDRESULT
    Last edited by taishan; Mar 8th, 2024 at 09:42 AM.

  8. #248

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    The font is controlled by the system unfortunately... since it's a Direct2D painted window I don't know any way to easily change that (besides changing it system-wide). You could change it for the custom controls, but that's it.

    The simple dialog function should be nonmodal just by omitting hWndOwner.

  9. #249
    Addicted Member
    Join Date
    Jun 2010
    Posts
    200

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

    Hi, I just upgraded/updated my cTaskDialog implementation from ver. 1.2R2 to 1.4U and when trying to compile my project I notice that somehow the ability to add itemData to combobox when adding an item has got lost. We
    added this function back in 2021 if you remember?
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  10. #250

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Did that ever make it into an official release? It's not in the 1.2 R2 release zip but I did find a dev version with it. Anyway, you can add back the same changes in that post, just using LongPtr for the lParam instead of Long. I'll update the release tonight.
    '

  11. #251
    Addicted Member
    Join Date
    Jun 2010
    Posts
    200

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

    I have a zip here it was added to but not sure if it's an official or not, maybe not. I was forced to take a break from VB6 for 2 years and just back some weeks ago so haven't kept up with all changes.

    Waiting for the update as I see there has been other changes as well so better let you put it together ;-)
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  12. #252

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Alright I posted a beta version, try it out, if everything works right that will be just the final version.

    https://github.com/fafalone/cTaskDia...log-1.4.1-beta

    The project now requires mTDHelper.bas in addition to cTaskDialog.cls; this was to to be able to use a single subclassing method that also worked in VBA 64bit and twinBASIC 64bit ('Universal compatibility' means you can use the .cls/.bas complete unmodified across the entire VB6 language world; VB6, VBA6, VBA7 32bit, VBA 64bit, twinBASIC 32bit, and twinBASIC 64bit.)

  13. #253
    Addicted Member
    Join Date
    Jun 2010
    Posts
    200

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

    Ok thanks, I will test it. I will also try to add my "ComboNewIndex" property, which I use in my code already. It makes it possible to check against a stored value and re-initialize a certain list item from last run. Simply put, a combobox (and listbox as well) isn't complete without a newitem property.

    Not sure how much time I'll have to test all this now though as I will leave for a road trip early next week and may be gone for a month, with limited computer and internet capabilities.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  14. #254
    Addicted Member
    Join Date
    Jun 2010
    Posts
    200

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

    Going through the code I am just wondering if these changes aren't needed as well (my additions in Bold, and red to make it easier to see)?

    Code:
    Public Sub Init()
    'resets the entire module
    mPageIndex = 0
    ...
    ReDim aComboItems(0)
    tComboInit.sText = ""
    tComboInit.iImage = 0
    tComboInit.iOverlay = 0
    tComboInit.lpData = 0
    nCbType = 0
    and
    Code:
    Private Sub AddComboBox(nType As ComboType)
    Dim lEditX As Long, lEditY As Long, cxEdit As Long, cyEdit As Long
    Dim lOffX As Long
    Dim tRC As RECT
    m_HasCustomControl = True
    ...
            If himlCombo Then
                Call SendMessageW(hCombo, CBEM_SETIMAGELIST, 0, ByVal himlCombo)
            End If
            For I = 0 To UBound(aComboItems)
                CBX_InsertItem hCombo, aComboItems(i).sText, aComboItems(i).iImage, aComboItems(i).iOverlay, aComboItems(i).lpData
            Next I
            If bCBInitValid Then
                Dim cbxi As COMBOBOXEXITEMW
    and
    Code:
    Public Sub ComboSetInitialState(sText As String, Optional iImage As Long = -1, Optional iOverlay As Long = -1, Optional lParam As LongPtr = 0)
    bCBInitValid = True
    tComboInit.sText = sText
    tComboInit.iImage = iImage
    tComboInit.iOverlay = iOverlay
    tComboInit.lpData = lParam
    End Sub
    Then there are some functions starting with zzCombo... but not really sure what they are about as zz is often used for subclassed stuff (from what I remember) but not sure if it's the case here or if it's something for development/testing or what.

    Anyway, still a bit VB6 rusty, so I may have missed something or got the above wrong. It's a big and complex, but very useful, class.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  15. #255
    Addicted Member
    Join Date
    Jun 2010
    Posts
    200

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

    Here is my implementation of a NewIdex property as well, very simple and few lines of code:

    DEclaration part
    Code:
    Private nComboIdx As Long
    Private nComboNewIndex As Long
    We only need a Get property
    Code:
    Public Property Get ComboHeight() As Long: ComboHeight = cyCombo: End Property
    Public Property Get ComboNewIndex() As Long: ComboNewIndex = nComboNewIndex: End Property
    And the asigment of value in the
    Code:
    Public Sub ComboAddItem(...)
    If aComboItems(0).sText = "" Then
        aComboItems(0).sText = sText
        aComboItems(0).iImage = iImage
        aComboItems(0).iOverlay = iOverlay
        aComboItems(0).lpData = lParam
        nComboNewIndex = 0
        Exit Sub
    End If
    ReDim Preserve aComboItems(UBound(aComboItems) + 1)
    aComboItems(UBound(aComboItems)).sText = sText
    aComboItems(UBound(aComboItems)).iImage = iImage
    aComboItems(UBound(aComboItems)).iOverlay = iOverlay
    aComboItems(UBound(aComboItems)).lpData = lParam
    nComboNewIndex = UBound(aComboItems)
    If hCombo Then
    As long as not the ability to insert an item in the middle of the list, it could stay this simple...

    Also, would like to point out that you have introduced as backward incompatibility issue by changing
    Code:
    Public Enum TDBUTTONS
    to
    Code:
    Public Enum TASKDIALOG_COMMON_BUTTON_FLAGS
    As this Enum is likely to be used in project code using cTaskDialog.cls

    Not a big problem as it throws a compile error but it shoul dbe noted in the change log to not leave programmers dazed and

    EDIT: My wrong on the latter, it was because my code was based on 1.2R2, before
    Code:
    Version 1.2.6 Universal
    'Bug fix: SimpleDialog return TDBUTTONS insted of TDRESULT
    which made should have been written " SimpleDialog returned TDBUTTONS insted of TDRESULT"
    Last edited by 7edm; Jun 13th, 2024 at 07:18 AM.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  16. #256

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    CBX_InsertItem definitely needs to include it yeah; but tComboInit isn't an actual item; it's just to set the edit box.

    ComboNewIndex... I'm not sure the name really captures what it represents; just seems like it would be better as a ComboItemCount property, but then I'd figured the user inserted the items... they should know how many... I'll add it though.

    And yeah should have mentioned the enum name change, sorry. It was changed for correctness; that's the official name in the Windows SDK and on MSDN.


    I've updated the beta with these changes; https://github.com/fafalone/cTaskDia...log-1.4.1-beta

  17. #257

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Project Update - cTaskDialog 1.5 Universal Compatibility Version

    This version adds the features requested by 7edm above for Combo Item lpData and ComboNewIndex, and now also no longer requires a manifest for comctl32 6.0. While it's still preferable if you use one, in response to this issue/request, I've added code that uses the SxS Activation Context API to briefly activate comctl6 for the call to TaskDialogIndirect (or TaskDialog, in .SimpleDialog), since it's impractical to ask people you distribute VBA files to to have modified Office exes. It uses code from my twinBASIC Control Panel Applet demo, originally used to get comctl6 Visual Styles in a standard DLL where the host exe didn't have a manifest, which now works with this courtesy of a great tip from VBF user VanGoghGaming.

    It works like this... it's first prepared in Class_Initialize:

    Code:
    hActCtx = INVALID_HANDLE_VALUE
    If (IsComCtl6 = False) And (useropt_no_force_comctl6 = False) Then
        hShell32 = LoadLibrary("shell32.dll")
    
        szSys = Environ$("WINDIR") & "\System32"
        Dim ctx As ACTCTX
        ctx.cbSize = LenB(ctx)
        ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID Or ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID Or ACTCTX_FLAG_HMODULE_VALID
        ctx.hModule = hShell32
        ctx.lpResourceName = 124
        ctx.lpAssemblyDirectory = StrPtr(szSys)
        hActCtx = CreateActCtx(ctx)
    End If
    Then the TaskDialogIndirect call is wrapped by:

    Code:
    If hActCtx <> INVALID_HANDLE_VALUE Then 'we need to activate comctl32.dll 6.0
        Dim lActCtxCookie As LongPtr
        ActivateActCtx hActCtx, lActCtxCookie
    End If
    
    
    hr = TaskDialogIndirect(uTDC, pnButton, pnRadButton, pfVerify)
     
    If hActCtx <> INVALID_HANDLE_VALUE Then
        DeactivateActCtx 0, lActCtxCookie 'Deactivate, because we don't want to interfere with the rest of the app
    End If
    It's then release when the class terminates.

    Download Attachment: Attachment 191998

    Project also on GitHub.
    Last edited by fafalone; Jun 15th, 2024 at 05:06 AM.

  18. #258
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    329

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

    the latest version for vb6

    Private Sub Command13_Click()
    Dim td As TDBUTTONS 'User Defined Type not Defined

  19. #259

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Sorry I renamed that enum to the actual SDK/MSDN name, TASKDIALOG_COMMON_BUTTON_FLAGS. I updated the zip and GitHub Form1.frm but that's the only change.
    Last edited by fafalone; Jun 15th, 2024 at 05:09 AM.

  20. #260
    Addicted Member
    Join Date
    Jun 2010
    Posts
    200

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

    Quote Originally Posted by fafalone View Post
    ComboNewIndex... I'm not sure the name really captures what it represents; just seems like it would be better as a ComboItemCount property, but then I'd figured the user inserted the items... they should know how many... I'll add it though.
    [/url]
    VB6 builtin and Common Controls ComboBox & ListBox both contains the property "NewIndex", which is the ListIndex of the last added item, which not necessarily is the same as the count if an item was added somewhere among existing items, which isn't an isse here at present at least. I prefixed it with Combo as you have used that style but I think NewIndex part shouldn't change as it's a well known (well not by you obviously ) world in the context.

    So note, it's not the same as the list count but is meant to be used for direct code operations in connection with an item being added..
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  21. #261
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    329

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

    Quote Originally Posted by fafalone View Post
    Project Update - cTaskDialog 1.5 Universal Compatibility Version

    This version adds the features requested by 7edm above for Combo Item lpData and ComboNewIndex, and now also no longer requires a manifest for comctl32 6.0. While it's still preferable if you use one, in response to this issue/request, I've added code that uses the SxS Activation Context API to briefly activate comctl6 for the call to TaskDialogIndirect (or TaskDialog, in .SimpleDialog), since it's impractical to ask people you distribute VBA files to to have modified Office exes. It uses code from my twinBASIC Control Panel Applet demo, originally used to get comctl6 Visual Styles in a standard DLL where the host exe didn't have a manifest, which now works with this courtesy of a great tip from VBF user VanGoghGaming.

    It works like this... it's first prepared in Class_Initialize:

    Code:
    hActCtx = INVALID_HANDLE_VALUE
    If (IsComCtl6 = False) And (useropt_no_force_comctl6 = False) Then
        hShell32 = LoadLibrary("shell32.dll")
    
        szSys = Environ$("WINDIR") & "\System32"
        Dim ctx As ACTCTX
        ctx.cbSize = LenB(ctx)
        ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID Or ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID Or ACTCTX_FLAG_HMODULE_VALID
        ctx.hModule = hShell32
        ctx.lpResourceName = 124
        ctx.lpAssemblyDirectory = StrPtr(szSys)
        hActCtx = CreateActCtx(ctx)
    End If
    Then the TaskDialogIndirect call is wrapped by:

    Code:
    If hActCtx <> INVALID_HANDLE_VALUE Then 'we need to activate comctl32.dll 6.0
        Dim lActCtxCookie As LongPtr
        ActivateActCtx hActCtx, lActCtxCookie
    End If
    
    
    hr = TaskDialogIndirect(uTDC, pnButton, pnRadButton, pfVerify)
     
    If hActCtx <> INVALID_HANDLE_VALUE Then
        DeactivateActCtx 0, lActCtxCookie 'Deactivate, because we don't want to interfere with the rest of the app
    End If
    It's then release when the class terminates.

    Download Attachment: Attachment 191998

    Project also on GitHub.
    how to use ActCtx tech to add get more manifest features?

  22. #262

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    @7edm, got it. Forgot those existed honestly. The new version covers that ok though?

    @loquat, the code shows you how; you just need to activate it before the calls that create whatever you want the manifest loaded by CreateActCtx to apply to. I've never tried this with Forms though; you'd probably need it activated before the form is loaded at all. What specifically are you trying to do?

  23. #263
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,748

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

    I don't know if it makes any difference in this case but I would avoid using "Environ" or any other VB6 string functions that are not Unicode-capable. GetSystemDirectoryW should do the trick here.

  24. #264

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    Pretty sure a lot more than cTaskDialog would break if someone installed Windows to a non-ANSI path, if that's even allowed. I'll change it just in case but low priority so it will be in the next update but not updating just for that.

  25. #265
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    329

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

    Rename controls' name on VB6 Form1.frm from Commandxx to meaningful names like cmdWithSliderBasicSlider
    Form1.frm

  26. #266
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    329

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

    Quote Originally Posted by fafalone View Post
    @loquat, the code shows you how; you just need to activate it before the calls that create whatever you want the manifest loaded by CreateActCtx to apply to. I've never tried this with Forms though; you'd probably need it activated before the form is loaded at all. What specifically are you trying to do?
    like ocx regfree/XPThemes/Administrator rights

  27. #267

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,096

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

    For themes, you just have to activate the manifest with ActivateActCtx prior to CreateWindowEx being called; for a VB Form that's probably prior to the form loading at all but I'm not sure.

    You can't change admin status during runtime.

    Regfree OCX is a problem because the manifest you're loading has to come from somewhere... this method allows you to dynamically load a manifest from somewhere other than the exe, it doesn't eliminate the requirement all together.

  28. #268
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,748

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

    Quote Originally Posted by fafalone View Post
    I'll change it just in case but low priority so it will be in the next update but not updating just for that.
    You could eliminate it altogether since the "ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID" flag is not needed in this scenario.

Page 7 of 7 FirstFirst ... 4567

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