I have a feeling that all you will need to do is manipulate CodeSoft using
OLE. Check out the PB functions ConnectToNewObject, or ConnectToObject and
the OLEObject and take a hard look at the examples in the help.
--
Jeffrey Huntsman
MCP, MCSD
Oakwood Systems Group
www.oakwoodsys.com
<robbmarr> wrote in message
news:3C463E8E923A8DD80071FDEE85256B5E.0071FE0985256B5E@webforums...
> I have an existing app controlling a product called Codesoft using a DDE
> interface. However, the new version of Codesoft no longer supports DDE
but
> has gone to ActiveX. The only problem that I have is that they do not
> provide a .OCX file, so I don't know how to register this control. They
> have provided me with an example that someone did in Delphi (which I know
> nothing about). Can anyone explain to me what is going on in the example
> below and how to do the samething in PB?
>
>
> // CodeSoft Demo in Delphi 6 based on Visual Basic example from
> // C:\Program Files\CS6\Samples\ActiveX\Front End\Module1.bas.
> // This isn't elegant at all -- it just demonstrates Delphi can be used
> // with CodeSoft via automation.
> //
> // In Delphi 6, in Project | Import Type Library, it is unclear whether
> // "LabelManger 5.0" (lppx.tlb) or "TK Labeling ActiveX 6.0" (lppx2.tlb)
> // should be imported. They both cannot be simultaneously imported
> because
> // they use the same names.
> //
> // I ended up importing the lppx2.tlb class library containing both
> // TApplication and TDocument objects. However, for reasons I do not
> // understand, the TDocument object didn't work the way I expected
> // while trying to replicate the CodeSoft VB demo. Instead of
> // using TDocument, the example worked fine with IDocument.
> //
> // efg, Stowers Institute for Medical Research, December 2001
>
> unit ScreenCodeSoft;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
> Forms,
> Dialogs, OleServer, StdCtrls, LabelManager2_TLB, ExtCtrls;
>
> type
> TFormCodeSoft = class(TForm)
> ButtonVisible: TButton;
> ButtonReadLabel: TButton;
> Image: TImage;
> OpenDialog: TOpenDialog;
> ButtonPrintLabel: TButton;
> Memo: TMemo;
> ButtonPrintSetup: TButton;
> ButtonShowFiller: TButton;
> ButtonChangeBarcode: TButton;
> procedure ButtonVisibleClick(Sender: TObject);
> procedure ButtonReadLabelClick(Sender: TObject);
> procedure FormDestroy(Sender: TObject);
> procedure FormCreate(Sender: TObject);
> procedure ButtonPrintLabelClick(Sender: TObject);
> procedure ButtonPrintSetupClick(Sender: TObject);
> procedure ButtonShowFillerClick(Sender: TObject);
> procedure ButtonChangeBarcodeClick(Sender: TObject);
> private
> OLE_Server: LabelManager2_TLB.TApplication;
> OLE_Doc : LabelManager2_TLB.IDocument; // .TDocument; ??
>
> PROCEDURE ShowPreview;
> public
>
> end;
>
> var
> FormCodeSoft: TFormCodeSoft;
>
> implementation
> {$R *.dfm}
>
> USES
> Clipbrd;
>
> PROCEDURE TFormCodeSoft.ShowPreview;
> VAR
> Metafile: TMetafile;
> BEGIN
> // Ask server to draw the label as a metafile and copy it to the
> clipboard
> // (don't bother fixing aspect ratio like in VB example)
> OLE_Doc.ViewMode := lppxViewModeValue;
> OLE_Doc.CopyToClipboard;
>
> // If a Metafile is now on the clipboard, display it in the TImage.
> IF Clipboard.HasFormat(CF_METAFILEPICT)
> THEN BEGIN
> MetaFile := TMetaFile.Create;
> TRY
> MetaFile.Assign(Clipboard);
>
> Image.Width := MetaFile.Width;
> Image.Height := MetaFile.Height;
>
> Image.Picture.Graphic := MetaFile;
> FINALLY
> MetaFile.Free
> END
>
> END
> ELSE Image.Picture.Graphic := NIL;
> END {ShowPreview};
>
>
> procedure TFormCodeSoft.FormCreate(Sender: TObject);
> begin
> OLE_Server := TApplication.Create(NIL);
> OLE_Doc := OLE_Server.ActiveDocument;
> end;
>
>
> procedure TFormCodeSoft.FormDestroy(Sender: TObject);
> begin
> OLE_Server.Documents.CloseAll( WordBool(TRUE) );
> OLE_Server.Quit;
> OLE_DOC := NIL;
> OLE_Server := NIL
> end;
>
>
> procedure TFormCodeSoft.ButtonVisibleClick(Sender: TObject);
> begin
> OLE_Server.Visible := NOT OLE_Server.Visible
> end;
>
>
> procedure TFormCodeSoft.ButtonReadLabelClick(Sender: TObject);
> VAR
> i : INTEGER;
> x : OleVariant;
> begin
> OpenDialog.InitialDir := ExtractFilePath(ParamStr(0));
>
> IF OpenDialog.Execute
> THEN BEGIN
> OLE_Server.Documents.Open(OpenDialog.Filename, WordBool(FALSE));
> OLE_Doc := OLE_Server.ActiveDocument;
>
> Memo.Lines.Clear;
> Memo.Lines.Add(IntToStr(OLE_Doc.DocObjects.Count) + ' DocObjects');
>
> Memo.Lines.Add(IntToStr(OLE_Doc.DocObjects.Barcodes.Count) + '
> Barcodes');
> FOR i := 1 TO OLE_Doc.DocObjects.Barcodes.Count DO
> BEGIN
> x := OLE_Doc.DocObjects.Barcodes.Item(i);
> Memo.Lines.Add(' ' + IntToStr(i) + ' ' + x.Name);
> Memo.Lines.Add(' Height: ' + VarAsType(x.BarHeight,
varString) );
> Memo.Lines.Add(' Ratio : ' + VarAsType(x.Ratio, varString) );
> Memo.Lines.Add(' Symbology: ' + VarAsType(x.Symbology,
varString)
> );
> Memo.Lines.Add(' Value : ' + x.Value);
> END;
>