tlbinf32.dll will extract typelib info from ActiveX/COM, including vtable member offset for dual interface.
ax02.rc
Code: Select all
#define IDD_DLG1 1000
#define AX1 1001
#define btNxtDay 1004
#define btNxtMonth 1005
#define btNxtYear 1006
#define btPrvYear 1007
#define btPrvMonth 1008
#define btPrvDay 1009
#define btClrGrid 1002
#define btClrDay 1003
#define btClrBack 1010
#define btAbout 1011
#define IDC_STC1 1012
IDD_DLG1 DIALOGEX 6,6,189,172
CAPTION "Ax02-Ax Control vTable Call"
FONT 8,"MS Sans Serif",0,0,0
STYLE 0x10CF0800
BEGIN
CONTROL "MSCAL.Calendar.7",AX1,"AtlAxWin71",0x50000000,0,0,188,131
CONTROL "Next Day",btNxtDay,"Button",0x50010000,0,134,42,11
CONTROL "Next Month",btNxtMonth,"Button",0x50010000,44,134,44,11
CONTROL "Next Year",btNxtYear,"Button",0x50010000,90,134,42,11
CONTROL "Prev Year",btPrvYear,"Button",0x50010000,90,147,42,11
CONTROL "Prev Month",btPrvMonth,"Button",0x50010000,44,147,44,11
CONTROL "Prev Day",btPrvDay,"Button",0x50010000,0,147,42,11
CONTROL "Grid Color",btClrGrid,"Button",0x50010000,90,160,42,11
CONTROL "Day Color",btClrDay,"Button",0x50010000,44,160,44,11
CONTROL "Back Color",btClrBack,"Button",0x50010000,0,160,42,11
CONTROL "About",btAbout,"Button",0x50010000,136,160,50,11
CONTROL "Calendar Demo with AxSupport",IDC_STC1,"Static",0x50001001,134,134,54,22
END
Code: Select all
'================================================
'Code generated by RC2CODE - RC To Code Generator
'Very first stage project, use at your own risk
'Contact Loe at webhasta[at]telkom.net
'================================================
'============================================================
'Tutorial 2 Using ActiveX Control with AxSupport vTable Call
'============================================================
#Include once "windows.bi"
'#include once "C:\FbEdit\Projects\Ax01\Ax01.bi" 'exported names of resource file
'=========================================================================
'Include file of control
'=========================================================================
#Include once"win/ocidl.bi"
#Include Once "mscal.bi"
'=========================================================================
'Defined constant in .rc file.
'Please delete this section if you have included exported names of resource.
'=========================================================================
#define IDD_DLG1 1000
#define AX1 1001
#define btNxtDay 1004
#define btNxtMonth 1005
#define btNxtYear 1006
#define btPrvYear 1007
#define btPrvMonth 1008
#define btPrvDay 1009
#define btClrGrid 1002
#define btClrDay 1003
#define btClrBack 1010
#define btAbout 1011
#define IDC_STC1 1012
'=========================================================================
'Global variable
'=========================================================================
dim shared as iCalendar Cal 'set Cal as Calendar object
Dim Shared As lpunknown punk
dim shared AxScode as scode
'=========================================================================
'Dialog callback procedure declaration
'=========================================================================
declare Function IDD_DLG1_DlgProc(byval hWin as HWND, byval uMsg as UINT, byval wParam as WPARAM, byval lParam as LPARAM) as integer
declare Function IDD_DLG1_Init(Byval hWin as hwnd,Byval wParam as wParam,Byval lParam as lParam)as Integer
declare Function IDD_DLG1_OnSize(Byval hWin as hwnd,Byval lState as long,Byval cx as long,Byval cy as long)as Integer
declare Function IDD_DLG1_OnClose(Byval hWin as hwnd)as Integer
declare Function IDD_DLG1_OnDestroy(Byval hWin as hwnd)as Integer
declare Function IDD_DLG1_OnNotify(Byval hWin as hwnd,Byval lCtlID as long,Byval lpNMHDR as NMHDR ptr,Byref lresult as long)as Integer
declare Function IDD_DLG1_OnTimer(Byval hWin as hwnd,Byval wTimerID as word)as Integer
declare function IDD_DLG1_btNxtDay_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btNxtMonth_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btNxtYear_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btPrvYear_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btPrvMonth_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btPrvDay_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btClrGrid_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btClrDay_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btClrBack_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
declare function IDD_DLG1_btAbout_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as Long
Declare FUNCTION AtlAxWinInit LIB "ATL71.DLL" ALIAS "AtlAxWinInit" () AS LONG
DECLARE FUNCTION AtlAxGetControl LIB "ATL71.DLL" ALIAS "AtlAxGetControl" (BYVAL hWnd AS hwnd, Byval pp AS uint ptr) AS uinteger
DECLARE FUNCTION AtlAxAttachControl LIB "ATL71.DLL" ALIAS "AtlAxAttachControl" (BYVAL pControl AS uint ptr, BYVAL hWnd AS hwnd, ByVal ppUnkContainer AS uint ptr) AS uinteger
DECLARE FUNCTION AtlAxCreateControlLic LIB "ATL71.DLL" ALIAS "AtlAxCreateControlLic" (BYVAL lpszName AS bstr, BYVAL hParent AS uinteger, BYVAL pStream AS uinteger, BYval ppUnkContainer AS uint ptr, BYVAL bstrLic AS bstr) AS uinteger
Function AxInit(ByVal host As Integer=false)As Integer
AxScode=CoInitialize(null)
If host Then AxScode=atlaxwininit
Function=AxScode
end Function
' ****************************************************************************************
' Retrieves the interface of the ActiveX control given the handle of its ATL container
' ****************************************************************************************
SUB AtlAxGetDispatch (BYVAL hWndControl AS hwnd, BYREF ppvObj AS lpvoid)
Dim ppUnk AS lpunknown
dim ppDispatch as pvoid
'dim IID_IDispatch as IID
' Get the IUnknown of the OCX hosted in the control
AxScode = AtlAxGetControl(hWndControl, @ppUnk)
IF AxScode<>0 OR ppUnk=0 THEN EXIT SUB
' Query for the existence of the dispatch interface
'IIDFromString("{00020400-0000-0000-c000-000000000046}",@IID_IDispatch)
AxScode=IUnknown_QueryInterface(ppUnk, @IID_IDispatch, @ppDispatch)
' If not found, return the IUnknown of the control
IF AxScode<>0 OR ppDispatch=0 THEN
ppvObj = ppUnk
EXIT SUB
END IF
' Release the IUnknown of the control
IUnknown_Release(ppUnk)
' Return the retrieved address
ppvObj = ppDispatch
End SUB
Function IDD_DLG1_Init(Byval hWin as hwnd,Byval wParam as wParam,Byval lParam as lParam)as Integer
AtlaxgetDispatch GetDlgItem(hwin,AX1),cal 'get Calendar control address
End Function
Function IDD_DLG1_OnSize(ByVal hWin as hwnd,Byval lState as long,Byval cx as long,Byval cy as long)as Integer
End Function
Function IDD_DLG1_OnClose(Byval hWin As hwnd)as Integer
cal->lpvtbl->Release(cal) 'release calendar object
couninitialize
End Function
Function IDD_DLG1_OnDestroy(Byval hWin as hwnd)as Integer
End Function
Function IDD_DLG1_OnNotify(Byval hWin as hwnd,Byval lCtlID as long,Byval lpNMHDR as NMHDR ptr,Byref lresult as long)as Integer
End Function
Function IDD_DLG1_OnTimer(Byval hWin as hwnd,Byval wTimerID as word)as Integer
End Function
function IDD_DLG1_btNxtDay_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->NextDay(cal) 'call NextDay method
end function
function IDD_DLG1_btNxtMonth_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->NextMonth(cal) 'call NextMonth method
end function
function IDD_DLG1_btNxtYear_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->NextYear(cal) 'call nextyear method
end function
function IDD_DLG1_btPrvYear_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->PreviousYear(cal) 'call PreviousYear method
end function
function IDD_DLG1_btPrvMonth_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->PreviousMonth(cal) 'call PreviousMonth method
end function
function IDD_DLG1_btPrvDay_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->PreviousDay(cal) 'call PreviousDay method
end function
function IDD_DLG1_btClrGrid_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as Long
cal->lpvtbl->putGridFontColor(cal,bgr(Rnd*255,Rnd*255,Rnd*255)) 'put gridcolor property
end function
function IDD_DLG1_btClrDay_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->putDayFontColor(cal,bgr(Rnd*255,Rnd*255,Rnd*255)) 'put daycolor property
end function
Function IDD_DLG1_btClrBack_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->putBackColor(cal,bgr(Rnd*255,Rnd*255,Rnd*255)) 'put backcolor property
end function
function IDD_DLG1_btAbout_Clicked(Byval hWin as hwnd,Byval hCtrl as hwnd)as long
cal->lpvtbl->AboutBox(cal)
end function
'=========================================================================
'Initial code of control
'=========================================================================
axinit(true) 'initialize axsupport with atl71 hosted ActiveX control
DialogBoxParam(GetModuleHandle(NULL), Cast(zstring ptr,IDD_DLG1), NULL, @IDD_DLG1_DlgProc, NULL)
ExitProcess(0)
end
'=========================================================================
'Dialog callback procedure
'=========================================================================
Function IDD_DLG1_DlgProc(byval hWin as HWND, byval uMsg as UINT, byval wParam as WPARAM, byval lParam as LPARAM) as integer
dim as long id,event,lresult
dim lpNMHDR as NMHDR ptr
select case uMsg
case WM_INITDIALOG
if IDD_DLG1_Init(hWin,wparam,lparam) then
function=false
exit function
endif
case WM_COMMAND
id=loword(wParam)
event=hiword(wParam)
if id=btNxtDay then
if event = BN_CLICKED THEN
if IDD_DLG1_btNxtDay_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btNxtMonth then
if event = BN_CLICKED THEN
if IDD_DLG1_btNxtMonth_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btNxtYear then
if event = BN_CLICKED THEN
if IDD_DLG1_btNxtYear_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btPrvYear then
if event = BN_CLICKED THEN
if IDD_DLG1_btPrvYear_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btPrvMonth then
if event = BN_CLICKED THEN
if IDD_DLG1_btPrvMonth_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btPrvDay then
if event = BN_CLICKED THEN
if IDD_DLG1_btPrvDay_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btClrGrid then
if event = BN_CLICKED THEN
if IDD_DLG1_btClrGrid_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btClrDay then
if event = BN_CLICKED THEN
if IDD_DLG1_btClrDay_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btClrBack then
if event = BN_CLICKED THEN
if IDD_DLG1_btClrBack_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
if id=btAbout then
if event = BN_CLICKED THEN
if IDD_DLG1_btAbout_Clicked(hWin,lparam) then
function=false
exit function
endif
endif
end if
case WM_SIZE
if IDD_DLG1_OnSize(hWin,wparam,loword(lparam),hiword(lparam)) then
function=false
exit function
endif
case WM_NOTIFY
lpNMHDR=lparam
id=lpnmhdr->idfrom
event=lpnmhdr->code
if IDD_DLG1_OnNotify(hWin,wparam,lparam,lresult) then
function=lresult
exit function
endif
case WM_TIMER
if IDD_DLG1_OnTimer(hWin,wparam) then
function=false
exit function
endif
case WM_CLOSE
if IDD_DLG1_OnClose(hWin) then
function=false
exit function
endif
EndDialog(hWin,0)
case WM_DESTROY
IDD_DLG1_OnDestroy(hWin)
function=false
exit function
case else
return FALSE
end select
return TRUE
End Function
this is my 1st attempt to build vtable UDT
mscal.bi
Code: Select all
'----------------------------------------------------------------------------------------------------
' vTable Call - Microsoft Calendar Control 11.0
' TypeLib CLSID="{8E27C92E-1264-101C-8A2F-040224009C02}"
'----------------------------------------------------------------------------------------------------
' --------------------------------------------------------------------------------------------
' Runtime license key
' --------------------------------------------------------------------------------------------
Const LICKEY_MSCALCalendar7 = ""
' --------------------------------------------------------------------------------------------
' ProgIds
' --------------------------------------------------------------------------------------------
Const PROGID_MSCALCalendar7 = "MSCAL.Calendar.7"
'----------------------------------------------------------------------------------------------------
'Interface ICalendar
'GUID = {8E27C92C-1264-101C-8A2F-040224009C02}
'----------------------------------------------------------------------------------------------------
Type ICalendarVtbl
getBackColor As Function (Byval pThis As Any ptr,Byref pclrBackColor As Uinteger) As hResult
putBackColor As Function (Byval pThis As Any ptr,Byval pclrBackColor As Uinteger) As hResult
getDay As Function (Byval pThis As Any ptr,Byref pnDay As Short) As hResult
putDay As Function (Byval pThis As Any ptr,Byval pnDay As Short) As hResult
getDayFont As Function (Byval pThis As Any ptr,Byref ppfontDayFont As lpunknown /'Font dispinterface'/) As hResult
putDayFont As Function (Byval pThis As Any ptr,Byval ppfontDayFont As lpunknown /'Font dispinterface'/) As hResult
getDayFontColor As Function (Byval pThis As Any ptr,Byref pclrDayFontColor As Uinteger) As hResult
putDayFontColor As Function (Byval pThis As Any ptr,Byval pclrDayFontColor As Uinteger) As hResult
getDayLength As Function (Byval pThis As Any ptr,Byref pnDayLength As Short) As hResult
putDayLength As Function (Byval pThis As Any Ptr,Byval pnDayLength As Short) As hResult
getFirstDay As Function (Byval pThis As Any ptr,Byref pnFirstDay As Short) As hResult
putFirstDay As Function (Byval pThis As Any ptr,Byval pnFirstDay As Short) As hResult
getGridCellEffect As Function (Byval pThis As Any ptr,Byref plGridCellEffect As Integer) As hResult
putGridCellEffect As Function (Byval pThis As Any ptr,Byval plGridCellEffect As Integer) As hResult
getGridFont As Function (Byval pThis As Any ptr,Byref ppfontGridFont As lpunknown /'Font dispinterface'/) As hResult
putGridFont As Function (Byval pThis As Any ptr,Byval ppfontGridFont As lpunknown /'Font dispinterface'/) As hResult
getGridFontColor As Function (Byval pThis As Any ptr,Byref pclrGridFontColor As Uinteger) As hResult
putGridFontColor As Function (Byval pThis As Any ptr,Byval pclrGridFontColor As Uinteger) As hResult
getGridLinesColor As Function (Byval pThis As Any ptr,Byref pclrGridLinesColor As Uinteger) As hResult
putGridLinesColor As Function (Byval pThis As Any ptr,Byval pclrGridLinesColor As Uinteger) As hResult
getMonth As Function (Byval pThis As Any ptr,Byref pnMonth As Short) As hResult
putMonth As Function (Byval pThis As Any ptr,Byval pnMonth As Short) As hResult
getMonthLength As Function (Byval pThis As Any ptr,Byref pnMonthLength As Short) As hResult
putMonthLength As Function (Byval pThis As Any ptr,Byval pnMonthLength As Short) As hResult
getShowDateSelectors As Function (Byval pThis As Any ptr,Byref pfShowDateSelectors As Boolean) As hResult
putShowDateSelectors As Function (Byval pThis As Any ptr,Byval pfShowDateSelectors As Boolean) As hResult
getShowDays As Function (Byval pThis As Any ptr,Byref pfShowDays As Boolean) As hResult
putShowDays As Function (Byval pThis As Any ptr,Byval pfShowDays As Boolean) As hResult
getShowHorizontalGrid As Function (Byval pThis As Any ptr,Byref pfShowHorizontalGrid As Boolean) As hResult
putShowHorizontalGrid As Function (Byval pThis As Any ptr,Byval pfShowHorizontalGrid As Boolean) As hResult
getShowTitle As Function (Byval pThis As Any ptr,Byref pfShowTitle As Boolean) As hResult
putShowTitle As Function (Byval pThis As Any ptr,Byval pfShowTitle As Boolean) As hResult
getShowVerticalGrid As Function (Byval pThis As Any ptr,Byref pfShowVerticalGrid As Boolean) As hResult
putShowVerticalGrid As Function (Byval pThis As Any ptr,Byval pfShowVerticalGrid As Boolean) As hResult
getTitleFont As Function (Byval pThis As Any ptr,Byref ppfontTitleFont As lpunknown /'Font dispinterface'/) As hResult
putTitleFont As Function (Byval pThis As Any ptr,Byval ppfontTitleFont As lpunknown /'Font dispinterface'/) As hResult
getTitleFontColor As Function (Byval pThis As Any ptr,Byref pclrTitleFontColor As Uinteger) As hResult
putTitleFontColor As Function (Byval pThis As Any ptr,Byval pclrTitleFontColor As Uinteger) As hResult
getValue As Function (Byval pThis As Any ptr,Byref pvarValue As Variant) As hResult
putValue As Function (Byval pThis As Any ptr,Byval pvarValue As Variant) As hResult
get_Value As Function (Byval pThis As Any ptr,Byref pvarValue As Variant) As hResult
put_Value As Function (Byval pThis As Any ptr,Byval pvarValue As Variant) As hResult
getValueIsNull As Function (Byval pThis As Any ptr,Byref pfValueIsNull As Boolean) As hResult
putValueIsNull As Function (Byval pThis As Any ptr,Byval pfValueIsNull As Boolean) As hResult
getYear As Function (Byval pThis As Any ptr,Byref pnYear As Short) As hResult
putYear As Function (Byval pThis As Any ptr,Byval pnYear As Short) As hResult
NextDay As Function (Byval pThis As Any ptr) As hResult
NextMonth As Function (Byval pThis As Any ptr) As hResult
NextWeek As Function (Byval pThis As Any ptr) As hResult
NextYear As Function (Byval pThis As Any ptr) As hResult
PreviousDay As Function (Byval pThis As Any ptr) As hResult
PreviousMonth As Function (Byval pThis As Any ptr) As hResult
PreviousWeek As Function (Byval pThis As Any ptr) As hResult
PreviousYear As Function (Byval pThis As Any ptr) As hResult
Refresh As Function (Byval pThis As Any ptr) As hResult
Today As Function (Byval pThis As Any ptr) As hResult
AboutBox As Function (Byval pThis As Any ptr) As hResult
setDayFont As Function (Byval pThis As Any ptr,Byval ppfontDayFont As lpunknown /'Font dispinterface'/) As hResult
setGridFont As Function (Byval pThis As Any ptr,Byval ppfontGridFont As lpunknown /'Font dispinterface'/) As hResult
setTitleFont As Function (Byval pThis As Any ptr,Byval ppfontTitleFont As lpunknown /'Font dispinterface'/) As hResult
End Type
Type ICalendar_
lpVtbl As ICalendarVtbl ptr
End Type
Type ICalendar As ICalendar_ ptr
mscal.bi
Code: Select all
'----------------------------------------------------------------------------------------------------
' vTable Call - Microsoft Calendar Control 11.0
' TypeLib CLSID="{8E27C92E-1264-101C-8A2F-040224009C02}"
'----------------------------------------------------------------------------------------------------
' --------------------------------------------------------------------------------------------
' Runtime license key
' --------------------------------------------------------------------------------------------
Const LICKEY_MSCALCalendar7 = ""
' --------------------------------------------------------------------------------------------
' ProgIds
' --------------------------------------------------------------------------------------------
Const PROGID_MSCALCalendar7 = "MSCAL.Calendar.7"
'----------------------------------------------------------------------------------------------------
'Interface ICalendar
'GUID = {8E27C92C-1264-101C-8A2F-040224009C02}
'----------------------------------------------------------------------------------------------------
Type ICalendarVtbl
QueryInterface As Function (Byval pThis As Any ptr,Byref riid As GUID,Byref ppvObj As Dword) As hResult
AddRef As Function (Byval pThis As Any ptr) As hResult
Release As Function (Byval pThis As Any ptr) As hResult
Offset28(15) As Byte
getBackColor As Function (Byval pThis As Any ptr,Byref pclrBackColor As Uinteger) As hResult
putBackColor As Function (Byval pThis As Any ptr,Byval pclrBackColor As Uinteger) As hResult
getDay As Function (Byval pThis As Any ptr,Byref pnDay As Short) As hResult
putDay As Function (Byval pThis As Any ptr,Byval pnDay As Short) As hResult
getDayFont As Function (Byval pThis As Any ptr,Byref ppfontDayFont As lpunknown /'Font dispinterface'/) As hResult
putDayFont As Function (Byval pThis As Any ptr,Byval ppfontDayFont As lpunknown /'Font dispinterface'/) As hResult
getDayFontColor As Function (Byval pThis As Any ptr,Byref pclrDayFontColor As Uinteger) As hResult
putDayFontColor As Function (Byval pThis As Any ptr,Byval pclrDayFontColor As Uinteger) As hResult
getDayLength As Function (Byval pThis As Any ptr,Byref pnDayLength As Short) As hResult
putDayLength As Function (Byval pThis As Any Ptr,Byval pnDayLength As Short) As hResult
getFirstDay As Function (Byval pThis As Any ptr,Byref pnFirstDay As Short) As hResult
putFirstDay As Function (Byval pThis As Any ptr,Byval pnFirstDay As Short) As hResult
getGridCellEffect As Function (Byval pThis As Any ptr,Byref plGridCellEffect As Integer) As hResult
putGridCellEffect As Function (Byval pThis As Any ptr,Byval plGridCellEffect As Integer) As hResult
getGridFont As Function (Byval pThis As Any ptr,Byref ppfontGridFont As lpunknown /'Font dispinterface'/) As hResult
putGridFont As Function (Byval pThis As Any ptr,Byval ppfontGridFont As lpunknown /'Font dispinterface'/) As hResult
getGridFontColor As Function (Byval pThis As Any ptr,Byref pclrGridFontColor As Uinteger) As hResult
putGridFontColor As Function (Byval pThis As Any ptr,Byval pclrGridFontColor As Uinteger) As hResult
getGridLinesColor As Function (Byval pThis As Any ptr,Byref pclrGridLinesColor As Uinteger) As hResult
putGridLinesColor As Function (Byval pThis As Any ptr,Byval pclrGridLinesColor As Uinteger) As hResult
getMonth As Function (Byval pThis As Any ptr,Byref pnMonth As Short) As hResult
putMonth As Function (Byval pThis As Any ptr,Byval pnMonth As Short) As hResult
getMonthLength As Function (Byval pThis As Any ptr,Byref pnMonthLength As Short) As hResult
putMonthLength As Function (Byval pThis As Any ptr,Byval pnMonthLength As Short) As hResult
getShowDateSelectors As Function (Byval pThis As Any ptr,Byref pfShowDateSelectors As Boolean) As hResult
putShowDateSelectors As Function (Byval pThis As Any ptr,Byval pfShowDateSelectors As Boolean) As hResult
getShowDays As Function (Byval pThis As Any ptr,Byref pfShowDays As Boolean) As hResult
putShowDays As Function (Byval pThis As Any ptr,Byval pfShowDays As Boolean) As hResult
getShowHorizontalGrid As Function (Byval pThis As Any ptr,Byref pfShowHorizontalGrid As Boolean) As hResult
putShowHorizontalGrid As Function (Byval pThis As Any ptr,Byval pfShowHorizontalGrid As Boolean) As hResult
getShowTitle As Function (Byval pThis As Any ptr,Byref pfShowTitle As Boolean) As hResult
putShowTitle As Function (Byval pThis As Any ptr,Byval pfShowTitle As Boolean) As hResult
getShowVerticalGrid As Function (Byval pThis As Any ptr,Byref pfShowVerticalGrid As Boolean) As hResult
putShowVerticalGrid As Function (Byval pThis As Any ptr,Byval pfShowVerticalGrid As Boolean) As hResult
getTitleFont As Function (Byval pThis As Any ptr,Byref ppfontTitleFont As lpunknown /'Font dispinterface'/) As hResult
putTitleFont As Function (Byval pThis As Any ptr,Byval ppfontTitleFont As lpunknown /'Font dispinterface'/) As hResult
getTitleFontColor As Function (Byval pThis As Any ptr,Byref pclrTitleFontColor As Uinteger) As hResult
putTitleFontColor As Function (Byval pThis As Any ptr,Byval pclrTitleFontColor As Uinteger) As hResult
getValue As Function (Byval pThis As Any ptr,Byref pvarValue As Variant) As hResult
putValue As Function (Byval pThis As Any ptr,Byval pvarValue As Variant) As hResult
get_Value As Function (Byval pThis As Any ptr,Byref pvarValue As Variant) As hResult
put_Value As Function (Byval pThis As Any ptr,Byval pvarValue As Variant) As hResult
getValueIsNull As Function (Byval pThis As Any ptr,Byref pfValueIsNull As Boolean) As hResult
putValueIsNull As Function (Byval pThis As Any ptr,Byval pfValueIsNull As Boolean) As hResult
getYear As Function (Byval pThis As Any ptr,Byref pnYear As Short) As hResult
putYear As Function (Byval pThis As Any ptr,Byval pnYear As Short) As hResult
NextDay As Function (Byval pThis As Any ptr) As hResult
NextMonth As Function (Byval pThis As Any ptr) As hResult
NextWeek As Function (Byval pThis As Any ptr) As hResult
NextYear As Function (Byval pThis As Any ptr) As hResult
PreviousDay As Function (Byval pThis As Any ptr) As hResult
PreviousMonth As Function (Byval pThis As Any ptr) As hResult
PreviousWeek As Function (Byval pThis As Any ptr) As hResult
PreviousYear As Function (Byval pThis As Any ptr) As hResult
Refresh As Function (Byval pThis As Any ptr) As hResult
Today As Function (Byval pThis As Any ptr) As hResult
AboutBox As Function (Byval pThis As Any ptr) As hResult
setDayFont As Function (Byval pThis As Any ptr,Byval ppfontDayFont As lpunknown /'Font dispinterface'/) As hResult
setGridFont As Function (Byval pThis As Any ptr,Byval ppfontGridFont As lpunknown /'Font dispinterface'/) As hResult
setTitleFont As Function (Byval pThis As Any ptr,Byval ppfontTitleFont As lpunknown /'Font dispinterface'/) As hResult
End Type
Type ICalendar_
lpVtbl As ICalendarVtbl ptr
End Type
Type ICalendar As ICalendar_ ptr
if we look at the offset table, the first member offset is 28 (&h1C), that why when we call first member it it point to the wrong offset (0).
to resolve this problem, we must rearrange "location" of memeber to its correct offset.
if we take a look at 2nd UDT we'll see addition of 3 default member of vtable:
Code: Select all
QueryInterface As Function (Byval pThis As Any ptr,Byref riid As GUID,Byref ppvObj As Dword) As hResult 'offset 0
AddRef As Function (Byval pThis As Any ptr) As hResult 'offset 4
Release As Function (Byval pThis As Any ptr) As hResult 'offset 8
Code: Select all
Offset28(15) As Byte 'offset 12, gap 16 bytes
some of the ActiveX/COM have >16 bytes gap like ADO recordset20 have 260 bytes gap between first member and release member.
Code: Select all
'----------------------------------------------------------------------------------------------------
'Interface Recordset20
'GUID = {0000054F-0000-0010-8000-00AA006D2EA4}
'----------------------------------------------------------------------------------------------------
Type Recordset20Vtbl
QueryInterface As Function (Byval pThis As Any ptr,Byref riid As GUID,Byref ppvObj As Dword) As hResult
AddRef As Function (Byval pThis As Any ptr) As hResult
Release As Function (Byval pThis As Any ptr) As hResult
Offset272(259) As Byte
Cancel As Function (Byval pThis As Any ptr) As hResult
getDataSource As Function (Byval pThis As Any ptr,Byref ppunkDataSource As Dword /'VT_UNKNOWN'/) As hResult
setDataSource As Function (Byval pThis As Any ptr,Byval ppunkDataSource As Dword /'VT_UNKNOWN'/) As hResult
_xSave As Function (Byval pThis As Any ptr,Byval FileName As Bstr=0,Byval PersistFormat As PersistFormatEnum /'enum'/=0) As hResult
getActiveCommand As Function (Byval pThis As Any ptr,Byref ppCmd As Any ptr /'VT_DISPATCH'/) As hResult
putStayInSync As Function (Byval pThis As Any ptr,Byval pbStayInSync As Boolean) As hResult
getStayInSync As Function (Byval pThis As Any ptr,Byref pbStayInSync As Boolean) As hResult
GetString As Function (Byval pThis As Any ptr,Byval StringFormat As StringFormatEnum /'enum'/=2,Byval NumRows As Integer=-1,Byval ColumnDelimeter As Bstr=0,Byval RowDelimeter As Bstr=0,Byval NullExpr As Bstr=0,Byref pRetString As Bstr) As hResult
getDataMember As Function (Byval pThis As Any ptr,Byref pbstrDataMember As Bstr) As hResult
putDataMember As Function (Byval pThis As Any ptr,Byval pbstrDataMember As Bstr) As hResult
CompareBookmarks As Function (Byval pThis As Any ptr,Byval Bookmark1 As Variant,Byval Bookmark2 As Variant,Byref pCompare As CompareEnum /'enum'/) As hResult
Clone As Function (Byval pThis As Any ptr,Byval LockType As LockTypeEnum /'enum'/=-1,Byref ppvObject As _Recordset /'dispinterface'/) As hResult
Resync As Function (Byval pThis As Any ptr,Byval AffectRecords As AffectEnum /'enum'/=3,Byval ResyncValues As ResyncEnum /'enum'/=2) As hResult
End Type
Type Recordset20_
lpVtbl As Recordset20Vtbl ptr
End Type
Type Recordset20 As Recordset20_ ptr
Code: Select all
'----------------------------------------------------------------------------------------------------
'Interface _DBTurbo2DEngine
'GUID = {4789A64B-59DC-4314-97EB-E50E4287BF12}
'----------------------------------------------------------------------------------------------------
Type _DBTurbo2DEngineVtbl
QueryInterface As Function (Byval pThis As Any ptr,Byref riid As GUID,Byref ppvObj As Dword) As hResult
AddRef As Function (Byval pThis As Any ptr) As hResult
Release As Function (Byval pThis As Any ptr) As hResult
Offset28(15) As Byte
getDBMath As Function (Byval pThis As Any ptr,Byref DBMath As _DBMath /'dispinterface'/) As hResult
Offset36(3) As Byte
setDBMath As Function (Byval pThis As Any ptr,Byval DBMath As _DBMath /'dispinterface'/) As hResult
getDBTexture As Function (Byval pThis As Any ptr,Byref DBTexture As _DBTexture /'dispinterface'/) As hResult
Offset48(3) As Byte
setDBTexture As Function (Byval pThis As Any ptr,Byval DBTexture As _DBTexture /'dispinterface'/) As hResult
getDBOverlay As Function (Byval pThis As Any ptr,Byref DBOverlay As _DBOverlay /'dispinterface'/) As hResult
Offset60(3) As Byte
setDBOverlay As Function (Byval pThis As Any ptr,Byval DBOverlay As _DBOverlay /'dispinterface'/) As hResult
getDBFPS As Function (Byval pThis As Any ptr,Byref DBFPS As _DBFPS /'dispinterface'/) As hResult
Offset72(3) As Byte
setDBFPS As Function (Byval pThis As Any ptr,Byval DBFPS As _DBFPS /'dispinterface'/) As hResult
getDBText As Function (Byval pThis As Any ptr,Byref DBText As _DBText /'dispinterface'/) As hResult
Offset84(3) As Byte
setDBText As Function (Byval pThis As Any ptr,Byval DBText As _DBText /'dispinterface'/) As hResult
getDBMap As Function (Byval pThis As Any ptr,Byref DBMap As _DBMap /'dispinterface'/) As hResult
Offset96(3) As Byte
setDBMap As Function (Byval pThis As Any ptr,Byval DBMap As _DBMap /'dispinterface'/) As hResult
getDBSubMap As Function (Byval pThis As Any ptr,Byref DBSubMap As _DBSubMap /'dispinterface'/) As hResult
Offset108(3) As Byte
setDBSubMap As Function (Byval pThis As Any ptr,Byval DBSubMap As _DBSubMap /'dispinterface'/) As hResult
getDBSprite As Function (Byval pThis As Any ptr,Byref DBSprite As _DBSprite /'dispinterface'/) As hResult
Offset120(3) As Byte
setDBSprite As Function (Byval pThis As Any ptr,Byval DBSprite As _DBSprite /'dispinterface'/) As hResult
getDBAutoMove As Function (Byval pThis As Any ptr,Byref DBAutoMove As _DBAutoMove /'dispinterface'/) As hResult
Offset132(3) As Byte
setDBAutoMove As Function (Byval pThis As Any ptr,Byval DBAutoMove As _DBAutoMove /'dispinterface'/) As hResult
getDBKeyInput As Function (Byval pThis As Any ptr,Byref DBKeyInput As _DBKeyInput /'dispinterface'/) As hResult
Offset144(3) As Byte
setDBKeyInput As Function (Byval pThis As Any ptr,Byval DBKeyInput As _DBKeyInput /'dispinterface'/) As hResult
getDBJoyStick As Function (Byval pThis As Any ptr,Byref DBJoyStick As _DBJoyStick /'dispinterface'/) As hResult
Offset156(3) As Byte
setDBJoyStick As Function (Byval pThis As Any ptr,Byval DBJoyStick As _DBJoyStick /'dispinterface'/) As hResult
getDBMouse As Function (Byval pThis As Any ptr,Byref DBMouse As _DBMouse /'dispinterface'/) As hResult
Offset168(3) As Byte
setDBMouse As Function (Byval pThis As Any ptr,Byval DBMouse As _DBMouse /'dispinterface'/) As hResult
getDBMusic As Function (Byval pThis As Any ptr,Byref DBMusic As _DBMusic /'dispinterface'/) As hResult
Offset180(3) As Byte
setDBMusic As Function (Byval pThis As Any ptr,Byval DBMusic As _DBMusic /'dispinterface'/) As hResult
getDBSound As Function (Byval pThis As Any ptr,Byref DBSound As _DBSound /'dispinterface'/) As hResult
Offset192(3) As Byte
setDBSound As Function (Byval pThis As Any ptr,Byval DBSound As _DBSound /'dispinterface'/) As hResult
getDBMapData As Function (Byval pThis As Any ptr,Byref DBMapData As _DBMapData /'dispinterface'/) As hResult
Offset204(3) As Byte
setDBMapData As Function (Byval pThis As Any ptr,Byval DBMapData As _DBMapData /'dispinterface'/) As hResult
getDBCounter As Function (Byval pThis As Any ptr,Byref DBCounter As _DBCounter /'dispinterface'/) As hResult
Offset216(3) As Byte
setDBCounter As Function (Byval pThis As Any ptr,Byval DBCounter As _DBCounter /'dispinterface'/) As hResult
getDBResource As Function (Byval pThis As Any ptr,Byref DBResource As _DBResource /'dispinterface'/) As hResult
Offset228(3) As Byte
setDBResource As Function (Byval pThis As Any ptr,Byval DBResource As _DBResource /'dispinterface'/) As hResult
InitializeDisplay As Function (Byval pThis As Any ptr,Byref hwnd As Integer,Byref dWindowed As Boolean,Byref dWidth As Integer=320,Byref dHeight As Integer=240,Byref dAdapter As Integer=0,Byref DevType As CONST_D3DDEVTYPE /'enum'/=0) As hResult
SetTextureStage As Function (Byval pThis As Any ptr,Byref TType As CONST_D3DTEXTURESTAGESTATETYPE /'enum'/,Byref TState As Integer) As hResult
SetRenderState As Function (Byval pThis As Any ptr,Byref RType As CONST_D3DRENDERSTATETYPE /'enum'/,Byref Value As Integer) As hResult
SetUpViewPort As Function (Byval pThis As Any ptr,Byref X As Integer,Byref Y As Integer,Byref Width As Integer,Byref Height As Integer) As hResult
SetBackColorRed As Function (Byval pThis As Any ptr,Byref Value As Short) As hResult
SetBackColorGreen As Function (Byval pThis As Any ptr,Byref Value As Short) As hResult
SetBackColorBlue As Function (Byval pThis As Any ptr,Byref Value As Short) As hResult
GetBackColorRed As Function (Byval pThis As Any ptr,Byref As Short) As hResult
GetBackColorGreen As Function (Byval pThis As Any ptr,Byref As Short) As hResult
GetBackColorBlue As Function (Byval pThis As Any ptr,Byref As Short) As hResult
SetWindowedObject As Function (Byval pThis As Any ptr,Byref Form As Any ptr /'VT_DISPATCH'/) As hResult
SetUpMapView As Function (Byval pThis As Any ptr,Byref mLeft As Single,Byref mTop As Single,Byref mRight As Single,Byref mBottom As Single,Byref mClip As Single) As hResult
SetMaxLevel As Function (Byval pThis As Any ptr,Byref Value As Short) As hResult
GetMaxLevel As Function (Byval pThis As Any ptr,Byref As Short) As hResult
GetDisplayOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
GetSoundOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
GetMusicOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
GetKeyInputOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
GetMouseOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
GetJoyStickOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
GetFontOn As Function (Byval pThis As Any ptr,Byref As Boolean) As hResult
Render As Function (Byval pThis As Any ptr) As hResult
ClearScreen As Function (Byval pThis As Any ptr) As hResult
End Type
Type _DBTurbo2DEngine_
lpVtbl As _DBTurbo2DEngineVtbl ptr
End Type
Type _DBTurbo2DEngine As _DBTurbo2DEngine_ ptr
if someone interrested, I'll post code to extract vTable UDT from ActiveX/COM with no offset gap.