Just to showcase what you're missing, likely:
Christofs struct init has this:
Code:
...
If .LoadLibrary() ;
and .CreateMemory() ;
and .Requery()
[highlight #FCE94F]Return .T.[/highlight]
Else
.Release()
[highlight #FCE94F]Return .F.[/highlight]
Endif
What changes if an init returns .t. vs .f.?
Well, the object get's created or not.
The return value is not passed back as return value of the createobject() call, it's telling VFP to either keep the object (when .t. is returned, which also is the default when you don't write an explicit RETURN .T. but just end the code of a method) or it's telling VFP to scrap the object.
So if you still didn't get what I was already mentioning above: If the struct class doesn't really create, loBitMapInfoHeader stays .f., that actually happened for me until I added convert.fll to the PATH.
Run this and see what happens:
Code:
On Error errortologfile()
? 'before local'
? 'loObject type is',Vartype(loObject)
Local loObject
? 'after local'
? 'loObject type is',Vartype(loObject)
loObject = CreateObject("myclass")
? 'after createobject'
? 'loObject type is',Vartype(loObject)
? 'loObject.property1 type is',Vartype(loObject.property1)
? 'loObject.property2 type is',Vartype(loObject.property2)
? 'end'
Modify File errors.log
Define Class myclass as custom
property1 = "string" && vartype "C"
property2 = 1 && vartype "N"
Procedure Init()
Return .F.
EndProc
EndDefine
Procedure errortologfile()
#Define CRLF Chr(13)+Chr(10)
StrToFile(Message()+CRLF,'errors.log',.t.)
Return
It's not showcasing what Christofs struct fails for in detail, you have to find out using the debugger and single stepping through the init, but this showcases how the vartype output can be blank, because loBitMapInfoHeader does not become an object as you expect and vartype can also error instead of returning "U" for undefined things.
Of course, when loBitMapInfoHeader does not become a struct object, everything else fails, especially since there will be no struct string nor pointer to send with the WM_CAP_SET_VIDEOFORMAT message.
Get the struct class to work, then you also don't get blank output from vartype() calls. It's not vartype returning blank, it's vartype erroring and error handler returning which results in blank lines. I make that obvious by establishing a simplistic (too simplistic indeed, for production) error handler, which just outputs MESSAGE() to a log file and finally show that log. You'll have three errors "loObject is not an object" and thus no vartype output, not even "U" for undefined.
You're working on wrong premises like vartype(anything) can't error, in the worst case it will only be "U" or perhaps "X". Untrue. And I already mentioned another error Vartype() might throw is "Alias ... not found". I've had both in my testing until I finally got the requirements correct for the struct class to work.
Chriss