Page 2 of 2 FirstFirst 12
Results 41 to 67 of 67

Thread: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

  1. #41
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    but in VB6 you'd have to go with the nuclear option of implementing it yourself in a BAS module.
    Ah yes, I did the same thing in my large WinRT project for IVector_(H)String. I actually wanted to avoid that. It really needs something like an IList<T> as a helper function.

  2. #42

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Lightbulb Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Usually you can find other objects that give you the vector you want. For example both ClipboardContentOptions.HistoryFormats and RemoteLauncherOptions.PreferredAppIds give you an IVector_HSTRING.

    And for XAML Binding of control properties you can use a custom implementation of IBindableVector in a class like I did in the PDF Viewer example above.

  3. #43
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    I know. It's a bit cumbersome, but it's also the best way instead of creating an IVector_xxx in a .bas file.

  4. #44

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Cool Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by -Franky- View Post
    My question is: How do I create a new and empty IVector_IStorageItem using your TLB?
    Since IDataPackage.SetStorageItems wants only an IIterable_IStorageItem parameter and does not require a full IVector_IStorageItem implementation then the problem is simplified a lot and we can implement these IIterable interfaces in a regular cStorageItems class using a vanilla Collection object as backing storage for the vector's elements:

    Code:
    Class cStorageItems
    
    Implements IIterable_IStorageItem, IIterator_IStorageItem
    
    Private BackingStorage As Collection, m_CurrentIndex As Long
    
    Friend Function This(vFiles As Variant) As IIterable_IStorageItem
    Dim vFile As Variant
        Set This = Me: If Not IsArray(vFiles) Then vFiles = Array(vFiles)
        With New cAwait
            For Each vFile In vFiles
                If .Await(StorageFileStatics.GetFileFromPathAsync(StrRef(vFile))) = AsyncStatus_Completed Then BackingStorage.Add .GetResults(Of IStorageFile)
            Next vFile
        End With
    End Function
    
    Private Function IIterable_IStorageItem_First() As IIterator_IStorageItem
        m_CurrentIndex = 0: Set IIterable_IStorageItem_First = Me
        Debug.Print "IIterable_IStorageItem_First"
    End Function
    
    Private Property Get IIterator_IStorageItem_Current() As IStorageItem
        Set IIterator_IStorageItem_Current = BackingStorage(m_CurrentIndex + 1)
        Debug.Print "IIterator_IStorageItem_Current"
    End Property
    
    Private Property Get IIterator_IStorageItem_HasCurrent() As BooleanByte
        IIterator_IStorageItem_HasCurrent = Abs(m_CurrentIndex <= BackingStorage.Count - 1)
        Debug.Print "IIterator_IStorageItem_HasCurrent"
    End Property
    
    Private Function IIterator_IStorageItem_MoveNext() As BooleanByte
        m_CurrentIndex = m_CurrentIndex + 1: IIterator_IStorageItem_MoveNext = IIterator_IStorageItem_HasCurrent
        Debug.Print "IIterator_IStorageItem_MoveNext"
    End Function
    
    Private Function IIterator_IStorageItem_GetMany(ByVal Length As Long, ByVal Items As LongPtr) As Long
        ' Not Implemented
    End Function
    
    Private Sub Class_Initialize()
        Set BackingStorage = New Collection
    End Sub
    
    End Class
    As you can see the implementation is a lot simpler because these interfaces are already declared and we don't need a BAS module anymore. However we still need memory allocation for the IIterable_IStorageItem elements, hence the need for a Collection.

    Here's the updated ShareUI.zip project showcasing this new approach.

    I'd still go with the previous FolderLauncherOptions method of obtaining a full-fledged vector implementation as it's still a lot easier and probably performs better than a Collection (although not by much).

  5. #45
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    I'd still go with the previous FolderLauncherOptions method of obtaining a full-fledged vector implementation as it's still a lot easier and probably performs better than a Collection (although not by much).
    I also believe that's the best way. I partly did it that way in my large WinRT project as well.

  6. #46
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    Also please feel free to post your creations in this thread as well instead of exclusively on the German forum!
    Since the question about how to access this ShareUI dialog was asked in a German forum, I'm naturally posting my example there as well. However, I'm not using your TLB in this example. Yes, I know it would be clearer and simpler with TLB. I hope you can forgive me.

  7. #47

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Wink Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    I wasn't talking about the ShareUI dialog, you couldn't have posted that since the IDataTransferManagerInterop interface wasn't included in the TypeLib at the time. You could have posted your video conversion example though, that could have been interesting for many other users.

    Anyway, I have now updated the TypeLib with this missing interface and added the ShareUI sample to the collection linked in the first post above.

    This update also includes the FolderWatcher project that demonstrates how you can monitor a folder for file changes and receive events when such changes occur.

    Monitored changes include:

    • file created (or copied into the folder)
    • file deleted
    • file renamed (reported as creation + deletion)
    • file size changed (like editing a text file)
    • file date changed (usually happens during editing as well)
    • file attributes changed

  8. #48
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    The code for this video converter was written for a specific problem and can be found here: https://www.vb-paradise.de/index.php...esen/?pageNo=3 <- Last post on this page. On page 4, I'll show a few more small changes to the code.

  9. #49
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    138

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    This update also includes the FolderWatcher project that demonstrates how you can monitor a folder for file changes and receive events when such changes occur.[/LIST]
    Error when try to run in cFileQuery.cls:
    Code:
    Set StorageFolderStatics.GetFolderFromPathAsync(StrRef(sWatchedFolder)).Completed = Me
    Attached Images Attached Images  

  10. #50

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Red face Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Open another project from the samples collection (like the GIF Player for example) and copy the 3 lines of code with the registry key check from Form_Load, looks like I forgot to add them in the FolderWatch project!

  11. #51
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    138

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    copy the 3 lines of code with the registry key
    Runtime error13 Type mismatch in line
    Code:
    If RegValStr(HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Visual Basic\6.0", "AllowUnsafeObjectPassing") <> APITRUE Then

  12. #52

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Wink Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    A little help maybe, what exactly is causing type mismatch for you, that line of code is very straightforward and it works just fine for everyone else...

  13. #53
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    @VanGoghGaming: I believe the error occurs when the setting for how errors are handled is configured under "General" in the IDE options. You are comparing a string with WinRT.BOOL.APITRUE here, which triggers the error. CStr(APITRUE) resolves the issue when reading and writing the value..
    Last edited by -Franky-; May 8th, 2026 at 01:28 AM.

  14. #54
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    138

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    A little help maybe, what exactly is causing type mismatch for you, that line of code is very straightforward and it works just fine for everyone else...
    APITRUE and HKEY_CURRENT_USER are not declare ... when i declare in a module every thing is ok
    Code:
    Public Const HKEY_CURRENT_USER As Long = &H80000001
    Public Const APITRUE As String = "1"

  15. #55

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Lightbulb Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by -Franky- View Post
    @VanGoghGaming: I believe the error occurs when the setting for how errors are handled is configured under "General" in the IDE options. You are comparing a string with WinRT.BOOL.APITRUE here, which triggers the error. CStr(APITRUE) resolves the issue when reading and writing the value..
    I can't reproduce it for any of the error trapping options in the General tab, probably because this isn't an error, the compiler is supposed to automatically coerce Long to String in this case. That's why I am at a loss for why this is happening in some cases.

    Quote Originally Posted by cliv View Post
    APITRUE and HKEY_CURRENT_USER are not declare ... when i declare in a module every thing is ok
    Code:
    Public Const HKEY_CURRENT_USER As Long = &H80000001
    Public Const APITRUE As String = "1"
    Those values are definitely declared as Enums in the TypeLib, just right-click one and select Definition. Maybe you have an ancient version of the TypeLib that you need to overwrite with the latest one from the first post above.

  16. #56
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    One should not leave it to the compiler to correctly cast values during a comparison. In .NET, with "Option Strict On," a comparison between a string and for example an integer would immediately be flagged as an error in the code.

  17. #57

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Wink Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    .NET is for the weak, that's why we keep on trucking in VB6! The compiler is perfectly capable to coerce value types as needed:

    Code:
    Debug.Print 1 = "1" ' Prints True
    I am more interested why exactly it produced Type mismatch only for @cliv above. Maybe it's an issue with SP6 not being installed or more likely an outdated TypeLib, either way it should work correctly all the time.

  18. #58
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,167

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    That's right! Embrace language constraints, strive for brevity and dream about direct machine opcodes via Emit :-))

    SP6 missing is possible but unlikely (everything will bomb out). I bet it's a case of having an old version of the typelib lying around registered in a temporary folder and now cannot untangle the registry mess.

    cheers,
    </wqw>

  19. #59
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    I am more interested why exactly it produced Type mismatch only for @cliv above. Maybe it's an issue with SP6 not being installed or more likely an outdated TypeLib, either way it should work correctly all the time.
    I am also encountering this error. SP6 and all other available updates for VB6 have been installed as well. Using CStr(APITRUE) resolved the error. I am also using your latest TLB.

    One really shouldn't speak negatively about other programming languages. Everyone who programs in VB.NET pokes fun at VB6 those who program in C# poke fun at those who program in VB.NET, and so on. Ultimately, it doesn't matter which language you program in. Every programming language has its own advantages and disadvantages. For instance, I personally would have liked to have had "Option Strict On" available in VB6 right from the start.

  20. #60

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Talking Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    It was a joke mate, just for laughs. Maybe you have some Add-Ins that cause this error, otherwise I really don't know what's happening. You were always able to compare strings with integers, it's a core feature.

  21. #61
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    138

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    I am more interested why exactly it produced Type mismatch only for @cliv above. Maybe it's an issue with SP6 not being installed or more likely an outdated TypeLib, either way it should work correctly all the time.
    Name:  2026-05-11_095645.jpg
Views: 113
Size:  73.0 KBName:  2026-05-11_095335.jpg
Views: 112
Size:  62.0 KBName:  2026-05-11_100036.jpg
Views: 112
Size:  9.3 KB

  22. #62

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Question Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    That's interesting, my VB6 doesn't display "Forms3: 12.0.4518.101" in the bottom-right corner. The rest of numbers are the same, Version 9782 and VBA: Retail 6.0.9782. Wondering what's up with that Forms3 stuff?

  23. #63
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    138

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    That's interesting, my VB6 doesn't display "Forms3: 12.0.4518.101"
    ...because i have i installed Microsoft Access 2007 for old database and Microsoft Office LTSC Professional Plus 2021


    Edit (Copilot):
    Forms3: 12.0.4518.101 is the version of the Microsoft Forms 2.0 ActiveX library (FM20.DLL) that Visual Basic 6.0 is using on your system. Forms3 is the internal name used by Microsoft for the third?generation MSForms library, which provides the controls used in VB6 and VBA UserForms. Forms3 corresponds to the DLL: FM20.DLL
    This DLL is installed with Microsoft Office, not with VB6 itself.
    The version you see: 12.0.4518.101 corresponds to Office 2007 (Office 12).
    Last edited by cliv; May 11th, 2026 at 07:10 AM.

  24. #64

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Wink Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Even AI is stumped by this comparison conundrum!

    Name:  VB6Error.png
Views: 110
Size:  6.4 KB

    I've finally managed to reproduce the error eventually by deleting the registry key entirely. It turns out vbNullString is not a valid comparison value for an integer!

  25. #65
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    I've finally managed to reproduce the error eventually by deleting the registry key entirely. It turns out vbNullString is not a valid comparison value for an integer!
    With "Option Strict On" this would never have happened. Just kidding. CStr(APITRUE) is enough to solve the problem.

  26. #66
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,167

    Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    > With "Option Strict On" this would never have happened

    Too bad the option is not available in MIDL :-))

    cheers,
    </wqw>

  27. #67

    Thread Starter
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,619

    Cool Re: [VB6] - WinRT Interfaces & XAML Islands TypeLibs for VB6/VBA x86 and VBA7 x64

    Quote Originally Posted by VanGoghGaming View Post
    It turns out vbNullString is not a valid comparison value for an integer!
    Fixed this bug and uploaded the new samples collection archive. This version also includes the BindableRecordset project which is an Access MDB Database editor using a WinRT XAML ListView control bound to an ADODB Recordset.

    This project focuses on editing the Customers table from the classic Northwind.mdb database while bridging technologies several decades apart:

    • a classic ADODB Recordset is used to open the table
    • a modern XAML ListView control is bound to this Recordset with an implementation of the IBindableVector interface

    The binding is set to two-way mode and triggered on PropertyChanged so that every change is recorded in real time and saved to the database.

    Name:  BindableRecordset.jpg
Views: 44
Size:  44.2 KB

Page 2 of 2 FirstFirst 12

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