Results 1 to 7 of 7

Thread: Visual Basic e arquivos STL

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    31

    Visual Basic e arquivos STL

    I've been looking for something like inserting 3D files (.stl format) in my project made in VB6 for a long time ... then I found a solution with a free web library (all documentation here https://www.viewstl.com/) I made it work nice together with the RC5 by olaf, but now I'm not able to run some functions in javascript, can someone help me as I call a function of the VB button?

    Sorry for my english from google translator

    Name:  Imagem1.jpg
Views: 365
Size:  16.5 KB

    Option Explicit
    Private wa As cWebArchive, WithEvents WS As cWebServer
    Private wb, wbExt As VBControlExtender
    Private WithEvents SC As cActiveScript

    Private Sub Form_Load()
    With New cIEFeatures
    .FEATURE_BROWSER_EMULATION = Int(Val(.InstalledVersion)) 'elevate the Browser-Version from its default-version 7
    End With

    If App.LogMode = 0 Then 'as long as in IDE-Mode, we re-create the *.wac every time
    Set wa = New_c.WebArchive
    wa.ReadContentsFromDirectory App.Path & "\WebAppRoot"
    wa.SaveContentsToArchiveFile App.Path & "\WebRoot.wac"
    End If

    Set wa = New_c.WebArchive(App.Path & "\WebRoot.wac") 'init the WA from the *.wac-Archive-File
    Set WS = New_c.WebServer 'create an InProcess-WebServer-instance
    WS.Listen App.Path & "\WebAppRoot", "127.0.0.1", 8888
    InitBrowser "http://127.0.0.1:8888"


    End Sub

    Private Sub InitBrowser(Optional URL As String = "about:blank")
    Set wbExt = Controls.Add("Shell.Explorer.2", "wbExt") 'only after the above went through, are we allowed to create a BrowserControl
    wbExt.Parent.Visible = True
    wbExt.Move 0, 0, ScaleWidth, ScaleHeight
    wbExt.Visible = True

    Set wb = wbExt.object
    wb.silent = True
    wb.Navigate2 URL

    Do Until wb.readyState = 4: DoEvents: Loop
    End Sub

    Private Sub Form_Resize()
    If Not wbExt Is Nothing Then wbExt.Move 0, 0, ScaleWidth, ScaleHeight
    End Sub

    Private Sub WS_ProcessRequest(Request As vbRichClient5.cWebRequest)
    Dim sURL As String: sURL = Request.URL

    Select Case sURL
    Case "", "/" 'a "naked" Root-URL-request (so we send the Start-(Home-)Page)
    With New_c.ArrayList(vbString) 'let's build the html-response-string
    .Add "<!DOCTYPE html>"
    .Add "<html>"
    .Add " <head>"
    .Add " <title></title>"
    .Add " </head>"
    .Add " <style>"
    .Add " body {text-align:center;}"
    .Add " </style>"
    .Add " <body bgcolor=""black"">"
    .Add " <div id=""stl_cont"" style=""width:" & ScaleWidth - 30 & "px;height:" & ScaleHeight - 30 & "px;margin:0 auto;""></div>"
    .Add " <script src=""stl_viewer.min.js""></script>"
    .Add " <script>"
    .Add " var stl_viewer=new StlViewer"
    .Add " ("
    .Add " document.getElementById(""stl_cont""), "
    .Add " {"
    .Add " models:"
    .Add " [ "
    .Add " {filename:""knot.stl"", display:""smooth""}"
    .Add " ] "
    .Add " }"
    .Add " );"
    .Add " </script>"
    .Add " </body>"
    .Add "</html>"

    Request.Response.SetResponseDataBytes New_c.Crypt.VBStringToUTF8(.Join(vbLf)) 'send it to the Browser
    End With

    Case Else
    Dim RelPath As String, B() As Byte
    RelPath = Replace(IIf(Len(sURL), sURL, "index.html"), "/", "")

    If Dir(Request.RootDirectory & RelPath, vbNormal) <> "" Then
    Debug.Print Request.RootDirectory & RelPath
    'B = wa.GetContent(RelPath) 'use the InMem-WebArchive to return the bytecontent of our Static-files
    B = New_c.FSO.ReadByteContent(Request.RootDirectory & RelPath) 'alternative delivery of bytes from the FS
    Request.Response.SetResponseDataBytes B
    Else
    Debug.Print "File not found: " & Request.RootDirectory & RelPath
    End If
    End Select

    End Sub

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Basic e arquivos STL

    Hi, a few comments:

    1. You might want to use more descriptive variable names.
    2. I also see states being referenced and compared with numbers. There should be enumerations where such numbers are named. Look for those and use the name from the enumeration.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    31

    Re: Visual Basic e arquivos STL

    Peter, thanks for the answer ... yes but I try to insert a "javascript" function not accepted

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Basic e arquivos STL

    I am afraid I have no idea what you mean. I took another look at your code and could you tell me what external components you're using here:
    Code:
    Private wa As cWebArchive
    Private WithEvents WS As cWebServer
    Private wb As VBControlExtender
    Private wbExt As VBControlExtender
    Private WithEvents SC As cActiveScript
    Without knowing your project's dependencies I cannot even try to debug it. EDIT: I just read "RC5 by olaf" - what is this RC5? I found a few threads on the forum but can't figure it out.
    Last edited by Peter Swinkels; Sep 16th, 2020 at 05:29 AM.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    31

    Re: Visual Basic e arquivos STL

    I adapted my code according to this project in the link https://www.vbforums.com/showthread....=1#post5473197

    I'm going to set up a new project with just that part of the code and post it here. thank you very much

  6. #6
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Basic e arquivos STL

    Perhaps you should mark this thread as resolved. That option should be available to you in the "Thread Tools" menu bar at the top of this thread.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    31

    Re: Visual Basic e arquivos STL

    but it is not yet resolved! my question continues, I just said I adapted my code according to this link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width