'rk_cpdf_space.inc
Namespace cPDFClassStatic
DIM SHARED oPageCanvasList AS CDicObj
End Namespace
using cPDFClassStatic
'''''''''''''''''''''''''''''''''''''''
'Namespaces implicitly have public access and this is not modifiable.
'A variable declared inside a namespace is always implicitly static
'and visible throughout the entire program even if the
'declaration modifier Shared is not specified (static and shared are optional,
' but this may improve code readability).
Type cPDF Extends Object
Private:
oPageCanvasList AS CDicObj
Namespace cPDFClassStatic
DIM SHARED oPageCanvasList AS CDicObj
End Namespace
'CdicO_rk_problem
#include once "AfxNova\CdicObj.inc"
USING AFXNOVA
? " ------------ type / class / objects ----------------------"
type PageCanvas
Width as long : Height as long : LeftMargin as long
TopMargin as long : RightMargin as long : BottomMargin as long
DrawingHeight as long : DrawingWidth as long : Orientation as long
ObjectNumber as long : StreamObject as long :StreamComplete as boolean
end type
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim uCanvas as PageCanvas
with uCanvas
.Width=612 : .Height=792 : .LeftMargin=18
.TopMargin=18 : .RightMargin=18 : .BottomMargin=18
.DrawingHeight=756 : .DrawingWidth=576 : .Orientation=1
.ObjectNumber=0 : .StreamObject=0 : .StreamComplete=false
end with
'------------------------------------------------------
declare SUB cPDF_CreateCanvas(BYREF uCanvas As PageCanvas )
declare SUB cPDF_GetCanvas(BYVAL nIndex AS LONG, BYREF uCanvas AS PageCanvas)
dim shared as long i,j = 0: ' helper-vars
? "------start of prolog---(for type + init uvar )----"
With uCanvas
? using " ## - init-var - ucanvas.Height= ##### .... .StreamComplete= &"; _
12; .Height; .StreamComplete
'for j =2 to SIZEOF(uCanvas)/4 -1 : ? "."; : next : ?
End With
? "'dim share' OR 'Static shared' 'uvar as CdicObj'"
Static shared oPageCanvasList as CdicObj
? using "-> oPageCanvasList.count {###}";oPageCanvasList.Count
? !"------end of prolog---------"
'-------------------------------------------------------
Private SUB cPDF_CreateCanvas(BYREF uCanvas As PageCanvas )
DIM dvin AS DVARIANT
DIM sCanvasID AS DWSTRING
? "------------create now -------------------"
? using " sub CanvasList.count { # }";oPageCanvasList.Count
sCanvasID = "C" + str(oPageCanvasList.Count + 1) 'FORMAT()
? using " sCanvasID='C _& count+1 { & }" ; sCanvasID
dvin.PutBuffer(@uCanvas, SIZEOF(uCanvas))
oPageCanvasList.Add(sCanvasID,dvin)
? "------------ created -------------------"
End Sub
'-------------------------------------------------------
Private SUB cPDF_GetCanvas(BYVAL nIndex AS LONG, BYREF uCanvas AS PageCanvas)
DIM dvx AS DVARIANT
DIM sCanvasID AS DWSTRING
i=i+1 : sCanvasID = "C" + str(nIndex) 'Format()
dvx = oPageCanvasList.Item(sCanvasID)
dvx.ToBuffer(@uCanvas, SIZEOF(uCanvas))
? using !"GetCanvas, ID= & with Info(#)= &";sCanvasID;i;dvx.GetErrorInfo(-1)
End Sub
'-----------------------------------------------------
? !"\nscope of oPageCanvasList must be shared/static/ "
cPDF_CreateCanvas(uCanvas )
? "------------getting now -------------------"
? !":first__call" : cPDF_GetCanvas(1,uCanvas)
? !":second__call": cPDF_GetCanvas(1,uCanvas)
'Get Canvas Error Info=Error &h80070057
? !":oth__x__call w. nindex <> 1 -> error &h80070057 - parameter error\n"
? !":oth__3__call w. nindex = 0" : cPDF_GetCanvas(0,uCanvas)
? !":oth__4__call w. nindex = 2" :cPDF_GetCanvas(2,uCanvas)
''-------------------------------------------------------
sleep
'##################console output#################
'------------ type / class / objects ----------------------
'-----start of prolog---(for type + init uvar )----
'12 - init-var - ucanvas.Height= 792 .... .StreamComplete= false
''dim share' OR 'Static shared' 'uvar as CdicObj'
'> oPageCanvasList.count { 0}
'-----end of prolog---------
'
'scope of oPageCanvasList must be shared/static/
'-----------create now -------------------
'sub CanvasList.count { 0 }
'sCanvasID='C & count+1 { C1 }
'----------- created -------------------
'-----------getting now -------------------
':first__call
'GetCanvas, ID= C1 with ErrorInfo(1)= Der Vorgang wurde erfolgreich beendet.
'
':second__call
'GetCanvas, ID= C1 with ErrorInfo(2)= Der Vorgang wurde erfolgreich beendet.
'
':oth__x__call w. nindex <> 1 --> error &h80070057 - generic parameter error
'
':oth__3__call w. nindex = 0
'GetCanvas, ID= C0 with ErrorInfo(3)= Error &h80070057
'Falscher Parameter.
'
':oth__4__call w. nindex = 2
'GetCanvas, ID= C2 with ErrorInfo(4)= Error &h80070057
'Falscher Parameter.
'#####################################
TYPE Foo
x AS long
y as long
b as WSTRING * 260
END type
' // Creates an instance of the CDicObj class
DIM SHARED pDic AS CDicObj
SUB GetUdt(BYREF tFoo2 AS Foo)
DIM dws AS DWSTRING = "Foo2"
'DIM dws AS DWSTRING = "Foo" + WSTR(2)
'DIM dws AS DWSTRING = "Foo" + FORMAT(2)
DIM dvFoo2 AS DVARIANT
'dvFoo2 = pDic.Item("Foo2")
dvFoo2 = pDic.Item(dws)
dvFoo2.ToBuffer(@tFoo2, SIZEOF(tFoo2))
print dvFoo2.GetErrorInfo(-1)
END SUB
'' // Creates an instance of the Foo type
'DIM t AS Foo = (12345, 72727, "Test string")
'' // Assigns it to a DVARIANT
'DIM dv AS DVARIANT
'dv.PutBuffer(@t, SIZEOF(t))
'' // Adds the type to the dictionary
'pDic.Add "Foo1", dv
' // Creates another instance of the Foo type
DIM t2 AS Foo = (111111, 22222, "Test string 2")
' // Assigns it to a DVARIANT
DIM dv2 AS DVARIANT
dv2.PutBuffer(@t2, SIZEOF(t2))
' // Adds the type to the dictionary
pDic.Add "Foo2", dv2
'' // Gets Foo1 from the dictionary
'DIM dvFoo1 AS DVARIANT
'dvFoo1 = pDic.Item("Foo1")
'' // Assigns it to a DVARIANT
'DIM tFoo1 AS Foo
'dvFoo1.ToBuffer(@tFoo1, SIZEOF(tFoo1))
'print dvFoo1.GetErrorInfo(-1)
'' // DIsplay the values
'print tFoo1.x
'print tFoo1.y
'print tFoo1.b
'' // Gets Foo2 from the dictionary
'DIM dvFoo2 AS DVARIANT
'dvFoo2 = pDic.Item("Foo2")
'' // Assigns it to a DVARIANT
'DIM tFoo2 AS Foo
'dvFoo2.ToBuffer(@tFoo2, SIZEOF(tFoo2))
'print dvFoo2.GetErrorInfo(-1)
'' // DIsplay the values
'print tFoo2.x
'print tFoo2.y
'print tFoo2.b
DIM tFoo2 AS Foo
GetUdt(tFoo2)
print tFoo2.x
print tFoo2.y
print tFoo2.b
tFoo2.x = 0
tFoo2.y = 0
tFoo2.b = ""
print "--------------"
GetUdt(tFoo2)
print tFoo2.x
print tFoo2.y
print tFoo2.b
tFoo2.x = 0
tFoo2.y = 0
tFoo2.b = ""
print "--------------"
GetUdt(tFoo2)
print tFoo2.x
print tFoo2.y
print tFoo2.b
print "--------------"
Private SUB cPDF.CreateCanvas(BYREF uCanvas As PageCanvas)
DIM dv AS DVARIANT
DIM sCanvasID AS DWSTRING
sCanvasID = "C" + FORMAT(oPageCanvasList.Count + 1)
dv.PutBuffer(@uCanvas, SIZEOF(uCanvas))
oPageCanvasList.Add(sCanvasID,dv)
oPageStreamList.Add("")
End Sub
Private SUB cPDF.GetCanvas(BYVAL nIndex AS LONG, BYREF uCanvas AS PageCanvas)
DIM dv AS DVARIANT
DIM sCanvasID AS DWSTRING
sCanvasID = "C" + FORMAT(nIndex)
dv = oPageCanvasList.Item(sCanvasID)
print "GetCanvas, ID=" + sCanvasID
dv.ToBuffer(@uCanvas, SIZEOF(uCanvas))
print "Get Canvas Error Info=" + dv.GetErrorInfo(-1)
sleep
End Sub
#Include once "windows.bi"
#Include once "win/uuids.bi"
#Include once "win/ole2.bi"
Dim guid As GUID
Dim wstrGUID As LPOLESTR
Dim strGUID As ZString * 260
CoCreateGuid (@guid)
If(StringFromCLSID (@guid, @wstrGUID) = S_OK) THEN
WideCharToMultiByte (CP_ACP, 0, Cast(WString Ptr,wstrGUID), -1, strGUID, MAX_PATH, NULL, NULL)
Print strGUID
EndIf
CoTaskMemFree(@wstrGUID)