$IFNDEF __OBJECT_TOOLBOX_USED
$DEFINE __OBJECT_TOOLBOX_USED
REM [This section contains the TypeOf FUNCTION AND all other code related TO it]
REM ------------------------------------------------------------------------------------------------------
DECLARE FUNCTION ObjectToolbox_GetClassName LIB "user32" ALIAS "GetClassNameA" _
(BYVAL hWnd AS LONG, ByRef lpClassName AS STRING, BYVAL nMaxCount AS LONG) AS LONG
FUNCTION ObjectToolbox.TypeOfA(Object AS LONG) AS STRING
DIM StrBuf AS STRING, StrPtr AS STRING, StrLen AS LONG
StrBuf=SPACE$(256): StrLen=LEN(StrBuf)
StrLen=ObjectToolbox_GetClassName(Object, StrBuf, StrLen)
StrPtr=LEFT$(StrBuf, StrLen)
Result=StrPtr
END FUNCTION
FUNCTION ObjectToolbox.TypeOf(Object AS LONG) AS STRING
DIM StrBuf AS STRING, StrPtr AS STRING, StrLen AS LONG
StrBuf=SPACE$(256): StrLen=LEN(StrBuf)
StrLen=ObjectToolbox_GetClassName(Object, StrBuf, StrLen)
StrPtr=LEFT$(StrBuf, StrLen)
IF LEFT$(StrPtr, 1)="T" THEN
StrPtr=REPLACE$(StrPtr, "Q", 1)
IF RIGHT$(StrPtr, 1)="s" THEN
StrPtr=LEFT$(StrPtr, LEN(StrPtr)-1)
END IF
END IF
IF StrPtr="QBitBtn" THEN
StrPtr="QButton"
ELSEIF StrPtr="QApplication" THEN
StrPtr="Application"
ELSEIF StrPtr="#32768" THEN
StrPtr="QMenuItem"
END IF
Result=StrPtr
END FUNCTION
FUNCTIONI TypeOf(...) AS STRING
DIM ptr1 AS INTEGER, lpfn1 AS LONG, lpfn2 AS LONG, bGetNative AS BYTE
ptr1=PARAMVAL(1): bGetNative=PARAMVAL(2)
BIND lpfn1 TO ObjectToolbox.TypeOf
BIND lpfn2 TO ObjectToolbox.TypeOfA
IF PARAMVALCOUNT=1 THEN
CALLFUNC lpfn1, ptr1
ELSEIF PARAMVALCOUNT=2 AND bGetNative=1 THEN
CALLFUNC lpfn2, ptr1
END IF
lpfn1=0: lpfn2=0
END FUNCTIONI
REM ----------------------------------------------------------------------------------------------------
REM [END TypeOf() code section]
$ENDIF
|