All BASIC

BASIC Developer & Support Resources => Scripting Languages => Topic started by: John on August 22, 2018, 10:54:15 PM

Title: Script BASIC - VB6 OCX Forms
Post by: John on August 22, 2018, 10:54:15 PM
I'm trying to pick up where Dave Zimmer left off with Script BASIC using VB6 forms as OCX controls.

Here is an example I plan to expand on.

Code: Script BASIC
  1. IMPORT COM.sbi
  2.  
  3. obj = COM::CREATE(:SET, "VB6.Sample")
  4.  
  5. 'Sample function prototypes
  6. ' longTest(v As Long)
  7. ' intTest(v As Integer)
  8. ' ByteTest(v As Byte)
  9. ' GetString(prompt As String, title, def) As String
  10. ' ShowUI() As Long
  11.  
  12. IF obj = 0 THEN
  13.   PRINT "Create Object FAILED!\n"
  14. ELSE
  15.   PRINT "TypeName obj = ", COM::TN(obj), "\n"
  16.   ' display object interface dialog
  17.  COM::DI(obj)
  18.   COM::CBN(obj, "longTest", :CALL, 20000)
  19.   COM::CBN(obj, "intTest", :CALL, 1000)
  20.   COM::CBN(obj, "byteTest", :CALL, 255)
  21.   retVal = COM::CBN(obj, "GetString", :CALL, "Enter some Text:", "my title", "default value!")
  22.   PRINT "GetString returned: ", retVal, "\n"
  23.   ' do NOT release objects you dont own..
  24.  objForm = COM::CBN(obj, "LaunchUI")
  25.   PRINT "objForm = ", objForm, "\n"
  26.   FOR i = 0 TO 10
  27.     COM::CBN(objForm, "AddItem", :CALL, "Hello from script basic! " & i)
  28.   NEXT
  29.   PRINT "Waiting until user closes form to proceede..\n"
  30.   COM::CBN(obj, "BlockUntilFormCloses")
  31.   sDate = COM::CBN(obj, "SelectDate")
  32.   IF LEN(sDate) = 0 THEN
  33.     PRINT "User pressed cancel for date selection\n"
  34.   ELSE
  35.     PRINT "Date: ", sDate, "\n"
  36.   END IF
  37.   COM::RELEASE(obj)
  38.   PRINT "All Done!\n"
  39. END IF
  40.  


C:\ScriptBASIC\examples>sbwin vb6_example.sb
TypeName obj = _Sample
GetString returned: Some Text
objForm = 3579816
Waiting until user closes form to proceede..
Date: 22/8/2018
All Done!

C:\ScriptBASIC\examples>


(https://files.allbasic.info/sbvb/obj_view.png)

(https://files.allbasic.info/sbvb/long.png)

(https://files.allbasic.info/sbvb/2bint.png)

(https://files.allbasic.info/sbvb/byte.png)

(https://files.allbasic.info/sbvb/textform.png)

(https://files.allbasic.info/sbvb/form_list.png)

(https://files.allbasic.info/sbvb/tryme.png)

(https://files.allbasic.info/sbvb/cal.png)





Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on August 23, 2018, 01:31:42 AM
Yes ... I'm going to have to follow your adventures in VB OCX/forms.

I must admit that I was wondering (last night) about parsing a .frm source into a different widget set and dialect of BASIC for direcrt use - just using VB as a form designer - thus allowing it to create cross-platform forms.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 23, 2018, 07:45:28 AM
I definitely can see using the VB IDE as a way to create IUP LED form definition files.

The only issue is VB is fixed position based and IUP is container based.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 23, 2018, 01:25:46 PM
Here is an example of VB6 form events calling back to Script BASIC functions and subs.  This functionality is crucial if VB6 is going to be used as an intelligent OCX form.

Code: Script BASIC
  1. IMPORT COM.sbi
  2.  
  3. FUNCTION Button1_Click(arg, arg1, arg2, arg3, arg4, arg5)
  4.   PRINT "Button1_Click arg =", arg, "\n"
  5.   PRINT "Button1_Click arg1 = ", arg1, "\n"
  6.   PRINT "Button1_Click arg2 = ", arg2, "\n"
  7.   PRINT "Button1_Click arg3 = ", arg3, "\n"
  8.   PRINT "Button1_Click arg4 = ", arg4, "\n"
  9.   PRINT "Button1_Click arg5 = ", arg5, "\n"
  10.   Button1_Click = arg + 1
  11. END FUNCTION
  12.  
  13. FUNCTION Button2_Click(arg)
  14.   PRINT "Back in script basic Button2_Click arg = ", arg, "\n"
  15.   Button2_Click = arg * 2
  16. END FUNCTION
  17.  
  18. obj = COM::CREATE(:SET, "VB6.Sample")
  19.  
  20. IF obj = 0 THEN
  21.   PRINT "CreateObject failed!\n"
  22. ELSE
  23.   PRINT "obj = ", obj, "\n"
  24.   oCollection = COM::CBN(obj, "CallBackHandlers", :GET)
  25.   PRINT "oCollection = ", oCollection, "\n"
  26.   COM::CBN(oCollection, "Add", :CALL, ADDRESS(Button1_Click()), "frmCallBack.cmdOp1_Click" )
  27.   COM::CBN(oCollection, "Add", :CALL, ADDRESS(Button2_Click()), "frmCallBack.cmdOp2_Click" )
  28.   retVal = COM::CBN(obj, "LaunchCallBackForm", :CALL, 21)
  29.   PRINT "LaunchCallBackForm returned ", retVal, "\n"
  30.   COM::RELEASE(obj)
  31.   PRINT "test complete!\n"
  32. END IF
  33.  


C:\ScriptBASIC\examples\sbvb>scriba cb.sb
obj = 5646152
oCollection = 5646320
Button1_Click arg =21
Button1_Click arg1 = two
Button1_Click arg2 = 3
Button1_Click arg3 = four
Button1_Click arg4 = 5
Button1_Click arg5 = 5646720
Back in script basic Button2_Click arg = 22
LaunchCallBackForm returned 44
test complete!

C:\ScriptBASIC\examples\sbvb>


I'm curious how many other BASIC languages other than VB can access OCX controls via COM/OLE automation?
 
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 23, 2018, 03:10:19 PM
This is an example of using an OCX as an out-of-process server. in the form of a .exe file. I didn't have to register the OCX. Interesting note, you can't run out-of-process with .NET.

I'm leaning towards using out-of-process server OCX based forms with Script BASIC. They offer more flexibility but give up performance which isn't my concern with the applications I write. (accounting software)

OCX EXE (https://free-visualbasic-tutor.blogspot.com/2011/07/activex-exe.html?m=1)

Creating an OCX control (http://www.thevbzone.com/l_ocx.htm)

What is an OCX? (https://community.embarcadero.com/article/technical-articles/162-programming/14557-what-is-an-ocx)

COM in plain C (https://www.codeproject.com/Articles/13601/COM-in-plain-C?msg=5546266#xx5546266xx)

Code: Script BASIC
  1. IMPORT COM.sbi
  2.  
  3. 'test using an activex exe
  4. obj = COM::CREATE(:SET, "VB6Exe.Sample")
  5. IF obj = 0 THEN
  6.   PRINT "CreateObject failed!\n"
  7. ELSE
  8.   PRINT "TypeName obj = ", COM::TN(obj), "\n"
  9.   sDate = COM::CBN(obj, "SelectDate")
  10.   IF LEN(sDate) = 0 THEN
  11.     PRINT "User pressed cancel for date selection\n"
  12.   ELSE
  13.     PRINT "Date: ", sDate, "\n"
  14.   END IF
  15.   COM::RELEASE(obj)
  16.   PRINT "Done!\n"
  17. END IF
  18.  


C:\ScriptBASIC\examples\sbvb>scriba cbexe.sb
TypeName obj = _Sample
Date: 23/8/2018
Done!

C:\ScriptBASIC\examples\sbvb>

Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on August 24, 2018, 01:54:57 AM
I definitely can see using the VB IDE as a way to create IUP LED form definition files.

The only issue is VB is fixed position based and IUP is container based.

*nods*

Should still be doable - especially if you're like me, and use sub-frames as a part of the form hierarchy in VB.

It's really more about automating the donkey work of creating the form file instead of having to do it from scratch every time. Perhaps the VB code associated with the form could be used to generate whatever customisation is required - allowing a form to be modified without losing the IUP parameters that represent the tweaks used to make the change over seamless.

Maybe in the form of:
Code: [Select]
sub WidgetName()
   with WidgetName
      .MaxWidth = value
      .MinWidth = value
      .MaxStringLength = value
      .UseHandler = HandlerName([property_list])
      .Property1 = "property"
      .Property2 = "value"
      'etc.
   end with
end sub


You could even include whatever validation and pre-processing routines you want - just as in standard VB - in order to generate a block of translated code for whatever target dialect you're after. Even C, Pascal etc.

The beauty of this is that it doesn't even have to be valid VB code, since you're using VB purely as an editor, and are never going to need to compile the form in VB.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 24, 2018, 08:25:19 AM
I think there would be more interest in a VB6 migration than a PowerBasic effort.

I'm curious how popular OCX forms as components use by other languages was in the day?
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on August 24, 2018, 11:01:08 AM
I only ever saw a few OCXs in use outside of specialist controls - and they were all used on ASP/IIS sites.

Online, they really didn't work well outside of Internet Explorer at first, and they were never seamless on Linux while OCX was being actively pushed by MS.

Last time I developed an OCX, it worked well on Windows browsers as well as on Mozilla for Linux (Debian Squeeze).

I'm not sure whether there was much uptake in C, as I never used Visual C.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 24, 2018, 11:22:40 AM
Excel is a very popular OCX used by COM/OLE supported languages. I also use COM automation with Crystal Reports and QuickBooks desktop integrations.

I think building intelligent OCX application forms and connect to them via COM/OLE automation, (CallByName in SB's instance) the business logic is separate and in the language of choice. I really don't have much interest in using OCX form controls in a web browser.
 
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 25, 2018, 12:29:34 AM
I'm working on an OCX control that will demonstrate the following in one control.


I'm thinking of converting the IUP Online Dictionary example to an OCX form. This would allow folks to compare the two directions using both GUI approaches.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on August 25, 2018, 01:58:18 AM
I meant that I only ever saw OCXs explicitly used in web pages.

I did use a few 3rd party OCX widgets myself, though.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 25, 2018, 02:39:20 PM
Many have forgotten how cool VB6 really is. The updated common controls access and theming support make it a viable IDE for today's programming.

BASIC isn't about SDK or WinAPI programming. The concept behind BASIC is to accomplish any task in the minimal number of steps and at the highest level possible.

Use C++ if Windows API programming gets you off.

Second Request
Quote
I'm curious how many other BASIC languages other than VB can access OCX controls via COM/OLE automation?

Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 26, 2018, 04:11:16 PM
Quote
I'm thinking of converting the IUP Online Dictionary example to an OCX form. This would allow folks to compare the two directions using both GUI approaches.

Here is the IUP and VB6 versions of the Script BASIC Online Dictionary example. This is a list of advantages I think the VB6 OCX GUI as an object offers.


ToDo Items


IUP
(https://www.allbasic.info/picture_library/web_dict.png)

Code: Script BASIC
  1. ' IUP Online Dictionary
  2.  
  3. IMPORT iup.sbi
  4.  
  5. servers[0]="dict.org"
  6. servers[1]="dict1.us.dict.org"
  7. servers[2]="all.dict.org"
  8.  
  9. about="""This is a Demo
  10. of the IUP GUI Binding
  11. for Scriptbasic"""
  12.  
  13. ' Initialize IUP
  14. Iup::Open()
  15.  
  16. ' Create main window
  17.  
  18. win = Iup::Create("dialog")
  19.   Iup::SetAttributes(win, "TITLE=\"ScriptBasic IUP Online Dictionary\", SIZE=500x300")
  20.   Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
  21.  
  22. ' Create container to house ALL GUI objects
  23.  
  24. vbox = Iup::Create("vbox")
  25.   Iup::SetAttributes(vbox, "MARGIN=10x10")
  26.  
  27. ' Create server panel
  28.  
  29. topBox = Iup::Create("hbox")
  30.   Iup::SetAttributes(topBox, "GAP=10")
  31.   Iup::Append(vbox, topBox)
  32. serverFrame = Iup::Create("frame")
  33.   Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")
  34.   Iup::Append(topBox, serverFrame)
  35. serverBox = Iup::Create("hbox")
  36.   Iup::SetAttributes(serverBox, "GAP=5")
  37.   Iup::Append(serverFrame, serverBox)
  38. serverCombo = Iup::Create("list")
  39.   Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")
  40.   Iup::Append(serverBox, serverCombo)
  41.   Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))
  42. btnFetch = Iup::Create("button")
  43.   Iup::SetAttributes(btnFetch, "TITLE=Fetch, SIZE = 50x")
  44.   Iup::Append(serverBox, btnFetch)
  45.   Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked()))
  46.  
  47. ' Create control panel
  48.  
  49. controlFrame = Iup::Create("frame")
  50.   Iup::SetAttributes(controlFrame, "TITLE=Controls")
  51.   Iup::Append(topBox, controlFrame)
  52. controlBox = Iup::Create("hbox")
  53.   Iup::SetAttributes(controlBox, "GAP=5")
  54.   Iup::Append(controlFrame, controlBox)
  55. btnAbout = Iup::Create("button")
  56.   Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  57.   Iup::Append(controlBox, btnAbout)
  58.   Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
  59. btnClear = Iup::Create("button")
  60.   Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")
  61.   Iup::Append(controlBox, btnClear)
  62.   Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
  63. btnExit = Iup::Create("button")
  64.   Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")
  65.   Iup::Append(controlBox, btnExit)
  66.   Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))
  67.  
  68. ' Create dictionary panel
  69.  
  70. dictFrame = Iup::Create("frame")
  71.   Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")
  72.   Iup::Append(vbox, dictFrame)
  73. serverList = Iup::Create("list")
  74.   Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")
  75.   Iup::Append(dictFrame, serverList)
  76.   Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected()))
  77.  
  78. ' Create text part
  79.  
  80. transFrame = IUP::Create("frame")
  81.   Iup::SetAttributes(transFrame, "TITLE=Translation")
  82.   Iup::Append(vbox, transFrame)
  83. text = Iup::Create("text")
  84.   Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")
  85.   Iup::Append(transFrame, text)
  86.  
  87. ' Create entry and search button
  88.  
  89. bottomBox = Iup::Create("hbox")
  90.   Iup::SetAttributes(bottomBox, "GAP=10")
  91.   Iup::Append(vbox, bottomBox)
  92. label = Iup::Create("label")
  93.   Iup::SetAttributes(label, "TITLE=\"Enter Word to Search For:\", SIZE=x12")
  94.   Iup::Append(bottomBox, label)
  95. entry = Iup::Create("text")
  96.   Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")
  97.   Iup::Append(bottomBox, entry)
  98. btnSearch = Iup::Create("button")
  99.   Iup::SetAttributes(btnSearch,"TITLE=Search, SIZE=50x")
  100.   Iup::Append(bottomBox, btnSearch)
  101.   Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))
  102. chkAll = Iup::Create("toggle")
  103.   Iup::SetAttributes(chkAll, "TITLE=ALL, SIZE=x12")
  104.   Iup::Append(bottomBox, chkAll)
  105. chkUTF = Iup::Create("toggle")
  106.   Iup::SetAttributes(chkUTF, "TITLE=UTF-8, SIZE=x12")
  107.   Iup::Append(bottomBox, chkUTF)
  108.  
  109. ' Add the main GUI container to the Window
  110.  
  111. Iup::Append(win, vbox)
  112.  
  113. ' Setup dialog defaults
  114.  
  115. Iup::Show(win)
  116. Iup::SetFocus(btnFetch)
  117. FOR i = 0 TO UBOUND(servers)
  118.   Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])
  119. NEXT
  120. Iup::SetAttribute(serverCombo, "VALUE", "1")
  121. Iup::Update(serverCombo)
  122. server_selection = servers[0]
  123.  
  124. ' Main processing loop
  125.  
  126. Iup::MainLoop()
  127. Iup::Close()
  128. END
  129.  
  130. ' Callback routines
  131.  
  132. SUB Win_exit
  133.   Iup::ExitLoop = TRUE
  134. END SUB
  135.  
  136. SUB btnAbout_clicked
  137.   Iup::Message("ABOUT", about)
  138. END SUB
  139.  
  140. SUB serverCombo_selected
  141.   server_selection = Iup::GetListText()
  142. END SUB
  143.  
  144. SUB serverList_selected
  145.   whichDictionary = Iup::GetListText()
  146. END SUB
  147.  
  148. SUB btnFetch_clicked
  149.   LOCAL dat, total, count
  150.   ON ERROR GOTO G_NetError
  151.   OPEN server_selection & ":2628" FOR SOCKET AS #1
  152.   PRINT#1,"SHOW DB\n"
  153.   LINE INPUT#1, dat
  154.   LINE INPUT#1, dat
  155.   count = 0
  156.   WHILE LEFT(dat, 1) <> "."
  157.     LINE INPUT#1, dat
  158.     IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
  159.     count+=1
  160.   WEND
  161.   PRINT#1,"QUIT\n"
  162.   CLOSE(#1)
  163.   FOR cnt = 0 TO count - 2
  164.     Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])
  165.   NEXT
  166.   Iup::SetAttribute(serverList, "VALUE", "1")
  167.   Iup::Update(serverCombo)
  168.   whichDictionary = total[0]
  169.   EXIT SUB
  170.  
  171.   G_NetError:
  172.   ' PRINT "Server ",server_selection," not available. (",ERROR,")\n"
  173. END SUB
  174.  
  175. SUB btnClear_clicked
  176.   Iup::ClearList(serverList)
  177.   Iup::SetAttribute(text, "VALUE", "")
  178.   Iup::SetAttribute(entry, "VALUE", "")
  179. END SUB
  180.  
  181. SUB btnSearch_clicked
  182.   LOCAL dict, dat, total, info
  183.   IUP::SetAttribute(text, "VALUE","Fetching....")
  184.   ON ERROR GOTO L_NetError
  185.   dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  186.   OPEN server_selection & ":2628" FOR SOCKET AS 1
  187.   IF Iup::GetAttribute(chkAll, "VALUE") THEN
  188.     PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"
  189.   ELSE
  190.     PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"
  191.   END IF
  192.   REPEAT
  193.     LINE INPUT#1, dat
  194.     IF LEFT(dat, 3) = "151" THEN
  195.       total$ &= "------------------------------\r\n"
  196.       total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))
  197.       total$ &= "------------------------------\r\n"
  198.       REPEAT
  199.         LINE INPUT#1, info
  200.         info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
  201.         IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"
  202.       UNTIL LEFT(info, 1) = "."
  203.       total &= "\n"
  204.     END IF
  205.   UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  206.   PRINT#1,"QUIT\n"
  207.   CLOSE(#1)
  208.   IF LEFT(dat, 3) = "552" THEN
  209.     total = "No match found."
  210.   ELSE IF LEFT(dat, 3) = "501" THEN
  211.     total = "Select a dictionary first!"
  212.   ELSE IF LEFT(dat, 3) = "550" THEN
  213.     total = "Invalid database!"
  214.   END IF
  215.   Iup::SetAttribute(text, "VALUE", total)
  216. EXIT SUB
  217.  
  218. L_NetError:
  219.   dat[0] = "Could not lookup word! (" & ERROR & ")"
  220.   Iup::SetAttribute(text, "VALUE", dat)
  221. END SUB
  222.  


VB6
(https://www.allbasic.info/picture_library/VB6_Online_Dict.png)

Code: Visual Basic
  1. VERSION 5.00
  2. Object = "{A99BDCD4-AB6D-490E-A03D-BF90764CBC6B}#1.0#0"; "VBCCR14.OCX"
  3. Begin VB.Form win
  4.    Caption         =   "Script BASIC VB6 Online Dictionary"
  5.    ClientHeight    =   7860
  6.    ClientLeft      =   120
  7.    ClientTop       =   450
  8.    ClientWidth     =   10995
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   7860
  11.    ScaleWidth      =   10995
  12.    StartUpPosition =   3  'Windows Default
  13.   Begin VBCCR14.CheckBoxW chkUTF
  14.       Height          =   315
  15.       Left            =   9915
  16.       TabIndex        =   11
  17.       Top             =   7200
  18.       Width           =   765
  19.       _ExtentX        =   1349
  20.       _ExtentY        =   556
  21.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  22.          Name            =   "MS Sans Serif"
  23.          Size            =   8.25
  24.          Charset         =   0
  25.          Weight          =   400
  26.          Underline       =   0   'False
  27.         Italic          =   0   'False
  28.         Strikethrough   =   0   'False
  29.      EndProperty
  30.       Caption         =   "Main.frx":0000
  31.    End
  32.    Begin VBCCR14.CheckBoxW chkAll
  33.       Height          =   255
  34.       Left            =   9105
  35.       TabIndex        =   10
  36.       Top             =   7245
  37.       Width           =   540
  38.       _ExtentX        =   953
  39.       _ExtentY        =   450
  40.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  41.          Name            =   "MS Sans Serif"
  42.          Size            =   8.25
  43.          Charset         =   0
  44.          Weight          =   400
  45.          Underline       =   0   'False
  46.         Italic          =   0   'False
  47.         Strikethrough   =   0   'False
  48.      EndProperty
  49.       Caption         =   "Main.frx":002A
  50.    End
  51.    Begin VBCCR14.CommandButtonW btnSearch
  52.       Height          =   345
  53.       Left            =   7815
  54.       TabIndex        =   9
  55.       Top             =   7185
  56.       Width           =   1140
  57.       _ExtentX        =   2011
  58.       _ExtentY        =   609
  59.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  60.          Name            =   "MS Sans Serif"
  61.          Size            =   8.25
  62.          Charset         =   0
  63.          Weight          =   400
  64.          Underline       =   0   'False
  65.         Italic          =   0   'False
  66.         Strikethrough   =   0   'False
  67.      EndProperty
  68.       Caption         =   "Main.frx":0050
  69.    End
  70.    Begin VBCCR14.TextBoxW entry
  71.       Height          =   330
  72.       Left            =   2475
  73.       TabIndex        =   8
  74.       Top             =   7185
  75.       Width           =   5205
  76.       _ExtentX        =   9181
  77.       _ExtentY        =   582
  78.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  79.          Name            =   "MS Sans Serif"
  80.          Size            =   8.25
  81.          Charset         =   0
  82.          Weight          =   400
  83.          Underline       =   0   'False
  84.         Italic          =   0   'False
  85.         Strikethrough   =   0   'False
  86.      EndProperty
  87.    End
  88.    Begin VBCCR14.FrameW transFrame
  89.       Height          =   2805
  90.       Left            =   150
  91.       Top             =   4215
  92.       Width           =   10740
  93.       _ExtentX        =   18944
  94.       _ExtentY        =   4948
  95.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  96.          Name            =   "MS Sans Serif"
  97.          Size            =   8.25
  98.          Charset         =   0
  99.          Weight          =   400
  100.          Underline       =   0   'False
  101.         Italic          =   0   'False
  102.         Strikethrough   =   0   'False
  103.      EndProperty
  104.       Caption         =   "Main.frx":007C
  105.       Begin VBCCR14.TextBoxW text
  106.          Height          =   2505
  107.          Left            =   0
  108.          TabIndex        =   6
  109.          Top             =   255
  110.          Width           =   10740
  111.          _ExtentX        =   18944
  112.          _ExtentY        =   4419
  113.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  114.             Name            =   "MS Sans Serif"
  115.             Size            =   8.25
  116.             Charset         =   0
  117.             Weight          =   400
  118.             Underline       =   0   'False
  119.            Italic          =   0   'False
  120.            Strikethrough   =   0   'False
  121.         EndProperty
  122.          BorderStyle     =   0
  123.          ScrollBars      =   3
  124.       End
  125.    End
  126.    Begin VBCCR14.FrameW dictFrame
  127.       Height          =   2820
  128.       Left            =   150
  129.       Top             =   1410
  130.       Width           =   10740
  131.       _ExtentX        =   18944
  132.       _ExtentY        =   4974
  133.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  134.          Name            =   "MS Sans Serif"
  135.          Size            =   8.25
  136.          Charset         =   0
  137.          Weight          =   400
  138.          Underline       =   0   'False
  139.         Italic          =   0   'False
  140.         Strikethrough   =   0   'False
  141.      EndProperty
  142.       Caption         =   "Main.frx":00B2
  143.       Begin VBCCR14.ListBoxW serverList
  144.          Height          =   2340
  145.          Left            =   15
  146.          TabIndex        =   5
  147.          Top             =   240
  148.          Width           =   10710
  149.          _ExtentX        =   18891
  150.          _ExtentY        =   4128
  151.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  152.             Name            =   "MS Sans Serif"
  153.             Size            =   8.25
  154.             Charset         =   0
  155.             Weight          =   400
  156.             Underline       =   0   'False
  157.            Italic          =   0   'False
  158.            Strikethrough   =   0   'False
  159.         EndProperty
  160.          BackColor       =   -2147483643
  161.          ForeColor       =   -2147483640
  162.          BorderStyle     =   0
  163.       End
  164.    End
  165.    Begin VBCCR14.FrameW controlFrame
  166.       Height          =   915
  167.       Left            =   6840
  168.       Top             =   300
  169.       Width           =   3900
  170.       _ExtentX        =   6879
  171.       _ExtentY        =   1614
  172.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  173.          Name            =   "MS Sans Serif"
  174.          Size            =   8.25
  175.          Charset         =   0
  176.          Weight          =   400
  177.          Underline       =   0   'False
  178.         Italic          =   0   'False
  179.         Strikethrough   =   0   'False
  180.      EndProperty
  181.       Caption         =   "Main.frx":00EA
  182.       Begin VBCCR14.CommandButtonW btnExit
  183.          Height          =   345
  184.          Left            =   2595
  185.          TabIndex        =   4
  186.          Top             =   405
  187.          Width           =   1125
  188.          _ExtentX        =   1984
  189.          _ExtentY        =   609
  190.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  191.             Name            =   "MS Sans Serif"
  192.             Size            =   8.25
  193.             Charset         =   0
  194.             Weight          =   400
  195.             Underline       =   0   'False
  196.            Italic          =   0   'False
  197.            Strikethrough   =   0   'False
  198.         EndProperty
  199.          Caption         =   "Main.frx":011A
  200.       End
  201.       Begin VBCCR14.CommandButtonW btnClear
  202.          Height          =   360
  203.          Left            =   1395
  204.          TabIndex        =   3
  205.          Top             =   405
  206.          Width           =   1125
  207.          _ExtentX        =   1984
  208.          _ExtentY        =   635
  209.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  210.             Name            =   "MS Sans Serif"
  211.             Size            =   8.25
  212.             Charset         =   0
  213.             Weight          =   400
  214.             Underline       =   0   'False
  215.            Italic          =   0   'False
  216.            Strikethrough   =   0   'False
  217.         EndProperty
  218.          Caption         =   "Main.frx":0142
  219.       End
  220.       Begin VBCCR14.CommandButtonW btnAbout
  221.          Height          =   360
  222.          Left            =   195
  223.          TabIndex        =   2
  224.          Top             =   405
  225.          Width           =   1125
  226.          _ExtentX        =   1984
  227.          _ExtentY        =   635
  228.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  229.             Name            =   "MS Sans Serif"
  230.             Size            =   8.25
  231.             Charset         =   0
  232.             Weight          =   400
  233.             Underline       =   0   'False
  234.            Italic          =   0   'False
  235.            Strikethrough   =   0   'False
  236.         EndProperty
  237.          Caption         =   "Main.frx":016C
  238.       End
  239.    End
  240.    Begin VBCCR14.FrameW serverFrame
  241.       Height          =   915
  242.       Left            =   285
  243.       Top             =   315
  244.       Width           =   6375
  245.       _ExtentX        =   11245
  246.       _ExtentY        =   1614
  247.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  248.          Name            =   "MS Sans Serif"
  249.          Size            =   8.25
  250.          Charset         =   0
  251.          Weight          =   400
  252.          Underline       =   0   'False
  253.         Italic          =   0   'False
  254.         Strikethrough   =   0   'False
  255.      EndProperty
  256.       Caption         =   "Main.frx":0196
  257.       Begin VBCCR14.CommandButtonW btnFetch
  258.          Height          =   345
  259.          Left            =   5085
  260.          TabIndex        =   1
  261.          Top             =   390
  262.          Width           =   1125
  263.          _ExtentX        =   1984
  264.          _ExtentY        =   609
  265.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  266.             Name            =   "MS Sans Serif"
  267.             Size            =   8.25
  268.             Charset         =   0
  269.             Weight          =   400
  270.             Underline       =   0   'False
  271.            Italic          =   0   'False
  272.            Strikethrough   =   0   'False
  273.         EndProperty
  274.          Caption         =   "Main.frx":01C4
  275.       End
  276.       Begin VBCCR14.ComboBoxW serverCombo
  277.          Height          =   315
  278.          Left            =   195
  279.          TabIndex        =   0
  280.          Top             =   405
  281.          Width           =   4800
  282.          _ExtentX        =   8467
  283.          _ExtentY        =   556
  284.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  285.             Name            =   "MS Sans Serif"
  286.             Size            =   8.25
  287.             Charset         =   0
  288.             Weight          =   400
  289.             Underline       =   0   'False
  290.            Italic          =   0   'False
  291.            Strikethrough   =   0   'False
  292.         EndProperty
  293.          Style           =   2
  294.          Text            =   "Main.frx":01EE
  295.       End
  296.    End
  297.    Begin VBCCR14.LabelW label
  298.       Height          =   195
  299.       Left            =   300
  300.       TabIndex        =   7
  301.       Top             =   7230
  302.       Width           =   1875
  303.       _ExtentX        =   3307
  304.       _ExtentY        =   344
  305.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  306.          Name            =   "MS Sans Serif"
  307.          Size            =   8.25
  308.          Charset         =   0
  309.          Weight          =   400
  310.          Underline       =   0   'False
  311.         Italic          =   0   'False
  312.         Strikethrough   =   0   'False
  313.      EndProperty
  314.       Caption         =   "Enter Word to Search For:"
  315.    End
  316. End
  317. Attribute VB_Name = "win"
  318. Attribute VB_GlobalNameSpace = False
  319. Attribute VB_Creatable = False
  320. Attribute VB_PredeclaredId = True
  321. Attribute VB_Exposed = False
  322.  

Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 29, 2018, 11:12:14 PM
Based on on the underwhelming response to this thread, I assume the concept of using a VB OCX as a GUI object and controlled via a COM/OLE automation interface doesn't excite anyone?

Hard core SDK / WinAPI32 coding emulated in a somewhat like BASIC seems to be the popular trend to achieve a Windows GUI.

I can't make any money if I have to recreate the wheel each time building a Windows GUI framework before I even get started on the project I'm being paid for.


Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on August 30, 2018, 01:11:03 AM
I, for one, like the idea of OCX forms.

I, however, am but one voice in the wilderness ...

 ... and am not (presently) actively developing any user interfaces.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on August 30, 2018, 10:37:31 PM
I was able to get my OLD (On Line Dictionary) OCX to do the following.

(https://www.allbasic.info/picture_library/VB6_Online_Dict.png)

(https://www.allbasic.info/picture_library/sb_fetch_clicked.png)   (https://www.allbasic.info/picture_library/sb_about_clicked.png)   (https://www.allbasic.info/picture_library/vb_about_return.png)

Code: Script BASIC
  1. IMPORT COM.sbi
  2. IMPORT DYC.sbi
  3.  
  4. FUNCTION Fetch_Clicked
  5.   DYC::dyc("ms,i,USER32.DLL,MessageBox,PZZL",0,"Fetch Clicked" & CHR(0),"On Line Dictionary",0)
  6.   Fetch_Clicked = TRUE
  7. END FUNCTION
  8.  
  9. FUNCTION About_Clicked(arg0,arg1,arg2)
  10.   DYC::dyc("ms,i,USER32.DLL,MessageBox,PZZL",0,"About Clicked\nAbout Me: " & arg0 & "\n" & _
  11.                                                 arg1 & " " & arg2 & CHR(0), _
  12.                                                 "On Line Dictionary",0)
  13.   About_Clicked = "Return from About click"
  14. END FUNCTION
  15.  
  16.  
  17. obj = COM::CREATE(:SET, "OLD.OLDict")
  18. oCollection = COM::CBN(obj, "CallBackHandlers", :GET)
  19. COM::CBN oCollection, "Add", :CALL, ADDRESS(Fetch_Clicked()), "win.btnFetch_Click"
  20. COM::CBN oCollection, "Add", :CALL, ADDRESS(About_Clicked()), "win.btnAbout_Click"
  21. COM::CBN obj, "ShowOLD"
  22. COM::RELEASE obj
  23.  

OLD.cls
Code: Visual Basic
  1. Public CallBackHandlers As New Collection
  2.  
  3. Public Function ShowOLD() As Long
  4.     ShowOLD = win.ShowMain(Me)
  5. End Function
  6.  

Main.frm (win)
Code: Visual Basic
  1. Private Declare Function ext_SBCallBack Lib "COM.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
  2. Private Declare Function ext_SBCallBackEx Lib "COM.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
  3.  
  4. Private m_owner As OLDict
  5.  
  6. Function ShowMain(owner As OLDict) As Long
  7.     On Error Resume Next
  8.     Set m_owner = owner
  9.     Me.Show 1
  10.     Set m_owner = Nothing
  11.     ShowMain = 0
  12.     Unload Me
  13. End Function
  14.  
  15. Private Function TriggerCallBack(nodeID As Long, argValue As Long)
  16.     TriggerCallBack = ext_SBCallBack(nodeID, argValue)
  17. End Function
  18. Private Function TriggerCallBackEx(nodeID As Long, v() As Variant)
  19.     TriggerCallBackEx = ext_SBCallBackEx(nodeID, v)
  20. End Function
  21.  
  22. Private Sub btnFetch_Click()
  23.     Dim nodeID As Long
  24.     Dim arg As Long
  25.     Dim rtnVal As Long
  26.    
  27.     nodeID = m_owner.CallBackHandlers("win.btnFetch_Click")
  28.     arg = False
  29.     rtnVal = TriggerCallBack(nodeID, arg)
  30. End Sub
  31.  
  32. Private Sub btnAbout_Click()
  33.     Dim nodeID As Long
  34.     Dim args(3)
  35.     Dim rtnVal As String
  36.    
  37.     nodeID = m_owner.CallBackHandlers("win.btnAbout_Click")
  38.     Set args(0) = Me
  39.     args(1) = 99
  40.     args(2) = "Bottles of beer."
  41.     rtnVal = TriggerCallBackEx(nodeID, args)
  42.     MsgBox rtnVal, vbExclamation
  43. End Sub
  44.  
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 01, 2018, 11:37:30 PM
I just wanted to mention I couln't be happier how well this is working even if no one else cares.

I see this saving me a tons of time building modern GUI applications that are easy to create and support.

Lets hope MS keeps COM/OLE automation around for awhile.



Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 02, 2018, 01:24:24 AM
I can't see COM/OLE disappearing in the near future - it is too deeply embedded into the current generation of applications.

Mind you, even if it does get cut, I'm sure the Open Source community (fingers crossed here) will end up producing a COM/OLE to whatever's new bridge (driver).
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 02, 2018, 10:03:00 AM
If Microsoft wants to keep the developers they have, taking things away isn't the way to do it.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 02, 2018, 03:16:50 PM
I had forgotten about the MsgBox function in the NT extension module. Much easier to use than the DYC FFI call to the Windows MessageBox API function.

NT MsgBox Documentation (https://www.scriptbasic.org/docs/nt/mod_nt_7.html)

Code: Script BASIC
  1. IMPORT COM.sbi
  2. IMPORT NT.sbi
  3.  
  4. FUNCTION Fetch_Clicked
  5.   NT::MsgBox "Fetch Clicked", "On Line Dictionary", "OK","Info", 1
  6.   Fetch_Clicked = TRUE
  7. END FUNCTION
  8.  
  9. FUNCTION About_Clicked(arg0,arg1,arg2)
  10.   NT::MsgBox "About Clicked\nAbout Me: " & arg0 & "\n" & _
  11.               arg1 & " " & arg2, "On Line Dictionary", "OK","Info", 1
  12.   About_Clicked = "Return from About click"
  13. END FUNCTION
  14.  
  15.  
  16. obj = COM::CREATE(:SET, "OLD.OLDict")
  17. oCollection = COM::CBN(obj, "CallBackHandlers", :GET)
  18. COM::CBN oCollection, "Add", :CALL, ADDRESS(Fetch_Clicked()), "win.btnFetch_Click"
  19. COM::CBN oCollection, "Add", :CALL, ADDRESS(About_Clicked()), "win.btnAbout_Click"
  20. COM::CBN obj, "ShowOLD"
  21. COM::RELEASE obj
  22.  

(https://allbasic.info/picture_library/nt_fetch.png)     (https://allbasic.info/picture_library/nt_about.png)
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 02, 2018, 06:01:31 PM
For those wondering if this runs on the current version of Windows 10.


(https://allbasic.info/picture_library/win10_form.png)

(https://allbasic.info/picture_library/win10_fetch.png)   (https://allbasic.info/picture_library/win10_about.png)   (https://allbasic.info/picture_library/win10_about_return.png)



Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 02, 2018, 10:24:33 PM
The author of the VBCCR (Common Controls Replacement) OCX also wrote a MSFlexGrid Replacement OCX. It supports Unicode among other enhancements.

Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 03, 2018, 10:31:28 AM
░░░░░░░░░░░░▄▄░░░░░░░░░
░░░░░░░░░░░█░░█░░░░░░░░
░░░░░░░░░░░█░░█░░░░░░░░
░░░░░░░░░░█░░░█░░░░░░░░
░░░░░░░░░█░░░░█░░░░░░░░
███████▄▄█░░░░░██████▄░░
▓▓▓▓▓▓█░░░░░░░░░░░░░░█░
▓▓▓▓▓▓█░░░░░░░░░░░░░░█░
▓▓▓▓▓▓█░░░░░░░░░░░░░░█░
▓▓▓▓▓▓█░░░░░░░░░░░░░░█░
▓▓▓▓▓▓█░░░░░░░░░░░░░░█░
▓▓▓▓▓▓█████░░░░░░░░░█░░
██████▀░░░░▀▀██████▀░░░░
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 04, 2018, 11:56:28 PM
Here is the VB6 OCX version of the On Line Dictionary example. Compare it to the IUP version in post #12 of this thread.

(https://allbasic.info/picture_library//sbvb_old.png)

Code: Script BASIC
  1. IMPORT COM.sbi
  2. IMPORT NT.sbi
  3.  
  4. servers[0]="dict.org"
  5. servers[1]="dict1.us.dict.org"
  6. servers[2]="all.dict.org"
  7.  
  8. FUNCTION btnFetch_Clicked
  9.   LOCAL dat, total, count
  10.   ON ERROR GOTO G_NetError
  11.   server_selection = COM::CBN(obj, "CurrentServer")
  12.   OPEN server_selection & ":2628" FOR SOCKET AS #1
  13.   PRINT#1,"SHOW DB\n"
  14.   LINE INPUT#1, dat
  15.   LINE INPUT#1, dat
  16.   count = 0
  17.   WHILE LEFT(dat, 1) <> "."
  18.     LINE INPUT#1, dat
  19.     IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
  20.     count+=1
  21.   WEND
  22.   PRINT#1,"QUIT\n"
  23.   CLOSE(#1)
  24.   FOR cnt = 0 TO count - 2
  25.     COM::CBN obj, "AddDictionaries", :CALL, total[cnt]
  26.   NEXT
  27.   COM::CBN obj, "DefaultDictionary"
  28.   btnFetch_Clicked = TRUE
  29.   EXIT FUNCTION
  30.  
  31.   G_NetError:
  32.   NT::MsgBox "Server " & server_selection & " not available. (" & ERROR & ")", "OLD Error", "OK","Info", 1
  33. END FUNCTION
  34.  
  35. FUNCTION btnSearch_clicked
  36.   LOCAL dict, dat, total, info
  37.   ON ERROR GOTO L_NetError
  38.   whichDictionary = COM::CBN(obj, "CurrentDictionary")
  39.   searchword = COM::CBN(obj, "SearchWord", :GET)
  40.   dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  41.   OPEN COM::CBN(obj, "CurrentServer") & ":2628" FOR SOCKET AS 1
  42.   IF COM::CBN(obj, "AllDict", :GET) THEN
  43.     PRINT#1,"DEFINE * " & searchword & "\n"
  44.   ELSE
  45.     PRINT#1,"DEFINE " & dict & " " & searchword & "\n"
  46.   END IF
  47.   REPEAT
  48.     LINE INPUT#1, dat
  49.     IF LEFT(dat, 3) = "151" THEN
  50.       total$ &= "------------------------------\r\n"
  51.       total$ &= RIGHT(dat, LEN(dat) - LEN(searchword) - LEN(dict))
  52.       total$ &= "------------------------------\r\n"
  53.       REPEAT
  54.         LINE INPUT#1, info
  55.         info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
  56.         IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\r\n"
  57.       UNTIL LEFT(info, 1) = "."
  58.       total &= "\r\n"
  59.     END IF
  60.   UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  61.   PRINT#1,"QUIT\n"
  62.   CLOSE(#1)
  63.   IF LEFT(dat, 3) = "552" THEN
  64.     total = "No match found."
  65.   ELSE IF LEFT(dat, 3) = "501" THEN
  66.     total = "Select a dictionary first!"
  67.   ELSE IF LEFT(dat, 3) = "550" THEN
  68.     total = "Invalid database!"
  69.   END IF
  70.   COM::CBN(obj, "SetTranslation", :CALL, total)
  71.   btnSearch_Clicked = TRUE
  72. EXIT FUNCTION
  73.  
  74. L_NetError:
  75.   dat[0] = "Could not lookup word! (" & ERROR & ")"
  76.   COM::CBN(obj, "SetTranslation", :CALL, dat)
  77. END FUNCTION
  78.  
  79. ' MAIN
  80.  
  81. obj = COM::CREATE(:SET, "OLD.OLDict")
  82. oCollection = COM::CBN(obj, "CallBackHandlers", :GET)
  83. COM::CBN oCollection, "Add", :CALL, ADDRESS(btnFetch_Clicked()), "win.btnFetch_Click"
  84. COM::CBN oCollection, "Add", :CALL, ADDRESS(btnSearch_Clicked()), "win.btnSearch_Click"
  85. FOR idx = 0 TO UBOUND(servers)
  86.   COM::CBN obj, "AddServer", :CALL, servers[idx]
  87. NEXT  
  88. COM::CBN obj, "DefaultServer"
  89. COM::CBN obj, "ShowOLD"
  90. COM::RELEASE obj
  91.  

FORM
Code: Visual Basic
  1. Private Declare Function ext_SBCallBack Lib "COM.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
  2. Private Declare Function ext_SBCallBackEx Lib "COM.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
  3.  
  4. Private m_owner As OLDict
  5. Private Type ControlPositionType
  6.     Left As Single
  7.     Top As Single
  8.     Width As Single
  9.     Height As Single
  10.     FontSize As Single
  11. End Type
  12.  
  13. Private m_ControlPositions() As ControlPositionType
  14. Private m_FormWid As Single
  15. Private m_FormHgt As Single
  16.  
  17.  
  18. Function ShowMain(owner As OLDict) As Long
  19.     On Error Resume Next
  20.     Set m_owner = owner
  21.     Me.Show 1
  22.     Set m_owner = Nothing
  23.     ShowMain = 0
  24.     Unload Me
  25. End Function
  26.  
  27. Private Function TriggerCallBack(nodeID As Long, argValue As Long) As Long
  28.     TriggerCallBack = ext_SBCallBack(nodeID, argValue)
  29. End Function
  30.  
  31. Private Function TriggerCallBackEx(nodeID As Long, v() As Variant)
  32.     TriggerCallBackEx = ext_SBCallBackEx(nodeID, v)
  33. End Function
  34.  
  35. Public Sub btnClear_Click()
  36.     win.serverList.Clear
  37.     win.dictTB.Text = ""
  38.     win.entry.Text = ""
  39.     win.btnFetch.SetFocus
  40.     End Sub
  41.  
  42. Private Sub btnExit_Click()
  43.     Set m_owner = Nothing
  44.     btnExit = 0
  45.     Unload Me
  46. End Sub
  47.  
  48. Private Sub btnFetch_Click()
  49.     Dim nodeID As Long
  50.     Dim arg As Long
  51.     Dim rtnVal As Long
  52.    
  53.     win.serverList.Clear
  54.     nodeID = m_owner.CallBackHandlers("win.btnFetch_Click")
  55.     arg = False
  56.     rtnVal = TriggerCallBack(nodeID, arg)
  57. End Sub
  58.  
  59. Private Sub btnSearch_Click()
  60.     Dim nodeID As Long
  61.     Dim arg As Long
  62.     Dim rtnVal As Long
  63.    
  64.     nodeID = m_owner.CallBackHandlers("win.btnSearch_Click")
  65.     arg = False
  66.     rtnVal = TriggerCallBack(nodeID, arg)
  67. End Sub
  68.  
  69. Private Sub btnAbout_Click()
  70.     MsgBox "Script BASIC VB6" & vbCrLf & "On Line Dictionary", vbInformation, "About"
  71. End Sub
  72.  
  73.  
  74. ' Save the form's and controls' dimensions.
  75. Private Sub SaveSizes()
  76. Dim i As Integer
  77. Dim ctl As Control
  78.  
  79.     ' Save the controls' positions and sizes.
  80.    ReDim m_ControlPositions(1 To Controls.Count)
  81.     i = 1
  82.     For Each ctl In Controls
  83.         With m_ControlPositions(i)
  84.             If TypeOf ctl Is Line Then
  85.                 .Left = ctl.X1
  86.                 .Top = ctl.Y1
  87.                 .Width = ctl.X2 - ctl.X1
  88.                 .Height = ctl.Y2 - ctl.Y1
  89.             Else
  90.                 .Left = ctl.Left
  91.                 .Top = ctl.Top
  92.                 .Width = ctl.Width
  93.                 .Height = ctl.Height
  94.                 On Error Resume Next
  95.                 .FontSize = ctl.Font.Size
  96.                 On Error GoTo 0
  97.             End If
  98.         End With
  99.         i = i + 1
  100.     Next ctl
  101.  
  102.     ' Save the form's size.
  103.    m_FormWid = ScaleWidth
  104.     m_FormHgt = ScaleHeight
  105. End Sub
  106.  
  107. Private Sub Form_Load()
  108.     SaveSizes
  109. End Sub
  110.  
  111. Private Sub Form_Resize()
  112.     ResizeControls
  113. End Sub
  114.  
  115. ' Arrange the controls for the new size.
  116. Private Sub ResizeControls()
  117. Dim i As Integer
  118. Dim ctl As Control
  119. Dim x_scale As Single
  120. Dim y_scale As Single
  121.  
  122.     ' Don't bother if we are minimized.
  123.    If WindowState = vbMinimized Then Exit Sub
  124.  
  125.     ' Get the form's current scale factors.
  126.    x_scale = ScaleWidth / m_FormWid
  127.     y_scale = ScaleHeight / m_FormHgt
  128.  
  129.     ' Position the controls.
  130.    i = 1
  131.     For Each ctl In Controls
  132.         With m_ControlPositions(i)
  133.             If TypeOf ctl Is Line Then
  134.                 ctl.X1 = x_scale * .Left
  135.                 ctl.Y1 = y_scale * .Top
  136.                 ctl.X2 = ctl.X1 + x_scale * .Width
  137.                 ctl.Y2 = ctl.Y1 + y_scale * .Height
  138.             Else
  139.                 ctl.Left = x_scale * .Left
  140.                 ctl.Top = y_scale * .Top
  141.                 ctl.Width = x_scale * .Width
  142.                 If Not (TypeOf ctl Is ComboBox) Then
  143.                     ' Cannot change height of ComboBoxes.
  144.                    ctl.Height = y_scale * .Height
  145.                 End If
  146.                 On Error Resume Next
  147.                 ctl.Font.Size = y_scale * .FontSize
  148.                 On Error GoTo 0
  149.             End If
  150.         End With
  151.         i = i + 1
  152.     Next ctl
  153. End Sub
  154.  

CLASS
Code: Visual Basic
  1. Public CallBackHandlers As New Collection
  2.  
  3. Public Function ShowOLD() As Long
  4.     ShowOLD = win.ShowMain(Me)
  5. End Function
  6.  
  7. Public Sub AddServer(server_url As String)
  8.     win.serverCombo.AddItem server_url
  9. End Sub
  10.  
  11. Public Sub DefaultServer()
  12.     win.serverCombo.ListIndex = 0
  13. End Sub
  14.  
  15. Public Function CurrentServer() As String
  16.     CurrentServer = win.serverCombo.List(win.serverCombo.ListIndex)
  17. End Function
  18.  
  19. Public Sub AddDictionaries(dictionary As String)
  20.     win.serverList.AddItem dictionary
  21. End Sub
  22.  
  23. Public Function CurrentDictionary() As String
  24.     CurrentDictionary = win.serverList.List(win.serverList.ListIndex)
  25. End Function
  26.  
  27. Public Sub DefaultDictionary()
  28.     win.serverList.ListIndex = 0
  29. End Sub
  30.  
  31. Public Sub SetTranslation(translation_text As String)
  32.     win.dictTB.Text = translation_text
  33. End Sub
  34.  
  35. Public Property Get SearchWord() As String
  36.     win.dictTB.SetFocus
  37.     SearchWord = win.entry.Text
  38. End Property
  39.  
  40. Public Property Get AllDict() As Long
  41.     AllDict = win.chkAll.Value
  42. End Property
  43.  




Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 05, 2018, 11:19:02 PM
I've changed the GetALL and GetEntry methods to AllDict and SearchWord properties. The Script BASIC and VB CLASS code in the previous post has been updated with the GET property changes.

Here is how the Script BASIC COM interface browser sees the OCX DLL.

(https://www.allbasic.info/picture_library/obj_view3.png)
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 07, 2018, 10:58:58 PM
I've added resize ability to to On Line Dictionary form. The routines are simple to use and also handles resizing the fonts.  Code updated in post #23.

Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 08, 2018, 08:05:42 AM
At this point, the VB6 based On Line Dictionary is functionally equivalent to the IUP version shown earlier in this thread. Other than not being cross platform, I like the VB6 direction more.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 08, 2018, 07:28:05 PM
I have provided my proof of concept of using an OCX control to provide an intelligent GUI as a COM object.

I would be interested in how others feel about the concept and would you use it?
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 10, 2018, 01:37:26 AM
Once I am back into development, I'll certainly take a long, hard look.

It is certainly an area that interests me to no end.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 10, 2018, 08:30:26 AM
+1

Any others?

I'm trying to get Charles Pegge (Oxygen Basic author) to create a similar CallByName interface as what we have working with Script BASIC. It would be great to have a BASIC compiler support OCX forms (created with VB Classic or VB.NET) as well as having an interpretive solution.

I never did get a response to what BASIC languages support COM/OLE automation.  :(

Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 11, 2018, 01:30:17 AM
As to what BASICs support COM/OLE - I have no idea.

Most could, but how many do?
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 11, 2018, 10:58:26 AM
According to the hard core WinAPI coders, COM/OLE automation is for pussies. I on the other hand value my time and try to give my clients their money's worth by working on their requirements and less on pre-project framework creation.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 12, 2018, 01:32:44 AM
Hard Core Win/API coders are all known to be crazy  ;D

COM/OLE was originally designed to simplify inter-process communications. Why re-invent the wheel every time you want to do something - and then have to re-re-invent it when a new version of Windows does something different?

If it's a performance-critical application, I can see it, but for most users? A few milliseconds on a screen-load isn't even enough to focus on the next page of data input. We wait longer for a web page to load up.

Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 12, 2018, 08:40:16 AM
The VB6 OCX based Online Dictionary loads instantly. You would never know it's not a compiled application.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 14, 2018, 01:53:03 AM
Impressive - but when COM/OLE was first developed, machines were much slower.

Remember that a lot of software suffers from bloat - and saving a few clock cycles here and there on a few thousand program threads will take a program from glacial slowness to cold-rice-pudding.

Of course, there's also the Oooooh!  SHINY! NEW! effect that has developers running like lemmings toward the latest and greatest tool (.NET springs to mind here), regardless of whether it is a necessary change or not.

IMHO, COM/OLE was an excellent software device that was dropped for no good and enduring reason - it is more flexible in many ways than the more recent process interfacing API. Certainly, it is better encapsulated for use.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 14, 2018, 01:55:03 PM
It's going to be really hard for Microsoft to kill off COM/OLE automation as it is the skeleton of Office. People count on it gluing their world together.

VB6 may be unsupported but VBA is alive and well. COM/OLE automation is used extensively under VBA. (Excel, Word, Outlook, ..., QuickBooks desktop, Crystal Reports, the list goes on and on)

Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 15, 2018, 09:56:15 AM
I'm trying to make the OLD OCX a dual interface but unable to find the checkbox that does so. No luck in the project properties.

The Oxygen Basic DLLC extension module supports a COM direct interface. I'm trying to get the Online Dictionary example to work as a non-iDispatch automation server. I'm using DLLC to prototype the direct interface and once it works, a generic include/library for O2 can be created. (removing SB from the picture)

Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 17, 2018, 06:12:32 AM
I suspect that might only be available when you create an ActiveX DLL, as below
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 17, 2018, 06:31:46 AM
It is an ActiveX DLL. I think I need to import the typelib for v-table (dual interface) access.

From what I've read, v-table (direct)) rather than iDispatch automation is twice as fast.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 19, 2018, 07:58:21 PM
At this point due to the lack of interest, I'm going to move on with this for my own needs and stop trying to promote the concept to others. In most programmers minds VB6 is dead and COM/OLE is for those still using it in MS Office automation using VBA.

Thanks AlyssonR for taking the time to provide your feedback!
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 21, 2018, 09:48:21 AM
John,

Once you have this running to your satisfaction, I would be interested in seeing how it works since the process of generating forms from SB, or any other non-VB IDE is, frankly, painful in the extreme.

I'm not ready to start front-end development, but I'm still in the middle of building my back-end software.

Hell, I've even been contemplating writing a widget terminal that would allow the fast generation of forms from a simple set of commands and to then talk to the back-end relatively painlessly.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 21, 2018, 11:30:38 AM
Quote
Once you have this running to your satisfaction, I would be interested in seeing how it works since the process of generating forms from SB, or any other non-VB IDE is, frankly, painful in the extreme.

The Online Dictionary proof of concept satitified all my requirements and I'm activity moving forward with the concept. I also plan to show direct v-table access as well using the DLLC extension modue.

I'm trying to get the thinBasic community to look at the concept. I believe Eros has COM/OLE automation as a core language feature which would make this a natural for thinBasic.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 21, 2018, 11:07:36 PM
Quote
Hell, I've even been contemplating writing a widget terminal that would allow the fast generation of forms from a simple set of commands and to then talk to the back-end relatively painlessly.

I hate web UI and graphics work. It's not my strong point. VB6 is my answer to Windows UI based programming. Where I excel is integration and migration tasks.

Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 22, 2018, 02:02:02 AM
I detest web UI (in fact any UI) programming with a vengeance, and VB6 has been my go-to for anything that requires interaction up to now - but I want to go cross-platform.

What I want is to be able to put all of the UI into a single program that can then be used by any suitable back-end application without having to use AJAX, HTML forms and such like. Much as a VB program can provide a front-end to other stuff.

The hassle of building user interfaces is a steep learning curve that I feel ill-equipped to deal with - and being able to send what amounts to the VB form building parameters to a front end over what is effectively a serial link (virtual or physical) appeals to me immensely. A serial link, I might add, that maintains stateful information across the link without the Hell-That-Is-Ajax.

That, and I really am too long in the tooth to start wrapping my mind around Java.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on September 27, 2018, 09:56:58 PM
I forgot to mention that VB6 OCX form DLLs using the VBCCR common controls replacement OCX, auto registers the OCX. (no need for regsvr32)
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AlyssonR on September 28, 2018, 01:32:45 AM
Now that, I was aware of.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on October 03, 2018, 10:22:51 PM
Here are a few links on COM and OLE automation courtesy of Eros.

I'm still trying to get to the bottom of how to use a VB6 OCX DLL in vtable mode rather than iDisptch.

Quote
V-table Interface

An interface definition has TypeKind = TKIND_INTERFACE. An interface is a set of pure virtual functions and an empty set of data members. If a type description contains any virtual functions, then the pointer to the VTBL is the first 4 bytes of the instance.

The type information fully describes the member functions in the VTBL, including parameter names and types and function return types. It may inherit from no more than one other interface.

With interfaces and dispinterfaces, all members should have different names, except the accessor functions of properties. For property functions having the same name, the documentation string and Help context should be set for only one of the functions (because they define the same property conceptually).


IDispatch Interface

These include objects (TypeKind = TKIND_DISPATCH) that support the IDispatch() interface with a specification of the dispatch data members (such as properties) and methods supported through the object's Invoke implementation. All members of the dispinterface should have different IDs, except for the accessor functions of properties.


Dual Interface

Dual interfaces (dual) have two different type descriptions for the same interface. The TKIND_INTERFACE type description describes the interface as a standard Component Object Model (COM) interface. The TKIND_DISPATCH type description describes the interface as a standard dispatch interface. The lcid and retval parameters, and the HRESULT return types are removed, and the return type of the member is specified to be the same type as the retval parameter.

By default, the TYPEKIND enumeration for a dual interface is TKIND_DISPATCH. Tools that bind to interfaces should check the type flags for TYPEFLAG_FDUAL. If this flag is set, the TKIND_INTERFACE type description is available through a call to ITypeInfo::GetRefTypeOfImplType() with an index of -1, followed by a call to ITypeInfo::GetRefTypeInfo().

Title: Re: Script BASIC - VB6 OCX Forms - VBCCR 1.6
Post by: John on October 09, 2018, 04:03:37 PM
Krool has release his 1.6 VBCCR common controls VB6 replacement OCX.

Release Notice (http://www.vbforums.com/showthread.php?698563-CommonControls-(Replacement-of-the-MS-common-controls))

Quote from: Krool
I agree. VBCCR should not be the solution for everything. It is intended to get rid of the old OCX dependencies and to support Unicode. (and more handy, bugfixes, features etc..)
If new "modern" UI is needed then another alternative approach is better. (without comct32.dll)

Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on October 14, 2018, 06:22:20 PM
The best example of a VB6 application interacting with the Script BASIC embedded, extension and preprocessor APIs is the SB IDE/Debugger for Windows 32 bit.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on January 13, 2019, 10:56:15 PM
I'm really disappointed that this concept of using modern OCX form controls and calling back to Script BASIC functions and subs didn't create any excitement. VB6 was a favorite among the 32 bit developer world of COM OLE automation.

Did I waste my time with this?
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on January 14, 2019, 07:29:02 PM
I'm considering putting the Windows version of Script BASIC on the shelf until I have time to be a proper maintainer. I'm still on the fence if 32 bit is still worth investing in.

I'm curious how popular VB.Net is today and are companies developing custom apps like they did with Classic?


Title: Re: Script BASIC - VB6 OCX Forms
Post by: AIR on January 14, 2019, 10:51:07 PM
I'm considering putting the Windows version of Script BASIC on the shelf until I have time to be a proper maintainer. I'm still on the fence if 32 bit is still worth investing in.

I'm curious how popular VB.Net is today and are companies developing custom apps like they did with Classic?

At one point, VB.net was popular in the corporate world because of ASP.net, but with the emergence of Node, Docker, etc, Enterprise devs have moved away from it (based on what I've seen, your experience may be different).

At work, we had an important legacy VB6/SQL application that had major issues working under Win 10 (My team and I came up with various workarounds, but with each security update that MS released we had to come up with new workarounds.  The main issue was 32bit OCX).  The decision was made to re-write it, and VB.net was never a real contender.  The application ended up being redone in C#.

As to 32 vs 64bit:  My choice would be 64bit.  If we were talking about a compiler that emits ASM, I would say stay 32bit (64bit ASM is a very different beast) but for an interpreter that supports interfacing with external libraries, 64bit is the way to go since it's getting harder to find up to date 32bit dll's for some major libraries.

Just my opinions...

AIR.
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on January 15, 2019, 10:47:49 AM
Curious, what OCX was causing your problem?
Title: Re: Script BASIC - VB6 OCX Forms
Post by: AIR on January 15, 2019, 12:31:17 PM
It was a 3rd party OCX that would generate reports on screen and optionally in PDF format, and an OCX that handled data updates.

Interestingly, PowerBuilder (Remember that?) apps written in the late 90's still work without issues, with just a single minor custom PowerBuilder dll update.  Go figure...
Title: Re: Script BASIC - VB6 OCX Forms
Post by: John on January 15, 2019, 12:59:56 PM
I highly recommend Krool's CCR OCX. I haven't seen any issues with VB6 runtime on Windows 10 using Krool's OCX. I was able to get VB6 IDE running on 10 with current theming. The only issue is you need to run it as ADMIN or turn off UNC. Form what I've heard VB6 runtime will be supported until 2025.