Jump to content

Beginner in COM, require help


PhoenixXL
 Share

Recommended Posts

Hi, all

This is the code is have so far

with a IAutoComplete and IEnumString interface

#include <WinAPI.au3>

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")


Func _ErrFunc($oError)
ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
"err.windescription:" & @TAB & $oError.windescription & @CRLF & _
"err.description is: " & @TAB & $oError.description & @CRLF & _
"err.source is: " & @TAB & $oError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
"err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
"err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

Func _AutoComplete($hWnd)
Const $IID_IAutoComplete = '{00bb2762-6a77-11d0-a535-00c04fd7d062}';
Const $CLSID_AutoComplete = '{00BB2763-6A77-11D0-A535-00C04FD7D062}';
Const $IAC_vTable = 'Enable hresult(BOOL);Init hresult(HWND;OBJECT;WSTR;WSTR);'

;Create the IAutoComplete interface
Local $_oAutoComplete = ObjCreateInterface($CLSID_AutoComplete, $IID_IAutoComplete, $IAC_vTable)
If Not IsObj($_oAutoComplete) Then Return ConsoleWrite('ErrorCode:' & @error & @CR) <> 0

Const $IID_IEnumString = '{00000101-0000-0000-C000-000000000046}'
Const $CLSID_ACListISF = '{03C036F1-A186-11D0-824A-00AA005B4383}'
Const $IES_vTable = 'Clone HRESULT(OBJECT);Next HRESULT(ULONG;WSTR;ULONG);Reset HRESULT();Skip HRESULT(ULONG)'

;Create the IEnumString interface
Local $_oIEnumString = ObjCreateInterface($CLSID_ACListISF, $IID_IEnumString, $IES_vTable)
If Not IsObj($_oIEnumString) Then Return ConsoleWrite('ErrorCode:' & @error & @CR) <> 0

;Initialise the AutoCompletion
$_oAutoComplete.Init($hWnd, Ptr($_oIEnumString), 0, 0)

EndFunc   ;==>_AutoComplete

GUICreate('')
GUICtrlCreateInput('', 10, 10, 100, 60)
_AutoComplete(GUICtrlGetHandle(-1))
GUISetState()

While GUIGetMsg() <> -3
Sleep(10)
WEnd
upon running the code Im getting the error "Invalid Callee."

Please help me

Thanks for your time

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

There are several issues with your code.

You have to list methods in v-table order (yours is in alphabetical). Other thing is object type - it should be ptr. Object type describes IDispatch, not IUnknown. Lose Ptr() and pass $_oIEnumString directly. On top of that you should really go with IAutoComplete2 interface to be able to set options by calling SetOptions method.

IAutoComplete2 is:

'Init hresult(hwnd;ptr;wstr;wstr);Enable hresult(bool);SetOptions hresult(dword);GetOptions hresult(dword*)'

IID_IAutoComplete2 is {eac04bc0-3791-11d2-bb95-0060977b464c}

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Thanks for the help trancexx

the error is now rectified :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

where you can learn the correct order?

may have documentation, or what ever program...

Thx.

For example, open MSDN page for specific interface and see in what file the definition is, then google that file. Or if you have Visual Studio that file would be on your comp, open it and search for definition.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...