Page 1 of 1

Making a structure with ot4xb

Posted: Wed Jul 29, 2015 12:46 pm
by rdonnay
I have a customer who needs to add custom forms to printers via code.

Windows has an API call named AddForm() under Printer Spooler functions.

This requires a structure.

I understand that ot4xb has features that are supposed to make it easier to create structures rather than using BAP.
I don't see any examples of this.

Does anyone have a sample?

Re: Making a structure with ot4xb

Posted: Wed Jul 29, 2015 12:59 pm
by Auge_Ohr
rdonnay wrote:Does anyone have a sample?
i guess you have download Source of ot4xb too.
in \Source\winapi_CommonStructures.cpp you will find a lot of Structure ready to use.
as Attachment Sample EnumPrinters.zip which also show how to write own Structure.
EnumPrinters.zip
(42.77 KiB) Downloaded 791 times

Re: Making a structure with ot4xb

Posted: Thu Jul 30, 2015 12:35 am
by Tom
You don't need any source. What you need is a correct description of the structure. Structures in OT4XB are class objects, created this way:

Code: Select all

BEGIN STRUCTURE oMyStructureName
  MEMBER UNIT _FirstPara
  MEMBER HWND _hWnd
  MEMBER BOOL _lWhatever
END STRUCTURE
This code should be at the end of the PRG. The structure object itself is created this way:

Code: Select all

oStruct := oMyStructureName():New()
All elements can be populated after that:

Code: Select all

oStruct:_FirstPara := 15
oStruct:_lWhatever := .T.
If you get a pointer to an existing structure of that kind somewhere, like in a callback, do this:

Code: Select all

FUNCTION MyCallBack(nStructPtr)
LOCAL oStruct := oMyStructureNAme():New():_link_(nStructPtr,.T.)
The last parameter (.T.) means that a copy of the structure is used here.