home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / tema / jpcad / ACC / SAMPLES / XDVIEW / BASEFRM.FR_ / BASEFRM.FR (.txt)
Encoding:
Visual Basic Form  |  1998-01-21  |  5.5 KB  |  174 lines

  1. VERSION 4.00
  2. Begin VB.Form BaseFrm 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   840
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1515
  7.    ClientWidth     =   1560
  8.    Height          =   1200
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   840
  12.    ScaleWidth      =   1560
  13.    Top             =   1215
  14.    Width           =   1680
  15.    Begin ACCLib.Amoeba Amoeba 
  16.       Left            =   240
  17.       Top             =   240
  18.       _Version        =   65536
  19.       _ExtentX        =   847
  20.       _ExtentY        =   847
  21.       _StockProps     =   0
  22.    End
  23. Attribute VB_Name = "BaseFrm"
  24. Attribute VB_Creatable = False
  25. Attribute VB_Exposed = False
  26. Dim XDataTypeStr(30) As String
  27. Option Explicit
  28. Private Sub Amoeba_Drag(ByVal UserData As Variant, ByVal Point As Object, Trans As Object, nStatus As Long)
  29.  'draw dragging line
  30.  Amoeba.DrawLine UserData, Point
  31. End Sub
  32. Private Sub Amoeba_Error(ByVal nErrorCode As Long)
  33.   If nErrorCode <= -1000 Then
  34.     MsgBox "JPCAD Error " + Str$(nErrorCode) + Chr(10) + "Ending XDView application"
  35.    End
  36.   End If
  37. End Sub
  38. Private Sub Amoeba_Status(ByVal nStatus As Long, ByVal nCmdCode As Long)
  39. 'handles Amoeba requests
  40. Dim Result As Long
  41. Select Case nStatus
  42.  Case A_LOAD
  43.      'program was loaded into Amoeba
  44.      Result = Amoeba.DefCmd("xdview", 0, 0)
  45.      Result = Amoeba.DefCmd("xdcreate", 1, 0)
  46.      Prompt "XDVIEW - new commands defined: xdcreate, xdview"
  47.  Case A_UNLOAD
  48.      'unloading request from Amoeba
  49.      Prompt "XDVIEW - unloading"
  50.      ' do not quit here ....
  51.  Case A_END
  52.     ' ...but here
  53.      Unload Me
  54.  Case A_CMD_CALL
  55.      'command was called - pass control to appropriate sub according to nCmdCode
  56.    Select Case nCmdCode
  57.          Case 0
  58.             XDViewBase
  59.          Case 1
  60.             frmXDCreate.Show 1
  61.          Case Else
  62.             'Bad procedure code
  63.     End Select
  64. End Select
  65. End Sub
  66. Private Sub Form_Load()
  67.  Hide
  68. End Sub
  69. Public Sub XDViewBase()
  70. ' main sub for XDVIEW command
  71.     'X-data types descriptions
  72.     XDataTypeStr(A_X_ARRAY) = "array"
  73.     XDataTypeStr(A_X_STRING) = "variable length string"
  74.     XDataTypeStr(A_X_CHAR) = "char"
  75.     XDataTypeStr(A_X_SHORT) = "16-bit integer"
  76.     XDataTypeStr(A_X_LONG) = "32-bit integer"
  77.     XDataTypeStr(A_X_DOUBLE) = "double"
  78.     XDataTypeStr(A_X_POINT) = "point/vector not transformated"
  79.     XDataTypeStr(A_X_LENGTH) = "double length transformated"
  80.     XDataTypeStr(A_X_ANGLE) = "double angle transformated (radians)"
  81.     XDataTypeStr(A_X_MIRROR) = "32-bit integer mirror flag"
  82.     XDataTypeStr(A_X_POSITION) = "point transformated"
  83.     XDataTypeStr(A_X_VECTOR) = "vector transformated (not moved)"
  84.     XDataTypeStr(A_X_DIRECTION) = "direction transformated (not moved or scaled)"
  85.     XDataTypeStr(A_X_ENTITY) = "index of element"
  86.     XDataTypeStr(A_X_VCHUNK) = "variable length chunk of bytes"
  87.     XDataTypeStr(A_X_CCHUNK) = "fixed length chunk of bytes"
  88.  XDataModified = False
  89.  Dim NullString As String
  90.  Dim description As String
  91.  Dim sPos As Long
  92.  Dim xType As Long
  93.  Dim xValue As Variant
  94.  Dim Point As Object
  95.  Dim i As Long
  96.  'select entity to scan for X-Data
  97.  Set Point = CreateObject("ACC.Point")
  98.         i = Amoeba.GetEnt("Handle/Select entity", "H,Handle", NullString, pEntity, Point)
  99.         If i = A_GET_CANCEL Then
  100.                 Amoeba.Prompt Chr(13) + "Bad selection"
  101.                 Exit Sub
  102.         End If
  103.         If i = A_GET_KWORD Then
  104.             i = Amoeba.GetLong("Entity handle", NullString, NullString, pEntity)
  105.             If i <> A_GET_OK Then
  106.                 Amoeba.Prompt Chr(13) + "Bad selection"
  107.                 Exit Sub
  108.             End If
  109.         End If
  110.  Loop While i <> A_GET_OK
  111.  i = 0
  112.  'count X-Data structures on selected entity
  113.  Do While BaseFrm.Amoeba.X_GetStruct(pEntity, i, pStruct) <> -1
  114.    i = i + 1
  115.  Loop
  116.  If i > 1 Then
  117.   'more than one structure, so let the user select
  118.   frmSelectXData.Show 1
  119.   If m_quitting Then
  120.     Exit Sub
  121.   End If
  122.  Else
  123.   If i = 0 Then
  124.    Prompt "No X-Data found."
  125.    Exit Sub
  126.   Else
  127.    If BaseFrm.Amoeba.X_GetStruct(pEntity, 0, pStruct) = -1 Then
  128.     Prompt "Error during loading X-Data description"
  129.     Exit Sub
  130.    End If
  131.    frmXDView.XList.Clear
  132.   End If
  133.  End If
  134.  If BaseFrm.Amoeba.X_GetDesc(pStruct, description) = -1 Then
  135.     Prompt "Could not read X-Data description"
  136.     Exit Sub
  137.  End If
  138.  If BaseFrm.Amoeba.X_CreateData(pStruct, pEntity, True, pXData) = -1 Then
  139.     Prompt "CreateData failed"
  140.     Exit Sub
  141.  End If
  142.  If BaseFrm.Amoeba.X_SetIndex(pXData, -1, -1, True) = -1 Then
  143.     Prompt "SetIndex failed"
  144.     Exit Sub
  145.  End If
  146.  sPos = InStr(description, ";")
  147.  If sPos > 0 Then
  148.   frmXDView.lbUserdescription.Caption = Left(description, sPos - 1)
  149.   frmXDView.Caption = "XData view - " + frmXDView.lbUserdescription.Caption
  150.   description = Right(description, Len(description) - sPos)
  151.  End If
  152.  Prompt "Description : " + description
  153.  frmXDView.lbDescription.Caption = description
  154.  i = 0
  155.  'retrieve all variables
  156.  Do While True
  157.     If BaseFrm.Amoeba.X_GetData(pXData, i, xType, xValue) = -1 Then
  158.         Exit Do
  159.     End If
  160.     frmXDView.XList.AddItem XDataTypeStr(xType)
  161.     frmXDView.XList.ItemData(frmXDView.XList.NewIndex) = xType
  162.     i = i + 1
  163.  Loop
  164.  If frmXDView.XList.ListCount > 0 Then
  165.   frmXDView.XList.ListIndex = 0
  166.  End If
  167.  'show main window
  168.  frmXDView.Show 1
  169. End Sub
  170. Public Sub Prompt(s As String)
  171. 'appends new-line character at the beginning of the prompt string
  172.  BaseFrm.Amoeba.Prompt Chr(10) + s
  173. End Sub
  174.