LineWidth EXAMPLE

  1. Tell Visual CADD where to find the new function LineWidth. Open the CMDEXT.DEF file and add a line similar to the following.
  1. Add the following controls to the basic form LWForm.

      TLabel    change the Caption to "Line width"

      TSpinEdit

      TBitBtn   change the button Kind to bkOK

  1. The following code is not robust. That is, you are on your honour to limit input values in the SpinBtn control to between 0 to 15. Rather than control input in the code, for the purpose of the example things are kept as basic as possible.

    Add the following code to the LWUnit unit.

      unit LWUnit;

      interface

      uses
        Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
        Dialogs, StdCtrls, Spin, Buttons;

      type
        TLWForm = class(TForm)
          Label1: TLabel;
          SpinEdit1: TSpinEdit;
          BitBtn1: TBitBtn;
          procedure BitBtn1Click(Sender: TObject);
        private
          { Private declarations }
        public
          { Public declarations }
        end;

      procedure LineWidth;

      var
        LWForm: TLWForm;

      implementation

      {$R *.DFM}

      uses VCMain32, VCType32, VCDlg32, VCTool32, VCTran32, VCDelphi;

      procedure LineWidth;
      begin
        LWForm.Show;
      end;

      exports LineWidth;

      procedure TLWForm.BitBtn1Click(Sender: TObject);
      var
        EntityType : SmallInt;
        WidthIndex : Integer;
      begin
        Close;
        DLLStart('DLLTest', 'LineWidth');
        if VCFirstEntity(iError, EntityType) then
          while iError = 0 do
          begin
            WidthIndex := SpinEdit1.Value;
            VCMatchCurrentEntity(iError);
            VCSetLineWidthIndex(iError, WidthIndex);       VCApplySettingsToCurrentEntity(iError);
            VCNextEntity(iError, EntityType);
          end;
        DLLClose('DLLTest', 'LineWidth');
      end;

      initialization
        LWForm := TLWForm.Create(Application);

      finalization
        LWForm.Free;

      end.

  1. Compile the project and run it using F9. Visual CADD should start up.
  1. In Visual CADD type LW.