CWindow RC 21

Started by José Roca, September 09, 2016, 02:32:30 PM

Previous topic - Next topic

Marc Pons

may i insist in the extends IDispatchVtbl
TYPE IMonthViewVTbl extends IDispatchVtbl
   'QueryInterface AS FUNCTION (BYVAL this AS IMonthView PTR, BYVAL riid AS CONST IID CONST PTR, BYVAL ppvObj AS ANY PTR PTR) AS HRESULT
   'AddRef AS FUNCTION (BYVAL this AS IMonthView PTR) AS ULONG
   'Release AS FUNCTION (BYVAL this AS IMonthView PTR) AS ULONG
   'GetTypeInfoCount AS FUNCTION (BYVAL this AS IMonthView PTR, BYVAL pctinfo AS UINT PTR) AS HRESULT
   'GetTypeInfo AS FUNCTION (BYVAL this AS IMonthView PTR, BYVAL iTInfo AS UINT, BYVAL lcid AS LCID, BYVAL ppTInfo AS ITypeInfo PTR PTR) AS HRESULT
   'GetIDsOfNames AS FUNCTION (BYVAL this AS IMonthView PTR, BYVAL iTInfo AS UINT, BYVAL lcid AS LCID, BYVAL ppTInfo AS ITypeInfo PTR PTR) AS HRESULT
   'Invoke AS FUNCTION (BYVAL this AS IMonthView PTR, BYVAL dispIdMember AS DISPID, BYVAL riid AS CONST IID CONST PTR, BYVAL lcid AS LCID, BYVAL wFlags AS WORD, BYVAL pDispParams AS DISPPARAMS PTR, BYVAL pVarResult AS VARIANT PTR, BYVAL pExcepInfo AS EXCEPINFO PTR, BYVAL puArgErr AS UINT PTR) AS HRESULT
   get_Appearance AS FUNCTION (BYVAL pthis AS ANY PTR, BYVAL penumAppearances As AppearanceConstants Ptr) AS HRESULT
   put_Appearance AS FUNCTION (BYVAL pthis AS AS ANY PTR, BYVAL penumAppearances As AppearanceConstants ) AS HRESULT
   ...


chm help file info extract
Quote
Extends declares typename to be derived from base_typename. The derived user-defined type, typename, inherits fields and methods of the base_typename base type. typename objects may be used in place of base_typename objects. Fields and methods inherited from base_typename will be implicitly accessible like regular members of typename.
However, a regular member will shadow an inherited member if they have the same identifier. The Base (Member Access) keyword can be used to explicitly access members of the base type shadowed by local members.

User-defined types that extend another type will include the base type structure at their beginning,

for abstract/virtual methods the class must inherit from Object , but here we don't need to inherit from Object
just inherit from IDispatchVtbl is enougth because we don't use abstract/virtual way. but it can save 7 lines on each class

You can experience it with the sample file, i've sent to you directly ( olecon_test3  with 2 calendars...)

José Roca

It doesn't matter. We don't have to type them. Besides, I'm not going to use it. I prefer to use abstract methods.

José Roca

#47
Completed the code generation.

Current problems: Possible conflicts with interface names and FB keywords.

Some interface declarations, structures, etc. may need to me moved because it is a one-pass compiler.

José Roca

#48
Quote from: Marc Pons on September 17, 2016, 10:20:23 AM
QuoteOnly the default events interfaces can be detected, but not other additional events interfaces.

For example, ADO has two dispatch events interfaces, ConnectionEvents and RecordsetEvents, but also two VTable events interfaces, ConnectionEventsVt and RecordsetEventsVt. As VB6 can't use the VTable ones,

yes i can see them, to mark them as event interface in tlb, it could be a specific treatment
as most case the name is something....events...  , it could be possible to check the name to correctly affect them
but in most case if you already have the dispach ones is enougth.

Thanks also for the sample, how to fire the vtable events , i have to study it more deeply
( i must definively admit my knowledge on COM is  just at the surface )

In the CoClass for the ADO connection interface they have used


    coclass Connection {
        [default] interface _Connection;
        [default, source] dispinterface ConnectionEvents;
    };


If they had used


    coclass Connection {
        [default] interface _Connection;
        [default, source] dispinterface ConnectionEvents;
        [source] interface ConnectionEventsVt;
    };


Both will be retrievable. The dispatch one as the default to satisfy VB6 and other Automation tools.


Marc Pons

2 more ocx/dll i've tested  ( coming from autocad)

i noticed, failing finding parameters / interfaces

they work correctly with your tlb_501 and my axsuite3

Marc Pons

Quote> may I ask for an little evolution :
> when changing the "Ole Automation view" option, it could be nice, the tree info and the code  be regenerated

Done.

it's true but if opened a file from disk, if you change the option,
you loose the reference to the opened file and you regenerate the tree and code for the typelib pointed on the typelib list

José Roca

Yes, I don't like to mess the code using globals. I will see if I can do something about it.

José Roca

Quote from: Marc Pons on September 17, 2016, 12:46:18 PM
2 more ocx/dll i've tested  ( coming from autocad)

i noticed, failing finding parameters / interfaces

they work correctly with your tlb_501 and my axsuite3

There is missing code. I will revise it later, after I sleep a little.

José Roca

#53
TypeLib Browser 1.0, Beta 06

Lets see if this one works fine.

José Roca

#54
TypeLib Browser, Beta 07

> it's true but if opened a file from disk, if you change the option, you loose the reference to the opened file and you regenerate the tree and code for the typelib pointed on the typelib list

With this version, when you load a type library from disk, it is added temporalily to the ListView, allowing to change views.

I also have implemented the save code option.

Marc Pons

#55
in beta 7

in tlb_100.bas line 152 missing  & ")" at the end of line

DIM wszDesc AS WSTRING * MAX_PATH = pParseLib->m_LibHelpString & " (Ver" & WSTR(pParseLib->m_LibMajorVersion) & "." & WSTR(pParseLib->m_LibMinorVersion)& ")"

in tlb_parselib.inc
on "#defines ...
lines 2023;2024;2025 & 2164;2165;2166  missing at the end of line & chr(13,10)


for tlb_100.bas , i'm proposing

            ' // Save generated code to disk
            CASE IDM_SAVE
               DIM wszFile AS WSTRING * 260 = "*.BI"' "*.INC"
               DIM wszInitialDir AS STRING * 260 = CURDIR
'DIM wszFilter AS WSTRING * 260 = "FB code files (*.BAS,*.INC,*.BI)|*.BAS,*.INC,*.BI|" & "Text files (*.TXT)|*.TXT|" & "All Files (*.*)|*.*|"
               DIM wszFilter AS WSTRING * 260 = "FB code files (*.BI,*.INC,*.BAS)|*.BI,*.INC,*.BAS|" & "Text files (*.TXT)|*.TXT|" & "All Files (*.*)|*.*|"
               DIM dwFlags AS DWORD = OFN_EXPLORER OR OFN_FILEMUSTEXIST OR OFN_HIDEREADONLY OR OFN_OVERWRITEPROMPT
               DIM cwsFile AS CWSTR = AfxSaveFileDialog(hwnd, "", wszFile, wszInitialDir, wszFilter, "BI", @dwFlags) ' INC


in that case is more a .bi file and if the user give the name without extension the bi will be default

code generation issue
using the AdDynHelp1.ocx  (see on the previous rar )
still missing code interface  on both views ,
the tree view shows the interface but the normally 2 methods have the same offest 0 in both views


José Roca

Quote
code generation issue
using the AdDynHelp1.ocx  (see on the previous rar )
still missing code interface  on both views ,
the tree view shows the interface but the normally 2 methods have the same offest 0 in both views

There is nothing to generate. It is a dispatch only interface and can only be called using Invoke.

José Roca

Made an small change in the GetParameters function of TLB_ParseLib.inc.


            IF pex->vardefaultvalue.vt = VT_BSTR THEN
               TreeView_AddItem(hTreeView, hParamNameNode, NULL, "Default value = " & CHR(34) & **cbsDefaultValue & CHR(34))
'               cbstrFBSyntax += " = " & CHR(34) & **cbsDefaultValue & CHR(34)
            ELSE
               TreeView_AddItem(hTreeView, hParamNameNode, NULL, "Default value = " & cbsDefaultValue)
               ' // Some typelibs have unprintable default values, e.g. wbemdisp.tlb,
               ' // that has unprintable IDispatch PTR values.
               IF LEN(cbsDefaultValue) THEN cbstrFBSyntax += " = " & cbsDefaultValue
            END IF


José Roca

#58
In the GetFunctions method, the line


TreeView_AddItem(hTreeView, hSubNode2, NULL, "DispID = " & WSTR(@pFuncDesc->memid) & " [&h" & HEX(pFuncDesc->memid, 8) & "]")


should be


TreeView_AddItem(hTreeView, hSubNode2, NULL, "DispID = " & WSTR(pFuncDesc->memid) & " [&h" & HEX(pFuncDesc->memid, 8) & "]")




José Roca

#59
New class: CDispInvoke

Allows to call methods and properties of dispatch or dual interfaces through IDispatch.Invoke. Not tested extensively yet.

In the example of the MonthView calendar, we can use:


DIM pdisp AS CDispInvoke = pOleCon->OcxDispPtr
pdisp.Put("Year", 1985)
pdisp.Put("Month", 4)
pdisp.Put("Day", 21)
DIM year AS LONG = pdisp.Get("Year")
print year
DIM month AS LONG = pdisp.Get("Month")
print month
DIM day AS LONG = pdisp.Get(&h1)   ' // Using the dispid instead of the name
print day


I'm using overloaded methods with a different number of parameters because variadic functions don't work with the 64-bit compiler.

See update in reply #62.