{"id":27696165,"url":"https://github.com/fafalone/cautocomplete","last_synced_at":"2025-08-22T17:07:17.849Z","repository":{"id":289225130,"uuid":"970528489","full_name":"fafalone/cAutoComplete","owner":"fafalone","description":"Custom Autocomplete Class for twinBASIC","archived":false,"fork":false,"pushed_at":"2025-04-22T23:45:08.000Z","size":4958,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T15:08:18.559Z","etag":null,"topics":["autocomplete","autocompletion","com","interfaces","twinbasic","vb6","windows","windows-api"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic 6.0","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fafalone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-22T06:38:34.000Z","updated_at":"2025-04-22T23:45:12.000Z","dependencies_parsed_at":"2025-04-23T04:47:29.889Z","dependency_job_id":null,"html_url":"https://github.com/fafalone/cAutoComplete","commit_stats":null,"previous_names":["fafalone/cautocomplete"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fafalone/cAutoComplete","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FcAutoComplete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FcAutoComplete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FcAutoComplete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FcAutoComplete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fafalone","download_url":"https://codeload.github.com/fafalone/cAutoComplete/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fafalone%2FcAutoComplete/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271672625,"owners_count":24800706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocomplete","autocompletion","com","interfaces","twinbasic","vb6","windows","windows-api"],"created_at":"2025-04-25T15:08:16.922Z","updated_at":"2025-08-22T17:07:17.776Z","avatar_url":"https://github.com/fafalone.png","language":"Visual Basic 6.0","readme":"# cAutoComplete\n### Custom Autocomplete Class for twinBASIC\n\nThis is a port of my original VB6 project: [[VB6] Using IAutoComplete / IAutoComplete2 including autocomplete with custom lists ](https://www.vbforums.com/showthread.php?836015-VB6-Using-IAutoComplete-IAutoComplete2-including-autocomplete-with-custom-lists)\n\nIt replaces oleexp.tlb with WinDevLib/WinDevLibImpl, which with tB allows greatly simplifying things by eliminating v-table redirects. It's been updated to also be x64 compatible.\n\n\u003e[!NOTE]\n\u003eThe twinproj is in a zip since it exceeds GitHub's 25MB limit; tB still includes all files and duplicates references, so it includes WinDevLib (13MB) and WinDevLibImpl which has its own copy of WinDevLib as its base.\n----\n\n![jgjDdBD](https://github.com/user-attachments/assets/894a28ba-c1e6-4165-bb4e-fbe498aadfb0)\n\n## `IAutoComplete` / `IAutoComplete2` / `IEnumString`\n\n`SHAutocomplete` has many well known limitations, the biggest being if you want to supply your own list to use with it. I was very impressed with Krool's work on this interface, and not wanting to include a whole other TLB set out to do it with oleexp, and now, bring it to twinBASIC/WinDevLib as Krool has done with his.\n\nIAutoCompleteDropdown is used to provide the status of the dropdown autosuggest list. The .DropdownStatus method reports whether it's down, and the text of an item if an item in the list is selected. In the sample project, this is run on an automatically updated timer enabled in the 'basic filesystem' routine. It also exposes the .ResetEnumerator call to update the dropdown list while it's open.\n\nHere's what the code looks like:\n\n\ncAutoComplete.cls - Unchanged besides hwnd to LongPtr.\n\n```vba\nOption Explicit\n\nPrivate pACO As AutoComplete\nPrivate pACL As ACListISF\nPrivate pACL2 As IACList2\nPrivate pACLH As ACLHistory\nPrivate pACLMRU As ACLMRU\nPrivate pACM As ACLMulti\nPrivate pObjMgr As IObjMgr\nPrivate pDD As IAutoCompleteDropDown\nPrivate pUnk As IUnknownUnrestricted\nPrivate m_hWnd As LongPtr\nPrivate pCust As cEnumString\n \nPrivate Sub Class_Initialize()\nSet pACO = New AutoComplete\nEnd Sub\n\nPublic Sub AC_Filesys(hWnd As LongPtr, lOpt As AUTOCOMPLETEOPTIONS)\nSet pACL = New ACListISF\npACO.Init hWnd, pACL, \"\", \"\"\npACO.SetOptions lOpt\npACO.Enable 1\nm_hWnd = hWnd\nEnd Sub\nPublic Sub AC_Disable()\npACO.Enable 0\nEnd Sub\nPublic Sub AC_Enable()\npACO.Enable 1\nEnd Sub\nPublic Sub AC_Custom(hWnd As LongPtr, sTerms() As String, lOpt As AUTOCOMPLETEOPTIONS)\nSet pCust = New cEnumString\npCust.SetACStringList sTerms\npACO.Init hWnd, pCust, \"\", \"\"\npACO.SetOptions lOpt\npACO.Enable 1\nm_hWnd = hWnd\nEnd Sub\nPublic Sub UpdateCustomTerms(sTerms() As String)\nIf (pCust Is Nothing) = False Then\n    pCust.SetACStringList sTerms\nEnd If\nEnd Sub\nPublic Sub AC_ACList2(hWnd As LongPtr, lOpt As AUTOCOMPLETEOPTIONS, lOpt2 As AUTOCOMPLETELISTOPTIONS)\nSet pACL = New ACListISF\nSet pACL2 = pACL\nIf (pACL2 Is Nothing) = False Then\n    pACL2.SetOptions lOpt2\n    pACO.Init hWnd, pACL2, \"\", \"\"\n    pACO.SetOptions lOpt\n    pACO.Enable 1\n    m_hWnd = hWnd\nElse\n    Debug.Print \"Failed to create IACList2\"\nEnd If\nEnd Sub\nPublic Sub AC_History(hWnd As LongPtr, lOpt As AUTOCOMPLETEOPTIONS)\nSet pACLH = New ACLHistory\npACO.Init hWnd, pACLH, \"\", \"\"\npACO.SetOptions lOpt\npACO.Enable 1\nm_hWnd = hWnd\n\nEnd Sub\nPublic Sub AC_MRU(hWnd As LongPtr, lOpt As AUTOCOMPLETEOPTIONS)\nSet pACLMRU = New ACLMRU\npACO.Init hWnd, pACLMRU, \"\", \"\"\npACO.SetOptions lOpt\npACO.Enable 1\nm_hWnd = hWnd\n\nEnd Sub\n\nPublic Sub AC_Multi(hWnd As LongPtr, lOpt As AUTOCOMPLETEOPTIONS, lFSOpts As AUTOCOMPLETELISTOPTIONS, bFileSys As Boolean, bHistory As Boolean, bMRU As Boolean, bCustom As Boolean, Optional vStringArrayForCustom As Variant)\n\n   On Error GoTo e0\n\nSet pACM = New ACLMulti\nSet pObjMgr = pACM\n\nIf bFileSys Then\n    Set pACL = New ACListISF\n    Set pACL2 = pACL\n    pACL2.SetOptions lFSOpts\n    pObjMgr.Append pACL2\nEnd If\nIf bMRU Then\n    Set pACLMRU = New ACLMRU\n    pObjMgr.Append pACLMRU\nEnd If\nIf bHistory Then\n    Set pACLH = New ACLHistory\n    pObjMgr.Append pACLH\nEnd If\nIf bCustom Then\n    Dim i As Long\n    Dim sTerms() As String\n    ReDim sTerms(UBound(vStringArrayForCustom))\n    For i = 0 To UBound(vStringArrayForCustom)\n        sTerms(i) = vStringArrayForCustom(i)\n    Next i\n    Set pCust = New cEnumString\n    pCust.SetACStringList sTerms\n    pObjMgr.Append pCust\nEnd If\n\npACO.Init hWnd, pObjMgr, \"\", \"\"\npACO.SetOptions lOpt\npACO.Enable 1\nm_hWnd = hWnd\n   On Error GoTo 0\n   Exit Sub\n\ne0:\n\n    Debug.Print \"cAutocomplete.AC_Multi.Error-\u003e\" \u0026 Err.Description \u0026 \" (\" \u0026 Err.Number \u0026 \")\"\n\nEnd Sub\n\nPublic Function DropdownStatus(lpStatus As Long, sText As String) As Long\nIf pDD Is Nothing Then\n    Set pDD = pACO\nEnd If\nDim lp As LongPtr\n\npDD.GetDropdownStatus lpStatus, lp\nSysReAllocStringW VarPtr(sText), lp\nCoTaskMemFree lp\n\nEnd Function\nPublic Sub ResetEnum()\nIf pDD Is Nothing Then\n    Set pDD = pACO\nEnd If\npDD.ResetEnumerator\nEnd Sub\n```\n\nImplementing IEnumString's functions\\\nNote that in addition to the change of moving the code here from the old redirects, there's the small change that to be more correct and in line with the documented signature (`LPOLESTR *`), the `rgelt` argument of `IEnumString::Next` has been changed from ByVal to ByRef. This means the string pointers have to be copied to `VarPtr(rgelt)` instead of just `rgelt`. There's also a bugfix fixing mismatched parentheses for `CoTaskMemAlloc`\n\n\n```vba\nPrivate Sub IEnumString_Next(ByVal celt As Long, rgelt As LongPtr, pceltFetched As Long)\nDebug.Print \"cEnumString_Next\"\nDim lpString As LongPtr\nDim i As Long\nDim celtFetched As Long\nIf rgelt = 0 Then\n    Err.ReturnHResult = E_POINTER\n    Exit Sub\nEnd If\n\nFor i = 0 To (celt - 1)\n    If nCur = nItems Then Exit For\n    lpString = CoTaskMemAlloc(LenB(sItems(nCur) \u0026 vbNullChar))\n    If lpString = 0 Then Err.ReturnHResult = S_FALSE: Exit Sub\n    \n    CopyMemory ByVal lpString, ByVal StrPtr(sItems(nCur)), LenB(sItems(nCur) \u0026 vbNullChar)\n    CopyMemory ByVal UnsignedAdd(VarPtr(rgelt), i * LenB(Of LongPtr)), lpString, LenB(Of LongPtr)\n    \n    nCur = nCur + 1\n    celtFetched = celtFetched + 1\nNext i\n If pceltFetched Then\n     pceltFetched = celtFetched\n End If\n If i \u003c\u003e celt Then Err.ReturnHResult = S_FALSE\n Debug.Print \"IES_Next retval=\" \u0026 Err.ReturnHResult\n\nEnd Sub\n\nPrivate Sub IEnumString_Skip(ByVal celt As Long)\nIf nCur + celt \u003c= nItems Then\n    nCur = nCur + celt\n    Err.ReturnHResult = S_OK\nElse\n    Err.ReturnHResult = S_FALSE\nEnd If\nEnd Sub\nPrivate Sub IEnumString_Reset()\nStringCountReset\nEnd Sub\nPrivate Sub IEnumString_Clone(ppenum As IEnumString)\nErr.ReturnHResult = E_NOTIMPL\nEnd Sub\n```\n\nFor the complete code, see the attached project.\n\n### Requirements \n-Windows Development Library for twinBASIC (WinDevLib)\\\n-WinDevLib for Implements (should be after WinDevLib in priority list)\n\n### Thanks \nKrool's project mentioned above is what inspired me to do this, and I borrowed a few techniques from his project, especially for IEnumString.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffafalone%2Fcautocomplete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffafalone%2Fcautocomplete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffafalone%2Fcautocomplete/lists"}