Restored from previous forum. Originally posted by Danilo.
The big Problem with OOP is only the init part.
There are the names COM, ActiveX, OLE, ATL and
for sure some more.
Many different names for the same goal.
"CallCOM()" is for calling a method in a COM
object, so it should work with all this
different things.
I looked at the Logitech SDK and i have seen
that i can use CallCOM() to call the Methods
in the Object. So its possible to display
the camera image, make a screenshot and much
more things.
The problem is "only" (LOL ) the init part.
I can figure out the things very often, when
i have C-Code. So i can translate it to PureBasic
and to Assembly (DirectX, COM).
C++ and VB hide all the (not easy) init stuff.
(thats a very good thing for the HighLevel coder,
but LowLevel coders cant get infos about it easily.)
Another problem in this case:
You need a camera to run the examples.
I cant start the compiled examples in the SDK,
because there is no camera attached to my PC.
From the SDK docs:
"However, instantiating an ATL COM object without
MFC is not quite so simple."
Logitech is right. They know what i think...
Here my little test.
MsgBox shows 0 every time, so it doesnt init
correctly. As long as this is 0 you cant use
CallCOM(). CallCOM() with 0 = crash.
Why does it not init correctly ?? Is it because
i dont have the camera connected and the driver
isnt installed correctly ??
I think thats the reason.
Cant write it without camera, but you´ll figure
it out yourself. Sorry.
Code: Select all
Declare InitializeVideo(hWnd)
Declare UnInitializeVideo()
#PrepareControl = 28
#ConnectCamera2 = 60
#put_EnablePreview = 60 + (47*4)
CoInitialize_(0)
If OpenLibrary(1,"ATL.DLL")
If CallFunction(1,"AtlAxWinInit")
beep_(1400,500)
;OpenLibrary(2,"VPortal2.dll")
;CallFunction(2,"DllRegisterServer")
hWnd = OpenWindow(1,10,10,640,500,#PB_Window_SYSTEMmenu,"No Camera Test :wink:")
InitializeVideo(hWnd)
MessageRequester("INFO",StrU(Camera,2),0)
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
;UnInitializeVideo()
CallFunction(1,"AtlAxWinTerm")
;CallFunction(2,"DllUnRegisterServer")
EndIf
CloseLibrary(1)
;CloseLibrary(2)
EndIf
CoUnInitialize_()
End
Procedure InitializeVideo(Parent)
Shared Camera
StringMem = AllocateMemory(1,1000,0)
;StringFromCLSID_(?CLSID_VideoPortal, StringMem) ; strGUIDVideoPortalActiveXControl
x = StringFromGUID2_(?CLSID_VideoPortal,StringMem,1000)
;StringMem = PeekL(*StringMem)
strGUIDVideoPortalActiveXControl.s = PeekS(StringMem)
;MessageRequester("INFO",strGUIDVideoPortalActiveXControl+Str(x),0)
;strGUIDVideoPortalActiveXControl.s = "{102225E5-EA25-11D3-886E-00105A154A4D}"
hWndCtl = CreateWindowEx_(0,"AtlAxWin", strGUIDVideoPortalActiveXControl,#WS_CHILD | #WS_VISIBLE | #WS_GROUP, 0, 0, 400, 400, Parent, 0, GetModuleHandle_(0),0)
CallFunction(1,"AtlAxGetControl",hWndCtl,@Camera)
;CallCOM(#PrepareControl,Camera,0,0,0,@Result)
;CallCOM(#ConnectCamera2,Camera,@Result)
;CallCOM(#put_EnablePreview,Camera,#TRUE)
EndProcedure
Procedure UnInitializeVideo()
EndProcedure
DataSection
CLSID_VideoPortal:
; CLSID_VideoPortal = {0x102225E5,0xEA25,0x11D3,{0x88,0x6E,0x00,0x10,0x5A,0x15,0x4A,0x4D}};
Data.l $102225E5
Data.w $EA25, $11D3
Data.b $88,$6E,$00,$10,$5A,$15,$4A,$4D
IID_IVideoPortal:
;IID_IVideoPortal = {0x102225E4,0xEA25,0x11D3,{0x88,0x6E,0x00,0x10,0x5A,0x15,0x4A,0x4D}};
Data.l $102225E4
Data.w $EA25,$11D3
Data.b $88,$6E,$00,$10,$5A,$15,$4A,$4D
strGUIDVideoPortal:
Data.w 123
; 1 0 2 2 2 5 E 5 - E A 2 5 - 1 1 D 3 - 8 8 6 E - 0 0 1 0 5 A 1 5 4 A 4 D
Data.w 49,48,50,50,50,53,69,53,45,69,65,50,53,45,49,49,68,51,45,56,56,54,69,45,48,48,49,48,53,65,49,53,52,65,52,68
Data.w 125, 0,0 ;{102225E5-EA25-11D3-886E-00105A154A4D}
EndDataSection
cya,
...Danilo
Edited by - Danilo on 07 June 2002 08:03:25