unit step111;

interface
uses
  Windows,
  SysUtils,
  LDefin2D,
  ksConstTLB,
  ksAuto,
{$IFDEF __LIGHT_VERSION__}
  klTLB;
{$ELSE}
  ksTLB;
{$ENDIF}

  function  LIBRARYNAME: PChar; pascal;
  procedure LIBRARYENTRY( command: WORD  ); Pascal;
  function  LIBRARYID: Cardinal; Pascal;
  function  CallBackProcCommandWindow( comm : Integer; rInfo : PIDispatch ) : Integer; stdcall;

implementation

var
  kompas : KompasObject;
  doc    : ksDocument2D;
//------------------------------------------------------------------------------
// LibraryId
//---
function LIBRARYID: UINT; pascal;
begin
  Result := 100;
end;


//------------------------------------------------------------------------------
//   
// 0 - , 1 - , 2 -  -  collection
// ---
function CallBackProcCommandWindow( comm : Integer; rInfo : PIDispatch ) : Integer; stdcall; Export;
var
  info : ksRequestInfo;
begin
//  char buf[10];
//  ::itoa( comm, buf, 10 );
  kompas.ksMessage( ' ' );
  //        
  //       
	info := ksRequestInfo( rInfo );
	if ( info <> nil ) then begin
		case comm of
			1 {ID_COMMAND_1} : info.title := '1';
      else info.title := '2';
		end;
	end;
  //   ,    
  //   :
  // TRUE - 
  // FALSE -    
  if ( comm = 14{ID_COMMAND_2_2_1_3} ) then
    Result := 0
  else
    Result := 1;
end;

//------------------------------------------------------------------------------
// LibraryEntry
//---
procedure LIBRARYENTRY( command: WORD ); pascal;
var
 info    : ksRequestInfo;
// comm    : integer;
begin
  kompas := KompasObject( CreateKompasObject );
  if kompas <> nil then begin
    doc  := ksDocument2D( kompas.Document2D() );
    info := ksRequestInfo( kompas.GetParamStruct(ko_RequestInfo) );
    if ( doc <> nil ) and ( info <> nil ) then begin
	    info.Init();
      info.MenuId := 100; // ID_TREE_CONTENTS;
      info.Title := ' ';
  	  info.SetCallBackCm( 'CALLBACKPROCCOMMANDWINDOW', HInstance, nil );
      {comm := }doc.ksCommandWindow( info );
//    char buf[10];
//    ::itoa( command, buf, 10 );
      kompas.ksMessage( ' ' );
    end;
    kompas := nil;
	end;
end;

//------------------------------------------------------------------------------
// LibraryName
//---
function LIBRARYNAME: PChar; pascal;
begin
  Result := '   ';
end;

end.
