Author Topic: O2 SB Embed  (Read 1610 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: O2 SB Embed
« Reply #15 on: March 30, 2021, 03:50:41 AM »
It looks like my O2 COM/OLE automation insurance may pay off after all.  8)

Code: OxygenBasic
  1. ' Excel COM / OLE Example
  2.  
  3. % filename "o2excel.exe"
  4. includepath "$/inc/"
  5. include "RTL32.inc"
  6. include "sbembed.inc"
  7. #console
  8. uses console
  9.  
  10. sys pProgram, fnsn
  11. sbData *arg
  12. sbData *argr
  13. string cr = chr(13, 10)
  14. string src = "IMPORT sbembed.sbi" + cr
  15.  
  16. pProgram = scriba_new(@newmem, @freemem)
  17. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
  18. scriba_SetFileName(pProgram, "none")
  19. scriba_LoadProgramString(pProgram, src, len(src))
  20. scriba_Run(pProgram, "")
  21.  
  22. @argr = scriba_NewSbArgs(pProgram,"u")
  23. fnsn = scriba_LookupFunctionByName(pProgram, "main::sb_create")
  24. @arg = scriba_NewSbArgs(pProgram, "s", "Excel.Application")
  25. scriba_CallArgEx(pProgram, fnsn, argr, 1, arg)
  26. print "Excel Object: " + str(argr.lng) + cr
  27.  
  28. scriba_DestroySbArgs(pProgram, arg, 1)
  29. scriba_DestroySbArgs(pProgram, argr, 1)
  30. scriba_destroy(pProgram)
  31.  


sbembed.sbi (added)
Code: Script BASIC
  1. DECLARE SUB CREATE ALIAS "CreateObject" LIB "com"
  2.  
  3. ' COM - CREATE
  4. FUNCTION sb_create(obj_name)
  5.   obj = CREATE(8, obj_name)
  6.   sb_create = obj
  7. END FUNCTION
  8.  


C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>o2excel
Excel Object: 7003868

C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>



It's late (into the wee morning) and I'll try to get the complete Excel example working when I wake up.


JRS

  • Guest
Re: O2 SB Embed
« Reply #16 on: March 30, 2021, 06:54:48 PM »
I was able to get the O2 Excel example to work.

Code: OxygenBasic
  1. ' O2 Excel Example
  2.  
  3. % filename "o2excel.exe"
  4. includepath "$/inc/"
  5. include "RTL32.inc"
  6. include "sbembed.inc"
  7. #console
  8. uses console
  9.  
  10. sys pProgram
  11. sbData *arg
  12. sbData *argr
  13. string cr = chr(13,10)
  14. int i, j
  15. int sb_call = 1
  16. int sb_get  = 2
  17. int sb_let  = 4
  18. int sb_set  = 8
  19. string src = "IMPORT sbembed.sbi" + cr
  20.  
  21. pProgram = scriba_new(@newmem, @freemem)
  22. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
  23. scriba_SetFileName(pProgram, "none")
  24. scriba_LoadProgramString(pProgram, src, len(src))
  25. scriba_Run(pProgram, "")
  26.  
  27. @argr = scriba_NewSbArgs(pProgram,"u")
  28. sys fn1 = scriba_LookupFunctionByName(pProgram, "main::sb_create")
  29. sys fn2 = scriba_LookupFunctionByName(pProgram, "main::sb_cbn")
  30. sys fn3 = scriba_LookupFunctionByName(pProgram, "main::sb_release")
  31.  
  32. @arg = scriba_NewSbArgs(pProgram, "s", "Excel.Application")
  33. scriba_CallArgEx(pProgram, fn1, argr, 1, arg)
  34. sys oexcel = argr.lng
  35. @arg = scriba_NewSbArgs(pProgram, "i s i", oexcel, "Workbooks", sb_get)
  36. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  37. sys oworkbook = argr.lng
  38. @arg = scriba_NewSbArgs(pProgram, "i s i", oWorkBook, "Add", sb_call)
  39. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  40. sys oExcelWorkbook = argr.lng
  41. @arg = scriba_NewSbArgs(pProgram, "i s i i", oExcelWorkbook, "Worksheets", sb_get, 1)
  42. scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  43. sys oExcelSheet = argr.lng
  44. sys ocell
  45. for i = 1 to 10
  46.   for j = 1 to 10
  47.     @arg = scriba_NewSbArgs(pProgram, "i s i i i", oExcelSheet, "Cells", sb_get, i, j)
  48.     scriba_CallArgEx(pProgram, fn2, argr, 5, arg)
  49.     ocell = argr.lng
  50.     @arg = scriba_NewSbArgs(pProgram, "i s i s",  oCell, "Value", sb_let, "test-" + str(i) + "-" + str(j))
  51.     scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  52.     @arg = scriba_NewSbArgs(pProgram, "i", oCell)
  53.     scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  54.   next j
  55. next i
  56. @arg = scriba_NewSbArgs(pProgram, "i s i s", oExcelWorkbook, "SaveAs", sb_call, "C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb\O2_Excel.xls")
  57. scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  58. @arg = scriba_NewSbArgs(pProgram, "i s i", oExcelWorkbook, "Close", sb_call)
  59. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  60. @arg = scriba_NewSbArgs(pProgram, "i s i", oexcel, "Quit", sb_call)
  61. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  62.  
  63. print "Spreadsheet Created" + cr
  64.  
  65. @arg = scriba_NewSbArgs(pProgram, "i", oExcelSheet)
  66. scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  67. @arg = scriba_NewSbArgs(pProgram, "i", oExcelWorkbook)
  68. scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  69. @arg = scriba_NewSbArgs(pProgram, "i", oworkbook)
  70. scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  71. @arg = scriba_NewSbArgs(pProgram, "i", oexcel)
  72. scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  73.  
  74. scriba_DestroySbArgs(pProgram, arg, 5)
  75. scriba_DestroySbArgs(pProgram, argr, 1)
  76. scriba_destroy(pProgram)
  77.  

This is the current status of the sbembed.sbi ScriptBasic IMPORT file.

Code: Script BASIC
  1. ' sbembed.sbi - ScriptBasic Embedded Function Wrappers
  2.  
  3. DECLARE COMMAND ArrayToXML ALIAS "xmlserialize" LIB "t"
  4. DECLARE SUB CREATE ALIAS "CreateObject" LIB "com"
  5. DECLARE SUB CBN ALIAS "CallByName" LIB "com"
  6. DECLARE SUB RELEASE ALIAS "ReleaseObject" LIB "com"
  7.  
  8. GLOBAL CONST sb_call = 1
  9. GLOBAL CONST sb_get  = 2
  10. GLOBAL CONST sb_let  = 4
  11. GLOBAL CONST sb_set  = 8
  12.  
  13. ' REPLACE
  14. FUNCTION sb_replace(basestr, searchstr, replacestr, occurances, startpos)
  15.   sb_replace = REPLACE(basestr, searchstr, replacestr, occurances, startpos)
  16. END FUNCTION
  17.  
  18. ' LIKE
  19. FUNCTION sb_like(basestr, mask)
  20.   ok = basestr LIKE mask
  21.   sb_like = ok
  22. END FUNCTION
  23.  
  24. ' MATCH
  25. FUNCTION sb_match(segment)
  26.   sb_match = JOKER(segment)
  27. END FUNCTION
  28.  
  29. ' SPLITA
  30. FUNCTION sb_splita(basestr, splitby)
  31.   SPLITA basestr BY splitby TO splitarray
  32.   sb_splita = ArrayToXML(splitarray)
  33. END FUNCTION  
  34.  
  35. ' COM - CREATE
  36. FUNCTION sb_create(obj_name)
  37.   obj = CREATE(8, obj_name)
  38.   sb_create = obj
  39. END FUNCTION
  40.  
  41. ' COM - CBN (CallByName)
  42. FUNCTION sb_cbn(obj, funcname, callypye, arg1, arg2, arg3, arg4)
  43.   IF arg1 = undef THEN
  44.     sb_cbn = CBN(obj, funcname, callypye)
  45.     GOTO Done
  46.   ELSE IF arg2 = undef THEN
  47.     sb_cbn = CBN(obj, funcname, callypye, arg1)
  48.     GOTO Done
  49.   ELSE IF arg3 = undef THEN
  50.     sb_cbn = CBN(obj, funcname, callypye, arg1, arg2)
  51.     GOTO Done
  52.   ELSE IF arg4 = undef THEN
  53.     sb_cbn = CBN(obj, funcname, callypye, arg1, arg2, arg3)
  54.     GOTO Done
  55.   ELSE IF arg4 <> undef THEN
  56.     sb_cbn = CBN(obj, funcname, callypye, arg1, arg2, arg3, arg4)
  57.   END IF
  58.   Done:
  59. END FUNCTION
  60.  
  61. ' COM - RELEASE
  62. FUNCTION sb_release(obj)
  63.   ok = RELEASE(obj)
  64.   sb_release = ok
  65. END FUNCTION
  66.  

This was my ScriptBasic test program using the sbembed.sbi IMPORT before writing the O2 version.

Code: Script BASIC
  1. ' Test COM
  2.  
  3. IMPORT sbembed.sbi
  4.  
  5. oexcel = sb_create("Excel.Application")
  6. oworkbook = sb_cbn(oexcel, "Workbooks", sb_get)
  7. oExcelWorkbook = sb_cbn(oWorkBook, "Add", sb_call)
  8. oExcelSheet = sb_cbn(oExcelWorkbook, "Worksheets", sb_get, 1)
  9. FOR i=1 TO 10
  10.   FOR j=1 TO 10
  11.     oCell = sb_cbn(oExcelSheet, "Cells", sb_get, i, j)
  12.     sb_cbn(oCell, "Value", sb_let, "test-" & i & "-" & j)
  13.     sb_release(oCell)
  14.   NEXT
  15. NEXT
  16. sb_cbn(oExcelWorkbook, "SaveAs", sb_call, "C:\\ScriptBASIC\\examples\\O2_Excel.xls")
  17. sb_cbn(oExcelWorkbook, "Close", sb_call)
  18. sb_cbn(oexcel, "Quit", sb_call)
  19.  
  20. PRINT "Spreadsheet Created\n"
  21.  
  22. sb_release(oExcelSheet)
  23. sb_release(oExcelWorkbook)
  24. sb_release(oworkbook)
  25. sb_release(oexcel)
  26.  


C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>o2excel
Spreadsheet Created

C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>
« Last Edit: April 02, 2021, 11:10:10 AM by John »

JRS

  • Guest
Re: O2 SB Embed
« Reply #17 on: March 31, 2021, 12:03:00 AM »
Charles,

Since O2 is calling an instance of SB, I should be able to use my existing code in VB6 to callback to SB functions. Within those function I should be able to do COM calls.

All theory at this point. I'll give it a try in the morning.

JRS

  • Guest
Re: O2 SB Embed
« Reply #18 on: March 31, 2021, 11:34:19 AM »
The Sage BOI get first customer example seems to work.

Code: OxygenBasic
  1. ' O2 Sage BOI Example                                                  
  2.                                                                    
  3. % filename "sageboi.exe"                                            
  4. includepath "$/inc/"                                                
  5. include "RTL32.inc"                                                
  6. include "sbembed.inc"                                              
  7. #console                                                            
  8. uses console                                                        
  9.                                                                    
  10. sys pProgram                                                        
  11. sbData *arg                                                        
  12. sbData *argr                                                        
  13. string cr = chr(13,10)                                              
  14. int sb_call = 1                                                    
  15. int sb_get  = 2                                                    
  16. int sb_let  = 4                                                    
  17. int sb_set  = 8                                                    
  18. string src = "IMPORT sbembed.sbi" + cr                              
  19.                                                                    
  20. pProgram = scriba_new(@newmem, @freemem)                            
  21. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")        
  22. scriba_SetFileName(pProgram, "none")                                
  23. scriba_LoadProgramString(pProgram, src, len(src))                  
  24. scriba_Run(pProgram, "")                                            
  25.                                                                    
  26. @argr = scriba_NewSbArgs(pProgram,"u")                              
  27. sys fn1 = scriba_LookupFunctionByName(pProgram, "main::sb_create")  
  28. sys fn2 = scriba_LookupFunctionByName(pProgram, "main::sb_cbn")    
  29. sys fn3 = scriba_LookupFunctionByName(pProgram, "main::sb_release")
  30.  
  31. @arg = scriba_NewSbArgs(pProgram, "s", "ProvideX.Script")
  32. scriba_CallArgEx(pProgram, fn1, argr, 1, arg)
  33. sys oscript = argr.lng
  34. @arg = scriba_NewSbArgs(pProgram, "i s i s", oscript, "Init", sb_call, "C:\Sage\Sage 100 Standard\MAS90\Home")
  35. scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  36. @arg = scriba_NewSbArgs(pProgram, "i s i s", oscript, "NewObject", sb_set, "SY_Session")
  37. scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  38. sys osession = argr.lng
  39. @arg = scriba_NewSbArgs(pProgram, "i s i s", osession, "nSetUser", sb_call, "js", "MY_PASSWORD")
  40. scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  41. @arg = scriba_NewSbArgs(pProgram, "i s i s", osession, "nsetcompany", sb_call, "ABC")
  42. scriba_CallArgEx(pProgram, fn2, argr, 4, arg)
  43. @arg = scriba_NewSbArgs(pProgram, "i s i s s", osession, "nSetDate", sb_call, "A/R", "20210331")
  44. scriba_CallArgEx(pProgram, fn2, argr, 5, arg)
  45. @arg = scriba_NewSbArgs(pProgram, "i s i s i", oscript, "NewObject", sb_set, "AR_Customer_svc", osession)
  46. scriba_CallArgEx(pProgram, fn2, argr, 5, arg)
  47. sys ocust = argr.lng
  48. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "nMoveFirst", sb_call)
  49. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  50. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sCustomerNo", sb_get)
  51. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  52. string CustomerNo = argr.str
  53. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sCustomerName", sb_get)
  54. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  55. string CustomerName = argr.str
  56. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sCity", sb_get)
  57. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  58. string City = argr.str
  59. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sState", sb_get)
  60. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  61. string State = argr.str
  62. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "sTelephoneNo", sb_get)
  63. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  64. string TelephoneNo = argr.str
  65. @arg = scriba_NewSbArgs(pProgram, "i s i", ocust, "DropObject", sb_call)
  66. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  67. @arg = scriba_NewSbArgs(pProgram, "i s i", osession, "DropObject", sb_call)
  68. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  69. @arg = scriba_NewSbArgs(pProgram, "i", oscript)
  70. scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  71.  
  72. print "Customer:  " + CustomerNo " - " + CustomerName + " - " + City + " - " + State + " - " + TelephoneNo + cr
  73.  
  74. scriba_DestroySbArgs(pProgram, arg, 5)
  75. scriba_DestroySbArgs(pProgram, argr, 1)
  76. scriba_destroy(pProgram)
  77.  


C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>sageboi
Customer:  ABF - American Business Futures - Milwaukee - WI - (414) 555-4787

C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>

« Last Edit: March 31, 2021, 12:59:39 PM by John »

JRS

  • Guest
Re: O2 SB Embed
« Reply #19 on: March 31, 2021, 03:59:29 PM »
Charles,

I"ve asked this before but is there a way I can call back to the O2 executable that started a VB6 OCX form? I think calling back to SB is going to work but O2 is preferable.
« Last Edit: March 31, 2021, 04:06:16 PM by John »

JRS

  • Guest
Re: O2 SB Embed
« Reply #20 on: March 31, 2021, 11:53:05 PM »
This is an example of getting and setting ScriptBasic variables from O2.

testvars.sb
Code: Script BASIC
  1. a = 1      
  2. b = .2    
  3. c = "Three"
  4.  

Code: Text
  1. % filename "getsetvars.exe"                                            
  2. includepath "$/inc/"                                                
  3. include "RTL32.inc"                                                
  4. include "sbembed.inc"                                              
  5. #console                                                            
  6. uses console                                                        
  7.                                                                    
  8. sys pProgram                                                        
  9. sbData *arg                                                                                                                
  10. string cr = chr(13,10)
  11.  
  12. string src = `IMPORT "testvars.sb"` + cr                              
  13.                                                                    
  14. pProgram = scriba_new(@newmem, @freemem)                            
  15. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")        
  16. scriba_SetFileName(pProgram, "none")                                
  17. scriba_LoadProgramString(pProgram, src, len(src))                  
  18. scriba_Run(pProgram, "")                                            
  19.                                                                    
  20. sys v_a = scriba_LookupVariableByName(pProgram, "main::a")
  21. sys v_b = scriba_LookupVariableByName(pProgram, "main::b")
  22. sys v_c = scriba_LookupVariableByName(pProgram, "main::c")
  23.  
  24. ' Get defined variable values
  25.  
  26. scriba_GetVariable(pProgram, v_a, @@arg)
  27. print arg.lng + cr
  28. scriba_GetVariable(pProgram, v_b, @@arg)
  29. print arg.dbl + cr
  30. scriba_GetVariable(pProgram, v_c, @@arg)
  31. print arg.str + cr + cr
  32.  
  33. ' Set variable values
  34.  
  35. scriba_SetVariable(pProgram, v_a, SBT_LONG, 101, 0.0, "", 0)
  36. scriba_SetVariable(pProgram, v_b, SBT_DOUBLE, 0, 2.2, "", 0)
  37. scriba_SetVariable(pProgram, v_c, SBT_STRING, 0, 0.0, "Thirty Three", 12)
  38.  
  39. ' Get changed variable values
  40.  
  41. scriba_GetVariable(pProgram, v_a, @@arg)
  42. print arg.lng + cr
  43. scriba_GetVariable(pProgram, v_b, @@arg)
  44. print arg.dbl + cr
  45. scriba_GetVariable(pProgram, v_c, @@arg)
  46. print arg.str + cr
  47.  
  48. scriba_DestroySbArgs(pProgram, arg, 1)
  49. scriba_destroy(pProgram)
  50.  


C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>getsetvars
1
0.2
Three

101
2.2000000000000002
Thirty Three

C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>

« Last Edit: April 01, 2021, 02:03:35 AM by John »

JRS

  • Guest
Re: O2 SB Embed
« Reply #21 on: April 01, 2021, 03:51:28 PM »
This is an example of O2 using a VB6 OCX form as a login UI, calling back to ScriptBasic to set the userid global variable which O2 retrieves after the form closes.

This wraps up my ScriptBasic Embedding introduction with Oxygen Basic. I hope you found it informative and maybe useful. Comments welcome.

Code: Text
  1. ' O2 VB Login Form Example
  2.  
  3. % filename "o2vblogin.exe"                                            
  4. includepath "$/inc/"                                                
  5. include "RTL32.inc"                                                
  6. include "sbembed.inc"                                              
  7. #console                                                            
  8. uses console                                                        
  9.                                                                    
  10. sys pProgram                                                        
  11. sbData *arg                                                        
  12. sbData *argr                                                        
  13. string cr = chr(13,10)                                              
  14.  
  15. int sb_call = 1                                                    
  16. int sb_get  = 2                                                    
  17. int sb_let  = 4                                                    
  18. int sb_set  = 8                                                    
  19. string src = "IMPORT sbembed.sbi" + cr + _
  20.              `IMPORT "callback.sb"` + cr                            
  21.                                                                    
  22. pProgram = scriba_new(@newmem, @freemem)                            
  23. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")        
  24. scriba_SetFileName(pProgram, "none")                                
  25. scriba_LoadProgramString(pProgram, src, len(src))                  
  26. scriba_Run(pProgram, "")                                            
  27.                                                                    
  28. @argr = scriba_NewSbArgs(pProgram,"u")                              
  29. sys fn1 = scriba_LookupFunctionByName(pProgram, "main::sb_create")  
  30. sys fn2 = scriba_LookupFunctionByName(pProgram, "main::sb_cbn")    
  31. sys fn3 = scriba_LookupFunctionByName(pProgram, "main::sb_release")
  32. sys fn4 = scriba_LookupFunctionByName(pProgram, "main::set_callback")
  33.  
  34. @arg = scriba_NewSbArgs(pProgram, "s", "O2VB.Login")
  35. scriba_CallArgEx(pProgram, fn1, argr, 1, arg)
  36. sys vbobj = argr.lng
  37. @arg = scriba_NewSbArgs(pProgram, "i", vbobj)
  38. scriba_CallArgEx(pProgram, fn4, argr, 1, arg)
  39. @arg = scriba_NewSbArgs(pProgram, "i s i", vbobj, "ShowOCXForm", sb_call)
  40. scriba_CallArgEx(pProgram, fn2, argr, 3, arg)
  41. sys ufunc = scriba_LookupVariableByName(pProgram, "main::userid")
  42. scriba_GetVariable(pProgram, ufunc, @@arg)
  43. print arg.str + cr
  44. @arg = scriba_NewSbArgs(pProgram, "i", vbobj)
  45. scriba_CallArgEx(pProgram, fn3, argr, 1, arg)
  46.  
  47. scriba_DestroySbArgs(pProgram, arg, 3)
  48. scriba_DestroySbArgs(pProgram, argr, 1)
  49. scriba_destroy(pProgram)
  50.  

callback.sb
Code: Script BASIC
  1. ' O2 SB Callback Functions
  2.  
  3. FUNCTION OK_Button_Click(user)
  4.   userid = user
  5.   OK_Button_Click = TRUE
  6. END FUNCTION
  7.  
  8. FUNCTION Set_Callback(vbobj)
  9.   oCollection = CBN(vbobj, "CallBackHandlers", sb_get)
  10.   CBN(oCollection, "Add", sb_call, ADDRESS(OK_Button_Click()), "Login_Form.OK_Button_Click")
  11. END FUNCTION
  12.  

VB6 Login Form
Code: Visual Basic
  1. Option Explicit
  2.  
  3. Private Declare Function ext_SBCallBack Lib "COM.dll" Alias "SBCallBack" (ByVal EntryPoint As Long, ByVal arg As Long) As Long
  4. Private Declare Function ext_SBCallBackEx Lib "COM.dll" Alias "SBCallBackEx" (ByVal EntryPoint As Long, ByRef v As Variant) As Variant
  5.  
  6. Private m_owner As Login
  7. Public LoginSucceeded As Boolean
  8.  
  9. Function ShowMain_Form(owner As Login) As Long
  10.     On Error Resume Next
  11.     Set m_owner = owner
  12.     Me.Show 1
  13.     Set m_owner = Nothing
  14.     ShowMain_Form = 0
  15.     Unload Me
  16. End Function
  17.  
  18. Private Function TriggerCallBack(nodeID As Long, argValue As Long) As Long
  19.     TriggerCallBack = ext_SBCallBack(nodeID, argValue)
  20. End Function
  21.  
  22. Private Function TriggerCallBackEx(nodeID As Long, v() As Variant)
  23.     TriggerCallBackEx = ext_SBCallBackEx(nodeID, v)
  24. End Function
  25.  
  26. Private Sub Cancel_Button_Click()
  27.     LoginSucceeded = False
  28.     Me.Hide
  29. End Sub
  30.  
  31. Private Sub OK_Button_Click()
  32.     Dim nodeID As Long
  33.     Dim arg(0) As Variant
  34.     Dim rtnVal As Long
  35.     If Password_Text = "OxygenBasic" Then
  36.         LoginSucceeded = True
  37.         nodeID = m_owner.CallBackHandlers("Login_Form.OK_Button_Click")
  38.         arg(0) = Login_Form.User_Text
  39.         rtnVal = TriggerCallBackEx(nodeID, arg)
  40.         Me.Hide
  41.     Else
  42.         MsgBox "Invalid Password, try again!", , "Login"
  43.         Password_Text.SetFocus
  44.         SendKeys "{Home}+{End}"
  45.     End If
  46. End Sub
  47.  

VB6 Login Class
Code: Visual Basic
  1. Public CallBackHandlers As New Collection
  2.  
  3. Public Function ShowOCXForm() As Long
  4.     ShowOCXForm = Login_Form.ShowMain_Form(Me)
  5. End Function
  6.  


C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>o2vblogin
John

C:\OxygenBasic\projectsC\ScriptBasic\EmbedSb>

« Last Edit: April 02, 2021, 09:27:05 PM by John »