Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a class with only the properties & methods you specify?

Status
Not open for further replies.

wcglorioso

Programmer
Jul 23, 2003
30
0
0
PH
This post is in relation to the post entitled "How to resolve Error 1440 in VFP7? (No such thing in VB6 equivalent)" - thread184-741015

I think I found the cause of Error 1440. I believe it is due to uninitialized properties whose data type is undefined.

I have read all the properties and queried their types using the function TYPE() and found out that two properties are left undefined namely UserData and UserDataHeader (see partial type library entry below)

[propget, helpstring("property UserData")]
HRESULT _stdcall UserData(
[in] long index,
[out, retval] unsigned char* pVal);
[propput, helpstring("property UserData")]
HRESULT _stdcall UserData(
[in] long index,
[in] unsigned char pVal);
[propget, helpstring("property UserDataHeader")]
HRESULT _stdcall UserDataHeader(
[in] long index,
[out, retval] unsigned char* pVal);
[propput, helpstring("property UserDataHeader")]
HRESULT _stdcall UserDataHeader(
[in] long index,
[in] unsigned char pVal);

Hence the properties expects a data structure (filled byte by byte according to documentation)

I would like to create a class that has two properties only for this reason.

DEFINE CLASS usrdat AS XXXXX
index=0
pVal=0
ENDDEFINE

I would like it to inherit from a class XXXXX that is empty and assign the resulting object to properties UserData and UserDataHeader.

If there is a different approach to this I am open to suggestions and corrections.

Thanks in advance.

 
I would like it to inherit from a class XXXXX that is empty and assign the resulting object to properties UserData and UserDataHeader.

There is no class that is actually empty, all classes have certain properties by default (such as name), try using a custom class:
Code:
public oClass
oClass = createobject("usrdat")
DEFINE CLASS usrdat AS CUSTOM
     index=0
     pVal=0
ENDDEFINE

Now you can reference your class' properties by using
Code:
oClass.index



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I anticipate someone will inform me that is so.

I will be posting another question with a relevant title but which is in relation to the problem I have posted before this (Thread184-741015) which is error 1440 (OLE exception error "name". OLE object may be corrupt.)

The reason for the said error may have something to do with the data structure properties UserData and UserDataHeader because when I queried their types using the TYPE() functions, they both return "U" for undefined data type.

Thanks for the reply mgagnon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top