Posted: Mon Oct 20, 2008 10:07 pm
Thanx, I didn`t know that (just tried it)
http://www.purebasic.com
http://forums.purebasic.com/english/
Code: Select all
;{ LinkedList Kundendaten
If CoCreateInstance_(?CLSID_AutoComplete, 0, 1, ?IID_IAutoComplete2, @AutoComplete.IAutoComplete2) = #S_OK
AutoComplete\SetOptions(#ACO_AUTOSUGGEST|#ACO_USETAB)
Enum.IEnumString = New_EnumString(kArray(), anzahlelemente)
AutoComplete\Init(GadgetID(#kunde), Enum, 0, 0)
EndIf
;}
;{ Map Artikel
If CoCreateInstance_(?CLSID_AutoComplete, 0, 1, ?IID_IAutoComplete2, @AutoComplete.IAutoComplete2) = #S_OK
AutoComplete\SetOptions(#ACO_AUTOSUGGEST|#ACO_USETAB)
Enum.IEnumString = New_EnumString(ArtikelArray(), anzahlArtikel)
AutoComplete\Init(GadgetID(#String_Artikel), Enum, 0, 0)
EndIf
;}
;
;
;Code
;
Enum\Release()
AutoComplete\Release()
CoUninitialize_()
Code: Select all
;{ Map Artikel
Enum2.IEnumString = New_EnumString(ArtikelArray(), anzahlArtikel)
AutoComplete\Init(GadgetID(#String_Artikel), Enum2, 0, 0)
;}
...but it doesn`t work on Windows 7. Has anyone an idea why? thx;{ Map Artikel
Enum2.IEnumString = New_EnumString(ArtikelArray(), anzahlArtikel)
AutoComplete\Init(GadgetID(#String_Artikel), Enum2, 0, 0)
;}
'cause I can't seem to get it right.srod wrote:Why not just release the objects and then recreate them etc? Worked okay here.
Code: Select all
XIncludeFile "IEnumString.pbi"
#ACO_NONE = 0 ; No autocompletion.
#ACO_AUTOSUGGEST = $1 ; Enable the autosuggest drop-down list.
#ACO_AUTOAPPEND = $2 ; Enable autoappend.
#ACO_SEARCH = $4 ; Add a search item to the dropdown list of completed strings. If this is item is selected, you should launch a search engine to assist the user.
#ACO_FILTERPREFIXES = $8 ; Don't match common prefixes, such as "www.", "http://", and so on.
#ACO_USETAB = $10 ; Use the TAB key to select an item from the drop-down list. This flag is disabled by default.
#ACO_UPDOWNKEYDROPSLIST = $20 ; Use the UP ARROW and DOWN ARROW keys to display the autosuggest drop-down list.
#ACO_RTLREADING = $40 ; If ACO_RTLREADING is set, the text is read in the opposite direction from the text in the parent window.
; -----------------------------------------------
#Window_0 = 0
#String_0 = 0
#string_1 = 1
Dim Strings.s(100)
Strings(0) = "Else"
Strings(1) = "ElseIf"
Strings(2) = "EnableDebugger"
Strings(3) = "EnableExplicit"
Strings(4) = "End"
Strings(5) = "EndDataSection"
Strings(6) = "EndEnumeration"
Strings(7) = "EndIf"
Strings(8) = "EndImport"
Strings(9) = "EndInterface"
Strings(10) = "EndMacro"
Strings(11) = "EndProcedure"
Strings(12) = "EndSelect"
Strings(13) = "EndStructure"
Strings(14) = "EndStructureUnion"
Strings(15) = "EndWith"
Strings(16) = "Enumeration"
Global laststring = 16
; Initialize the COM environment
CoInitialize_(0)
If OpenWindow(#Window_0, 323, 219, 600, 300, "AutoComplete", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
StringGadget(#String_0, 40, 40, 320, 20, "")
StringGadget(#String_1, 40, 90, 320, 20, "")
SetActiveGadget(#String_0)
; This creates the autocomplete object:
;
If CoCreateInstance_(?CLSID_AutoComplete, 0, 1, ?IID_IAutoComplete2, @AutoComplete.IAutoComplete2) = #S_OK
; Lets change the options for autocomplete a bit:
; See the constant definitions above for the available options.
; There is a dropdown or in-place suggestion mode.
;
AutoComplete\SetOptions(#ACO_AUTOSUGGEST|#ACO_USETAB)
; This creates the IEnumString interface from our string array:
;
Enum.IEnumString = New_EnumString(Strings(), 101)
; This sets the autocomplet with our Enum object.
; If you want more info on the last 2 parameters, read here:
; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/iautocomplete/Init.asp
; Note that these must be unicode strings if present!
;
; This also works for Comboboxes, you just need to get the handle to the edit
; control that is contained inside with the GetComboBoxInfo_() function.
;
AutoComplete\Init(GadgetID(#String_0), Enum, 0, 0)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case #string_0
If EventType() = #PB_EventType_LostFocus
; Add gadget contents to the array
tmp$ = GetGadgetText(#string_0)
FreeGadget(#string_0)
laststring + 1
Strings(laststring) = tmp$
Enum\Release()
AutoComplete\Release()
StringGadget(#String_0, 40, 40, 320, 20, tmp$)
CoCreateInstance_(?CLSID_AutoComplete, 0, 1, ?IID_IAutoComplete2, @AutoComplete.IAutoComplete2)
AutoComplete\SetOptions(#ACO_AUTOSUGGEST|#ACO_USETAB)
Enum.IEnumString = New_EnumString(Strings(), 101)
AutoComplete\Init(GadgetID(#String_0), Enum, 0, 0)
EndIf
EndSelect
EndSelect
Until EventID= #PB_Event_CloseWindow
CloseWindow(#window_0)
; Release our own references to the objects to avoid a memory leak
;
Enum\Release()
AutoComplete\Release()
EndIf
EndIf
CoUninitialize_()
DataSection
CLSID_AutoComplete: ; {00BB2763-6A77-11D0-A535-00C04FD7D062}
Data.l $00BB2763
Data.w $6A77, $11D0
Data.b $A5, $35, $00, $C0, $4F, $D7, $D0, $62
IID_IAutoComplete: ; {00BB2762-6A77-11D0-A535-00C04FD7D062}
Data.l $00BB2762
Data.w $6A77, $11D0
Data.b $A5, $35, $00, $C0, $4F, $D7, $D0, $62
IID_IAutoComplete2: ; {EAC04BC0-3791-11D2-BB95-0060977B464C}
Data.l $EAC04BC0
Data.w $3791, $11D2
Data.b $BB, $95, $00, $60, $97, $7B, $46, $4C
EndDataSection
I can't reproduce that. I killed the program many times from the debugger and from Taskmanager but it always works fine next time. I'm running win7 x86 here.add "win" as a new autocomplete entry (via the tab). End the program. restart it and see what entering "w" does. For me, it crashes every time
Me too.netmaestro wrote: I'm running win7 x86 here.