home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 February / Chip_2001-02_cd1.bin / sharewar / vecad / examples / vb / editor / Module2.bas < prev    next >
BASIC Source File  |  2000-09-20  |  3KB  |  105 lines

  1. Attribute VB_Name = "Module2"
  2. Public hwVec As Long   ' handle to drawing window
  3. Public VecX0 As Long   ' top of drawing window
  4. Public VecY0 As Long   ' left of drawing window
  5. Public SBarH As Long   ' height of status bar
  6.  
  7. Sub CreateVecWindow(ByVal hwnd As Long)
  8.   Dim w As Long, h As Long, h2 As Long
  9.   Dim X As Long, Y As Long
  10.   Dim WinStyle As Long
  11.   
  12.   ' Register your copy of Vecad.dll
  13.   vlRegistration 0   'use your reg. code here
  14.   
  15.   ' Create VeCAD toolbars
  16.   w = 0
  17.   h = 0
  18.   h2 = 0
  19.   X = 0
  20.   Y = -1
  21.   vlToolBarCreate hwnd, VL_TB_MAIN, X, Y, -1, 1, w, h
  22.   Y = Y + h
  23.   h2 = h
  24.   X = 0
  25.   vlToolBarCreate hwnd, VL_CB_LAYER, X, Y, 210, h2, w, h
  26.   X = X + w
  27.   vlToolBarCreate hwnd, VL_CB_COLOR, X, Y, 90, h2, w, h
  28.   X = X + w
  29.   vlToolBarCreate hwnd, VL_CB_STLINE, X, Y, 200, h2, w, h
  30.   X = X + w
  31.   vlToolBarCreate hwnd, VL_TB_SNAP, X, Y, -1, 1, w, h
  32.   Y = Y + h
  33.   vlToolBarCreate hwnd, VL_TB_DRAW, 0, Y, 60, 500, w, h
  34.   Y = Y + h
  35.   vlToolBarCreate hwnd, VL_TB_EDIT, 0, Y, 60, -1, w, h
  36.   X = w
  37.   Y = h2 + h2 - 1
  38.   VecX0 = X
  39.   VecY0 = Y
  40.   
  41.   ' Create VeCAD StatusBar
  42.   vlStatBarCreate hwnd, SBarH
  43.   
  44.   ' Create VeCAD window, size will be set in OnSize()
  45.   WinStyle = VL_WS_CHILD + VL_WS_SCROLL + VL_WS_BORDER
  46.   hwVec = vlWndCreate(hwnd, WinStyle, 0, 0, 400, 300, AddressOf DwgProc)
  47.   
  48.   If (hwVec >= 0) Then
  49.     vlPropPut VD_WND_EMPTYTEXT, hwVec, "VeCAD 5.1; By Visual Basic;"
  50.   End If
  51. End Sub
  52.  
  53. Sub ResizeVecWindow(ByVal hwnd As Long)
  54.   Dim w As Long, h As Long
  55.   
  56.   vlGetWinSize hwnd, w, h
  57.   If (w > 0 And h > 0) Then
  58.     ' Resize drawing window
  59.     vlWndResize hwVec, VecX0, VecY0, w - VecX0, h - VecY0 - SBarH
  60.     ' Resize statusbar
  61.     vlStatBarResize
  62.   End If
  63. End Sub
  64.  
  65. Sub UpdateMainTitle()
  66.   Dim iPage As Long, nPage As Long
  67.   Dim FileName As String, PageName As String, Pos As String
  68.  
  69.   FileName = Space(255)
  70.   PageName = Space(128)
  71.   iPage = vlPageIndex("", 0)
  72.   nPage = vlPageCount()
  73.   Pos = Format(iPage + 1, "0") + "/" + Format(nPage, "0")
  74.   vlPropGet VD_DWG_FILENAME, -1, FileName
  75.   vlPropGet VD_PAGE_NAME, iPage, PageName
  76.   FileName = Left(FileName, InStr(FileName, Chr(0)) - 1)
  77.   PageName = Left(PageName, InStr(PageName, Chr(0)) - 1)
  78.   Form1.Caption = "Editor - [" + FileName + "], page: " + Pos + " """ + PageName + """"
  79. End Sub
  80.  
  81. Sub FileNew()
  82.   vlFileNew hwVec, AddressOf DwgProc, ""
  83. '  Dim iDwg As Long
  84. '  iDwg = vlDwgCreate(hwVec, AddressOf DwgProc)
  85. '  If (iDwg >= 0) Then
  86. '    vlClear True
  87. '    vlRedraw
  88. '    vlSetFocus
  89. '  End If
  90. End Sub
  91.  
  92. Sub FileOpen()
  93.   vlFileOpen hwVec, AddressOf DwgProc, ""
  94. '  Dim iDwg As Long
  95. '  Dim ret As Boolean
  96. '  iDwg = vlDwgCreate(hwVec, AddressOf DwgProc)
  97. '  If (iDwg >= 0) Then
  98. '    ret = vlFileLoad(VL_FILE_VEC, "")
  99. '    If (ret = False) Then
  100. '      vlDwgDelete iDwg
  101. '    End If
  102. '  End If
  103. End Sub
  104.  
  105.