-
Re: The 1001 questions about vbRichClient5 (2020-04-17)
Hi Olaf, cDynFactory works very well now. Thank you so much.
I still have a few questions:
(1) Is it possible to implement dynamic properties names containing spaces or special characters (similar to keywords in cCollection), for example:
Code:
Dim oD As Object
Set oD = DynFactory.NewDynObj
oD ["AA BB"] = "123456"
'Or'
Set oD ["AA BB"] = New Class1
(2) Is it possible to associate cDynFactory with cCollection so that the dynamic properties of cDynFactory are like keywords of cCollection.
(3) Is there a limit to the number of dynamic properties of cDynFactory? Can cDynFactory have as many dynamic properties as cCollection?
(4) If cDynFactory is heavily used, does cDynFactory occupy more or less memory than cCollection? Thanks.
-
Re: The 1001 questions about vbRichClient5 (2020-04-17)
Quote:
Originally Posted by
dreammanor
Hi Olaf, cDynFactory works very well now. Thank you so much.
I still have a few questions:
(1) Is it possible to implement dynamic properties names containing spaces or special characters (similar to keywords in cCollection), for example:
(2) Is it possible to associate cDynFactory with cCollection so that the dynamic properties of cDynFactory are like keywords of cCollection.
(3) Is there a limit to the number of dynamic properties of cDynFactory? Can cDynFactory have as many dynamic properties as cCollection?
(4) If cDynFactory is heavily used, does cDynFactory occupy more or less memory than cCollection? Thanks.
Are you sure, you want all this in an Object with Dynamic Properties?
Seems to me, that you're better advised, to use the cCollection (or an adapted cHashD) for all this.
E.g. when you currently write:
DynObj.SomeProp
you can (using a VB- or cCollection) write something equally short:
SomeCol!SomeProp
... using the Bang-Operator instead of a Dot.
And for "Spaces in Keys" the bang-operator also has support:
SomeCol![Some Prop]
To adapt cHashD to that behaviour, you will only have to make its Item-Prop the Default-Prop.
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-17)
Hi Olaf, my idea is this:
(1) Added a member variable "Private m_Data As cCollection" in cDynFactory
(2) Map dynamic properties to the keywords of m_Data
=======================================
There are two minor problems with using the bang-operator:
(1) The characters in the bang-operator will affect the case of all variables in the project, for example:
SomeCol![hello andy] will make all Hello variables in the project become hello, all Andy variables becomes andy.
(2) Before using the bang-operators on the properties of cCollection or cHashD, these properties must be initialized first(give each property an initial value), for example:
Code:
'--- Error ---
SomeCol!SomeProp= 123
'--- Correct ----
SomeCol.Prop("SomeProp") = 123
MsgBox SomeCol!SomeProp
-
Re: The 1001 questions about vbRichClient5 (2020-04-17)
Quote:
Originally Posted by
dreammanor
(2) Before using the bang-operators on the properties of cCollection or cHashD, these properties must be initialized first(give each property an initial value), for
Since the code for or cHashD is open, you can adjust the:
- Item Let/Set Prop
- Item Get Prop
Routines to your liking...
e.g.:
- making 'Item' the Default-Prop
- but also with regards to autocreating entries in Let/Set (in case PropKey doesn't exist)
- and also what to return, when the Get-Prop doesn't find an existing "PropKey"
In the cCollection I don't want to change the current behaviour,
because of the risk of breaking someone elses Code, which relies on the current Error-Throwing.
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-17)
Yes, I took a similar approach to what you said. I encapsulated cCollection again and set Item as the default-prop. But the default-prop can only be the first-level property, for example: SomeCol("SomeProp") is valid, but ParentCol.SomeCol("SomeProp") will be wrong.
But it doesn't matter, I've migrated the development environment from XP to Win10 (instead of Win7 as mentioned earlier). Now I don't need to translate JavaScript code into VB6 code. I'll use UglifyJS directly in VB6 on Win10 to compress the JS code, but this solution is not perfect, because UglifyJS still cannot recognize the new JS syntax (such as "let") in JScript9, and RegExp in JScript9 cannot support the Unlicode parameter "/u".
Of course, if cDynFactory could be combined with cCollection, it's still a wondeful thing.
-
Qustion 046: How to make RC5.WebServer only process the data of its own window?
Qustion 046: How to make RC5.WebServer only process the data of its own window?
Both RC5.WebServer in Form1 and Form2 are listening on "127.0.0.1: 8282", how to make ws_ProcessRequest in Form1 only handle DoSomething_01, and ws_ProcessRequest in Form2 only handle DoSomething_02?
Or, is it possible to simulate the use of Web-APIs to process the data in Form1 and Form2 separately? Thanks!
Form1
Code:
Private Sub Form_Load()
Set ws = New_c.WebServer
ws.Listen App.Path, "127.0.0.1", 8282
End Sub
Private Sub ws_ProcessRequest(Request As vbRichClient5.cWebRequest)
'DoSomething_01
End Sub
Form2
Code:
Private Sub Form_Load()
Set ws = New_c.WebServer
ws.Listen App.Path, "127.0.0.1", 8282
End Sub
Private Sub ws_ProcessRequest(Request As vbRichClient5.cWebRequest)
'DoSomething_02
End Sub
Note:
Form1 and Form2 may be loaded sequentially or simultaneously.
-
Re: Qustion 046: How to make RC5.WebServer only process the data of its own window?
Quote:
Originally Posted by
dreammanor
Qustion 046: How to make RC5.WebServer only process the data of its own window?
Both RC5.WebServer in Form1 and Form2 are listening on "127.0.0.1: 8282", how to make
ws_ProcessRequest in Form1 only handle
DoSomething_01, and ws_ProcessRequest in Form2 only handle
DoSomething_02?
Or, is it possible to simulate the use of Web-APIs to process the data in Form1 and Form2 separately? Thanks!
Form1
Code:
Private Sub Form_Load()
Set ws = New_c.WebServer
ws.Listen App.Path, "127.0.0.1", 8282
End Sub
Private Sub ws_ProcessRequest(Request As vbRichClient5.cWebRequest)
'DoSomething_01
End Sub
Form2
Code:
Private Sub Form_Load()
Set ws = New_c.WebServer
ws.Listen App.Path, "127.0.0.1", 8282
End Sub
Private Sub ws_ProcessRequest(Request As vbRichClient5.cWebRequest)
'DoSomething_02
End Sub
Note:
Form1 and Form2 may be loaded sequentially or simultaneously.
Either make the separate ws-instances (which are currently "per Form") listen on different Ports,
or just wrap the ws - Object in a separate Class (e.g. cSharedServer)...
From within cSharedServer you could then delegate to (Public Boolean-returning Functions in) as many Form-Instances as you like.
e.g. (ws_event-handler within cSharedServer):
Code:
Private Sub ws_ProcessRequest(Request As vbRichClient5.cWebRequest)
If Form1.HandleRequest(Request) Then Exit Sub
If Form2.HandleRequest(Request) Then Exit Sub
'... a.s.o.
End Sub
HTH
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Very good suggestion, thank you very much, Olaf.
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Hi Olaf, I found a phenomenon:
In VB6 IDE, if RC5.Subclass or vbWidgets-related code is used in the VB6-Forms, after the VB6-Forms exit and return to design mode, at this time, if I open the VB6 Object-Browser window and drag the sub-window dividing line with the mouse, then the mouse is always in the "splitting-dragging" state, and cannot exit from the Object-Browser window, resulting in the entire VB6 IDE windows being frozen.
This phenomenon has occurred many times.
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Quote:
Originally Posted by
dreammanor
Hi Olaf, I found a phenomenon:
In VB6 IDE, if RC5.Subclass or vbWidgets-related code is used in the VB6-Forms, after the VB6-Forms exit and return to design mode, at this time, if I open the VB6 Object-Browser window and drag the sub-window dividing line with the mouse, then the mouse is always in the "splitting-dragging" state, and cannot exit from the Object-Browser window, resulting in the entire VB6 IDE windows being frozen.
This phenomenon has occurred many times.
I've encountered this a few times (on Win7 and Win8), but only when the project contained an MS-BrowserControl.
Have not seen it anymore on a fully up-to-date Win10.
HTH
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Yes, MS-Browser Control is used in my forms. Maybe it's because I didn't install the patch for Win10 (I turned off the automatic upgrade option for Win10).
I'm thinking, if I use "Set wbExt = Controls.Add("Shell.Explorer.2", "wbExt")" instead of MS-Browser Control, will it avoid this situation?
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Quote:
Originally Posted by
dreammanor
I'm thinking, if I use "Set wbExt = Controls.Add("Shell.Explorer.2", "wbExt")" instead of MS-Browser Control, will it avoid this situation?
This is worth a try ... (maybe the behaviour I was seeing on Win7 and Win8 was also due to using the IE-Control early-bound,
am working since about 3 years now strictly latebound with the Browser-Control,
to avoid Interface-incompatibilities between the "Win/IE-Version used for compiling" and the "Win/IE-Versions the App gets deployed to".
HTH
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Hi Olaf, I did further testing and found that the problem was indeed caused by the IE-Control. But even if I delete IE-Control and use "Set wbExt = Controls.Add (" Shell.Explorer.2 "," wbExt ")" for late binding, the problem still cannot be eliminated.
-
Question 047: None
-
Re: The 1001 questions about vbRichClient5 (2020-04-25)
Quote:
Originally Posted by
dreammanor
Hi Olaf, I did further testing and found that the problem was indeed caused by the IE-Control. But even if I delete IE-Control and use "Set wbExt = Controls.Add (" Shell.Explorer.2 "," wbExt ")" for late binding, the problem still cannot be eliminated.
You're right...
(sorry, my former assumption that this was gone on a recent Win10 -
doesn't hold up to a concrete test, which I've done now)...
For anybody who want's to reproduce this "possessive IE-Control-Bug, influencing the VB-IDE, once navigating at least once":
Here some minimal-code for a virginal VB6-Form-Project ...
(without additional Controls or References... so the RC5 doesn't have anything to do with it):
Code:
Option Explicit
Private wbExt As VBControlExtender
Private Sub Form_Load()
Set wbExt = Controls.Add("Shell.Explorer.2", "wbExt")
wbExt.Visible = True
wbExt.object.Navigate2 "about:blank"
End Sub
After the above snippet was pasted into the Form (and at least run once -> calling .Navigate2 is important),
the VB6-IDE ObjectExplorer will not recover from a "TileSplitter-MouseDrag-Operation"...
The IDE will now remain stuck in an Endless-Loop within the Splitter-DragOp, never coming out of there ...
(causing 100% CPU-load on a single CPU-Core - and that's how you can detect this VB6-Task in the TaskManager, to kill it from there).
HTH
Olaf
-
Re: The 1001 questions about vbRichClient5 (2019-07-28)
Quote:
Originally Posted by
Schmidt
You don't need the WebServer-instance, to make that work.
Here some code, which will work on an empty (normal) VB-Form -
only a reference to vbWidgets and vbRichClient5 is required:
Code:
Option Explicit
Private WithEvents Panel As cWidgetForm, WithEvents WB As cwBrowser
Private Sub Form_Load()
Set Panel = Cairo.WidgetForms.CreateChild(hWnd)
Set WB = Panel.Widgets.Add(New cwBrowser, "WB")
WB.WebKit.Navigate2 "file:///" & Replace(App.Path & "\CLEditor\index.html", "\", "/")
End Sub
Private Sub Form_Resize()
ScaleMode = vbPixels
Panel.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub Panel_ResizeWithDimensions(ByVal NewWidth As Long, ByVal NewHeight As Long)
WB.Widget.Move -1, -1, NewWidth + 3, NewHeight
End Sub
The magenta-colored part is the important one...
(a SubFolder, named \CLEditor sits below the App-Path, and contains the unzipped CLEditor-package).
Here is my (slightly adjusted) index.html:
Code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="jquery.cleditor.css" />
<script src="jquery-3.1.1.min.js"></script>
<script src="jquery.cleditor.min.js"></script>
<script>
$(document).ready(function () { cleditor($("#input"),{height:"100%"}); });
</script>
</head>
<body style="margin:0; padding:0; border:0; overflow:hidden;">
<div style="position:absolute; left:0px; right:0px; width:100%; top:0px; bottom:0px; height:100%;">
<textarea id="input" name="input"></textarea>
</div>
</body>
</html>
HTH
Olaf
Hi Olaf, when I dynamically generated index.html in "ws_ProcessRequest (Request As vbRichClient5.cWebRequest)", CLEditor did not load successfully.
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Hi Olaf, when I dynamically generated index.html in "ws_ProcessRequest (Request As vbRichClient5.cWebRequest)", CLEditor did not load successfully.
Code:
Option Explicit
Private wa As cWebArchive, WithEvents ws As cWebServer
Private wb, wbExt As VBControlExtender
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, 7200, 1920
'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 " <link rel=""stylesheet"" href=""jquery.cleditor.css"" />"
.Add " <script src=""jquery-3.1.1.min.js""></script>"
.Add " <script src=""jquery.cleditor.min.js""></script>"
.Add " <script>"
.Add " $(document).ready(function () { cleditor($(""#input""),{height:""100%""}); });"
.Add " </script>"
.Add "</head>"
.Add "<body style=""margin:0; padding:0; border:0; overflow:hidden;"">"
.Add " <div style=""position:absolute; left:0px; right:0px; width:100%; top:0px; bottom:0px; height:100%;"">"
.Add " <textarea id=""input"" name=""input""></textarea>"
.Add " </div>"
.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
-
1 Attachment(s)
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Added the statement: .Add " <script src=""jquery-3.1.1.min.js""></script>"
Re-posted the test project. The problem seems to be in the following statement:
Code:
<link rel="stylesheet" href="jquery.cleditor.css"/>
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://127.0.0.1:8888/jquery.cleditor.css".
-
1 Attachment(s)
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
dreammanor
Hi Olaf, when I dynamically generated index.html in "ws_ProcessRequest (Request As vbRichClient5.cWebRequest)", CLEditor did not load successfully.
You've forgot to pre-load jquery in your index-html definitions.
And also, when you place byte-arrays in the Response-Object
(and not FileNames, which can "speak for themselves" regarding their MIME-Type),
you'll have to set the Response.ContentType explicitly in your Event-Handler.
Here's your Zip with all necessary corrections:
Attachment 176709
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Hi Olaf, before seeing your reply, I just solved this problem myself:
Code:
...
...
Case Else
Dim RelPath As String, B() As Byte
RelPath = Replace(IIf(Len(sURL), sURL, "index.html"), "/", "\")
If Dir(Request.RootDirectory & RelPath, vbNormal) <> "" Then
If Right$(RelPath, 4) = ".css" Then
'Debug.Assert False
Request.Response.ContentType = "text/css; text/html; charset=UTF-8"
End If
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
But, obviously, your method is more concise, professional and elegant. Much appreciated.
In addition, I encountered more problems when using CKEditor4. I'll try to solve these problems myself. If I can't solve it, I'll have to ask for your help and guidance again.
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
dreammanor
In addition, I encountered more problems when using CKEditor4. I'll try to solve these problems myself. If I can't solve it, I'll have to ask for your help and guidance again.
The newest versions of some of the more popular js-libs tend to leave out IE-support completely
(so they wouldn't work in the IE-Control, no matter if "uplifted" via cIEFeatures.cls or not)...
FWIW, ... I have already a VB6-WrapperClass for the (Chromium-based) MS-Edge-BrowserControl working (for the most parts) -
but since the MS-Base-API for the Control-binding is "still changing", I'll release it only after the new Edge-engine
ships officially with Win10-builds.
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
Schmidt
The newest versions of some of the more popular js-libs tend to leave out IE-support completely
(so they wouldn't work in the IE-Control, no matter if "uplifted" via cIEFeatures.cls or not)...
FWIW, ... I have already a VB6-WrapperClass for the (Chromium-based) MS-Edge-BrowserControl working (for the most parts) -
but since the MS-Base-API for the Control-binding is "still changing", I'll release it only after the new Edge-engine
ships officially with Win10-builds.
Olaf
It's really good news. This morning, I tested CKEdior5, which does not support IE and Ms-Edge at all, which makes me very frustrated. Looking forward to your VB6-WrapperClass for the (Chromium-based) MS-Edge-BrowserControl. Much appreciated.
-
1 Attachment(s)
Re: The 1001 questions about vbRichClient5 (2020-04-28)
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
Schmidt
The newest versions of some of the more popular js-libs tend to leave out IE-support completely
(so they wouldn't work in the IE-Control, no matter if "uplifted" via cIEFeatures.cls or not)...
FWIW, ... I have already a VB6-WrapperClass for the (Chromium-based) MS-Edge-BrowserControl working (for the most parts) -
but since the MS-Base-API for the Control-binding is "still changing", I'll release it only after the new Edge-engine
ships officially with Win10-builds.
Olaf
That would be great! Will communication between javascript and the host (vb6) be possible?
Thanks!
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
paliadoyo
That would be great! Will communication between javascript and the host (vb6) be possible?
Yes.
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
Schmidt
Yes.
Olaf
Great news!
Thanks
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Set DG.DataSource = Rs.DataSource err:
'-2147221504 (80040000)':
ADO needs to be installed to use DataBinding
Code:
Private Sub UpdateDataGrid(DG As DataGrid, SQL As String)
Set DG.DataSource = Nothing
Set Rs = Cnn.OpenRecordset(SQL)
MsgBox Rs.RecordCount
Set DG.DataSource = Rs.DataSource
End Sub
-
Re: The 1001 questions about vbRichClient5 (2020-04-28)
Quote:
Originally Posted by
xiaoyao
Set DG.DataSource = Rs.DataSource err:
'-2147221504 (80040000)':
ADO needs to be installed to use DataBinding
Code:
Private Sub UpdateDataGrid(DG As DataGrid, SQL As String)
Set DG.DataSource = Nothing
Set Rs = Cnn.OpenRecordset(SQL)
MsgBox Rs.RecordCount
Set DG.DataSource = Rs.DataSource
End Sub
Please post complete Demo-Code ...
(either in a Zip, or in a fully "self-contained" Code-Snippet like the one below):
Code:
Option Explicit
Private Rs As cRecordset
Private Sub Form_Load()
With New_c.Connection(, DBCreateInMemory)
.Execute "Create Table T(ID Integer Primary Key, Txt Text)"
.Execute "Insert Into T(Txt) Values('Text 1')"
.Execute "Insert Into T(Txt) Values('Text 2')"
.Execute "Insert Into T(Txt) Values('Text 3')"
Set Rs = .OpenRecordset("Select * From T")
End With
MsgBox Rs.RecordCount
Set DataGrid1.DataSource = Rs.DataSource
End Sub
From the Error-Message you got, I'd think my little example above will produce the same thing.
Because that Message points to a "messed up ADO-installation"
(for ADO-DataBinding with RC5-cRecordsets, the OleDB-SimpleProvider is needed, which comes "along with ADO").
Also a "messed up VB6-installation" could be the cause, due to the VB.DataGrid-dependencies to:
- DBADAPT.dll
- MSSTDFMT.dll
- MSBIND.dll
If those are not properly installed or registered on your Win-Machine, Bindings to the VB6-DataGrid will not work properly.
I recommend, to use "non-ADO-based Bindings" with SQLite, to work completely "MS-dependency-free".
(I've included the OleDB-SimpleProvider-Binding-Mode on cRecordsets only for "legacy-purposes").
Krools VBFlexGrid for example does support such an MS-free Binding-Mode.
Here is an example, how to use it with SQLite and the RC5.cRecordsets:
http://www.vbforums.com/showthread.p...te-Recordsets)
HTH
Olaf
-
2 Attachment(s)
Qustion 047: About RC5.cDC.DrawLine
Qustion 047: About RC5.cDC.DrawLine
wqweto wrote a wonderful Color-Picker similar to PhotoShop's, but its UI is too old. So I plan to rewrite it.
Double Dragon: Outlook Bar control + Photoshop Style Color Picker
I know RC5.Cairo is a good choice, but Cairo does not seem to be too convenient when dealing with single pixels. So I plan to use RC5.Win32_DC as my drawing tool to replace wqweto's cMemDC. But when the program runs to RC5.DC.DrawLine, VB6-IDE will make an error and exit. I don't know why.
Form1
Code:
'--- draw bar selector with RC5_Win32_DC ---
Private Sub DrawBarSelector_RC5_Win32()
Dim DIB As cDIB, DC As cDC
Dim nIdx As Long
Set DIB = New_c.DIB(BAR_WIDTH + 13, 7) 'create the DIB-instance (using a Constructor)
DIB.Fill MASK_COLOR 'ensure a BackGround-Fill on the complete DIB-area
Set DC = New_c.DC(DIB) 'create a DC-instance (using the Constructor, to select the DIB)
For nIdx = 1 To 4
DC.DrawLine nIdx, nIdx, nIdx, 7 - nIdx
DC.DrawLine BAR_WIDTH + 12 - nIdx, nIdx, BAR_WIDTH + 12 - nIdx, 7 - nIdx
Next
Set imgBar2.Picture = DIB.Picture
End Sub
-
Qustion 047: About RC5.cDC.DrawLine
Deleted duplicate content.
-
Re: Qustion 047: About RC5.cDC.DrawLine
Quote:
Originally Posted by
dreammanor
...when the program runs to RC5.DC.DrawLine, VB6-IDE will make an error and exit. I don't know why.
Fixed that in the new (already uploaded) version ...
This was "messed up by me" by passing a NullPointer in the last param of the GDI-MoveToEx-API as 0&, instead of ByVal 0& ...
(since this worked "some looong time ago", I assume that I redefined the API-Declare at some point - without adapting the call)
Quote:
Originally Posted by
dreammanor
Question 047: About RC5.cDC.DrawLine
I know RC5.Cairo is a good choice, but Cairo does not seem to be too convenient when dealing with single pixels.
So I plan to use RC5.Win32_DC as my drawing tool to replace wqweto's cMemDC.
I wouldn't invest this time in your shoes, because:
- "GDI-API-knowledge" will not help you with anything in the future
- nor will the Code you're about to write be portable to other platforms
- and ensuring DPI-awareness for all that GDI-based code is also "an adventure"
If you'd use the RC5-WidgetEngine instead to build that Dialogue:
- you'd end up with significantly less code
- learn cairo along the way
- all the while developing fully DPI-aware (without doing anything special for it)
- ending up with a contribution to the RC5-WidgetSet
- the new ColorChooser-widget then e.g. usable in a portable new IDE (saving time on my end)
As for convenient Pixel-access on a Cairo-Surface - this can be achieved via "virtual SafeArray-spanning":
Dim Pxl2D() As Byte
CC.Surface.BindToArray Pxl2D
'... Pixel-Loop here
CC.Surface.ReleaseArray Pxl2D
But you'll probably not need this, when you apply Linear-Gradient-Patterns properly.
FWIW, below is your changed Form-Code (to show, how the two triangles can be drawn with RC5.Cairo in a "best-practice"-way).
Code:
Option Explicit
Private Const BAR_WIDTH As Long = 16, MASK_COLOR As Long = &HFF00FF
Private Sub Command1_Click()
DrawBarSelector_wqweto BAR_WIDTH + 13, 7
End Sub
Private Sub Command2_Click()
DrawBarSelector_RC5_Win32 New_c.DIB(BAR_WIDTH + 13, 7)
End Sub
Private Sub Command3_Click()
DrawBarSelector_RC5_Cairo Cairo.CreateSurface(BAR_WIDTH + 13, 7).CreateContext
End Sub
'--- draw bar selector with RC5_Cairo ---
Private Sub DrawBarSelector_RC5_Cairo(CC As cCairoContext)
CC.Paint 1, Cairo.CreateSolidPatternLng(Me.BackColor) 'CC.Paint will fill the whole surface (no need to define a Rect)
DefineTrianglePathOn CC, CC.Surface.Height / 2 'we pass the y-extent of the diagonal (as half the Surface-Height)
CC.TranslateDrawings CC.Surface.Width, 0 'translate, so the second triangle will be drawn "from the top-right-edge"
CC.ScaleDrawings -1, 1 'we just have to flip the x-Axis-Scaling in addition, for "inverse expansion"
DefineTrianglePathOn CC, CC.Surface.Height / 2 'now we add the same path-coords again (but under the just defined coord-transform)
CC.Fill , Cairo.CreateSolidPatternLng(vbBlack) 'to finally fill both path-defs of our two triangles in one call
Set imgBar3.Picture = CC.Surface.Picture
End Sub
Private Sub DefineTrianglePathOn(CC As cCairoContext, DExt As Double)
CC.MoveTo 0, 0 'define (move-to) the top-left-origin of our triangle
CC.RelLineTo DExt, DExt 'a diagonal, relative from the origin (ending in the y-center)
CC.RelLineTo -DExt, DExt 'and the same diagonal, relative-backwards (inverted in x-direction)
End Sub
'--- draw bar selector in mem dc ---
Private Sub DrawBarSelector_wqweto(ByVal dx As Long, ByVal dy As Long)
With New cMemDC
.Init dx, dy
.Cls MASK_COLOR
Dim nIdx As Long
For nIdx = 0 To dy \ 2
.DrawLine nIdx, nIdx, nIdx, dy - nIdx
.DrawLine dx - nIdx - 1, nIdx, dx - nIdx - 1, dy - nIdx
Next
Set imgBar.Picture = .ExtractIcon(MASK_COLOR)
End With
End Sub
'--- draw bar selector with RC5_Win32_DC ---
Private Sub DrawBarSelector_RC5_Win32(DIB As cDIB)
DIB.Fill Me.BackColor 'ensure a BackGround-Fill on the complete DIB-area
With New_c.DC(DIB) 'create a DC-instance (using the Constructor, to select the DIB)
Dim nIdx As Long
For nIdx = 0 To DIB.dy \ 2
.DrawLine nIdx, nIdx, nIdx, DIB.dy - nIdx
.DrawLine DIB.dx - nIdx - 1, nIdx, DIB.dx - nIdx - 1, DIB.dy - nIdx
Next
End With
Set imgBar2.Picture = DIB.Picture
End Sub
HTH
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-05-26)
Hi Olaf, thank you for your detailed reply. Your solution is excellent as always. Much appreciated.
Actually, I've used RC5.Cairo to develop several controls before, such as Spread, RichEdit (CodeEditor), ScrollBar. But my memory is very poor now, as long as I haven't used RC5.Cairo for 6 months, I'll completely forget Cario commands and syntax (however, I always seem to remember the GDI functions and syntax). Now I need to learn Cairo from scratch.
I decided to accept your suggestion and use RC5.Cairo instead of RC5.Win32DC, although this will kill many of my brain cells. In addition, I plan to record this "rewriting process" in detail and upload it to CodeBank for others to learn and refer to.
Edit:
The development of ColorPicker will be delayed for several weeks.
-
Question 048: Add HoverTextColor To cWidgetBase
Question 048: Add HoverTextColor To cWidgetBase
I know that there is HoverColor (HoverBackColor) property in cWidgetBase, but in many cases we still need HoverTextColor. It would be great if HoverTextColor could be added to cWidgetBase and enmThemeColor.
-
Question 049: Serialization of image properties in controls
Removed meaningless question.
-
Question 050: Storage of website resources
Removed meaningless question.
-
Question 049: Is there any possibility that Cairo and SqliteDB in RC5 will be banned?
Question 049: Is there any possibility that Cairo and SqliteDB in RC5 will be banned?
Last month, several military-related universities in China have been banned from using MATLAB because they have entered the sanctions list of the US government. I'm wondering whether Cairo and SqliteDB in vbRichClient5 have the possibility of being banned. Thanks.
Note:
The software developer/supplier of MATLAB is the American company MathWorks.
-
Re: Question 049: Is there any possibility that Cairo and SqliteDB in RC5 will be ban
Quote:
Originally Posted by
dreammanor
Question 049: Is there any possibility that Cairo and SqliteDB in RC5 will be banned?
Last month, several military-related universities in China have been banned from using MATLAB because they have entered the sanctions list of the US government. I'm wondering whether Cairo and SqliteDB in vbRichClient5 have the possibility of being banned. Thanks.
Note:
The software developer/supplier of MATLAB is the American company MathWorks.
Not sure, whether this is really a question, or a statement instead (to let us know, that MatLab "blocked chinese military institutions from using their services").
As for RC5 (and the binaries I provide) - I'll not hinder anyone to download new(er) versions of the libs I compile (from my WebServer, which is located in germany).
Also, it is "just a few Dlls in a Zip" - and not an (interactive) WebService you are using, so - once you've "downloaded it locally", nobody can take it from you there.
As for the situation with MatLab, I'd not blame the company itself (who's just following "the current law" of the state it is located in).
If the relations between china and germany should ever deteriorate to such a level or lower...,
I guess that "such banning" would happen at "german inet-provider-level" automatically (vbRichClient.com then not reachable anymore from chinese IP-addresses) -
all that without me "doing anything pro-actively, trying to be patriotic"...
Also keep in mind, that in such a "fictional deteriorated situation", the chinese would be good advised, to not use any pre-compiled binaries which came from "foreign Webservers or OSes"... ;)
Olaf
-
Re: Question 049: Is there any possibility that Cairo and SqliteDB in RC5 will be ban
Hi Olaf, thank you for your detailed reply. A few years ago, I started to try to gradually get rid of Microsoft's development environment. My computers now don't have MS-Office and VisualStudio.NET. Even my VB6 apps no longer use MsCommonControls, but it seems that I cannot find a suitable VB6 alternative. The prerequisite for me to be able to develop complex applications is to have an excellent "debugger", but apart from Delphi and VS.NET, I've never found a more friendly debugging environment than VB6. This is why I tried to develop a debugger for JavaScript with VB6 a few months ago.
12 years ago, I spent a lot of time looking for alternatives to Ms-AccessDB, and finally I found SqliteDB (dhRichClient30). Now, I have to start looking for alternatives to VB6.
-
2 Attachment(s)
Question 050: The best way to make ucPanel transparent
Question 050: The best way to make ucPanel transparent
In most cases, I use ucPanel as a container for RC5.Widgets. Now, I need to make the ucPanel transparent. I know there are several ways to achieve this. But I'd like to know what is the best way to make ucPanel transparent? Thanks.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Is cfso wrong for me? Why does the prompt object variable or with variable is not set?
Code:
Dim sFSO As vbRichClient5.cFSO
MsgBox sFSO.FileExists ( App.Path & "\Logo.png")
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
You haven't created an instance of the cFSO object yet. Try:
Code:
New_c.FSO.FileExists(App.Path & "\Logo.png")
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Thank you @jpbro.
I can use it after testing.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
dreammanor
All of my desktop tools will be developed based on RC5, and I'll have a lot of questions to ask Olaf and other RC5 experts. In order not to disturb other people, I concentrated all my questions about RC5 in this thread.
Quote:
Originally Posted by
dreammanor
Olaf and other RC5 experts could pick up some valuable questions to answer and ignore the worthless questions.
.. . ..
.. . ..
Quote:
Originally Posted by
dreammanor
If someone else wants to ask questions about RC5 in my thread, I'll also put them in the list above. All questions about RC5 are welcome.
Dear Olaf (DreamManor and other RC5 experts too),
I would be extremely grateful if I can get answers to the following questions :
Brief Scenario:
I have an existing free app (downloadable from my website and thus already deployed in 1000s of end-users' systems). It uses many of Krool's invaluable controls. I am very much thinking of making use of your fabulous RC5 also in my app now, esp. your RC5's WebKitCairo. As of now, I will display some local web pages inside my app in some screens (using your WebKitCairo or WebKitCairoNewLibCurl). As I progress further, I will act upon events of the displayed local pages' buttons, canvas, etc. I will do most of the event handling within my app itself and show the results in the displayed local page's text area, etc. I might choose to show the results in some vb6 controls (TextBox, PictureBox, etc.) too in my app's screen. The idea is to try pushing(wherever possible) the UI design of my screens to html/css/javascript (since it has "loads" of advantages for me).
Based on the above scenario, my questions are:
1. Will the portions of my app using your RC5 (incl. my app's screens which avail your WebKitCairo or WebKitCairoNewLibCurl) work in Windows 11 also? If they will definitely work, without any issues whatsoever (for at least the next 5 years), great.
2. This page - https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge/ - says that the "Internet Explorer 11" desktop application will be retired and go out of support on June 15, 2022, for certain versions of Windows 10.
Will the above situation have any bearing at all on my app? Will the portions of my app, incl. the portions using your WebKitCairo or WebKitCairoNewLibCurl, continue to behave exactly as before in all OSes (Win7-to-Win11 would suffice if not WinXP-to-Win11), after 15-June-2022 also? If so (for at least the next 5 years), then again, great.
3. If the portions of my app using your RC5, esp. the portions using your WebKitCairo or WebKitCairoNewLibCurl, will not work in Win11 (OR) if they will not work in one or more OSes after 15-June-2022, then, what is the best approach for me?
- Well, as of now, I cannot straightaway start using your RC6 in my app (even though I understand that the WebView2 methodology will definitely work in Win11 and that the supported OSes are Win7-to-Win11 for WebView2). This is because of the large size of the 'WebView2 Runtime' installer (more than 100 MB) which is required to be installed in end-users' systems by Microsoft. I have read all the end-user deployment options given by Microsoft (https://docs.microsoft.com/en-us/mic...s/distribution) but none of them will be viable in the case of 'all of' my end users (since all may not have the facility to download large files; since all may not have hard disks with sufficient capacity to allow installation of such large runtimes which may occupy lot of space in their hard disks; also some users, even if they have the required facilities, just do not like to download/install large executables since they feel it may affect their systems). So, using RC6 (which contains WebView2Loader) in my app is not feasible, as of now.
4. If all portions (let me collectively call them 'XYZ') of my app using your RC5, incl. the portions availing your WebKitCairo or WebKitCairoNewLibCurl, will definitely work in all OSes including Windows 11, without any issues (for at least the next 3 years, if not 5), then, going forward, I might love to have one more version of my app where 'XYZ' uses your RC6 instead of RC5 so that users who do not mind installing the 'WebView2' runtime can use that version of my app. In such a case, I wish to know whether my RC5-involving codes (esp. the ones involving your WebkitCairo or WebKitCairoNewLicCurl) be easily portable to RC6 (with no or minimal code changes) OR will I have to recode most or all of my RC5 code?
5. Are there any WebKitCairo tutorials, examples, demos? If so, kindly let me know the web links for them. I was not able to find them so far. I was able to find only the following tutorials so far - RC5cairoTutorial.zip, RC5formsTutorial.zip, RC5WidgetsTutorials.zip and CairoTutorial-master.zip.
6. In the case of RC6 also, are there any WebView2 tutorials?
Expecting your answers on the above, so that I can assuredly start using your RC5 (or RC6, if that is the ideal/only choice, going forward) in my app.
Kind regards.
NOTE:
Though I had a single QUOTE block only at the top of my message, after I submitted/saved my reply/changes, the single QUOTE block automatically turned into multiple QUOTE blocks. Don't know why. I edited my message 2 to 3 times to make it a single QUOTE block again (at the top) but same thing happened in the final output (it changed to multiple QUOTE blocks). So, I am leaving the 3 QUOTE blocks (at the top) as they are.
-
Re: The 1001 questions about vbRichClient5 (2019-05-26)
I see that cActiveScript can execute JavaScript code. But can it do so if the javascript code references another library?
I tried referencing the library in the first line of the script (ex.
Code:
const path = require('path');
) but that doesn't seem to work.
-
Re: The 1001 questions about vbRichClient5 (2019-05-26)
Quote:
Originally Posted by
AAraya
I see that cActiveScript can execute JavaScript code. But can it do so if the javascript code references another library?
I tried referencing the library in the first line of the script (ex.
Code:
const path = require('path');
) but that doesn't seem to work.
ES6 modules are neither supported by "JScript" nor are they via the also supported "JScript9" initiator-string.
So, I'd rely on the strength of both interpreter-engines, which is to use COM-Dlls or -Objects (instead of "modules").
Code:
Option Explicit
Private WithEvents JS9 As cActiveScript
Private Sub Form_Load()
Set JS9 = New_c.ActiveScript("JScript9", True, False) 'this adds the COM-Objects New_c and Cairo already into the js-context
JS9.AddObject "console", Me 'here we add a third COM-Object (the Form itself)
With New_c.StringBuilder
.AddNL "var D = new ActiveXObject('Scripting.Dictionary')" 'and here the 4th COM-Object (the MS-Scripting.Dictionary) this time via js-code itself
'COM-Object access (via variables D, as well as New_c and Cairo)
.AddNL "D.Add('SQLite-Version', New_c.Connection().Version())"
.AddNL "D.Add('Cairo-Version', Cairo.Version)"
.AddNL "console.log( D('SQLite-Version') )" 'and here two COM-Objects are addressed, the console(Form) with its Public Log-Method
.AddNL "console.log( D('Cairo-Version') )" '...printing out the Values behind COM-Object D("SomeKey")
JS9.AddCode .ToString
End With
End Sub
Public Sub Log(ByVal Text)
Debug.Print Text
End Sub
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-02-08)
Quote:
Originally Posted by
Schmidt
Nice...
FWIW, here's a performance-improvement for the ActiveScript-JSCode based replacements
(which also corrects a few errors in the reg-expressions):
Code:
With New_c.StringBuilder
.AppendNL "'use strict';"
.AppendNL "var regCmtSngLine1 = /(^\/\/.*?(\r|\n))/gm ;"
.AppendNL "var regCmtSngLine2 = /(?!([""']([^\\[""']]*).*[""'])).(\/\/.*?(\r|\n))/g ;"
.AppendNL "var regCmtMultiLine = /(\/\*[\w\'\s\r\n\*]*\*\/)/g ;"
.AppendNL "var regLet = /^\s*[\{\(]*let \b/gm ;"
.AppendNL "var regEmptyLines = /^\s*[\r\n]/gm ;"
.AppendNL "function CompressJavaScript(code){"
.AppendNL " return code"
.AppendNL " .replace(regCmtSngLine1,'')"
.AppendNL " .replace(regCmtSngLine2,'')"
.AppendNL " .replace(regCmtMultiLine,'')"
.AppendNL " .replace(regLet,'var ')"
.AppendNL " .replace(regEmptyLines,'')"
.AppendNL "}"
mSC.AddCode .ToString
End With
With these changes it is now faster than the (VB)Scripting-Regex-Code -
(also note, that "JScript" works - surprisingly - a bit faster than the newer "JScript9" engine).
Olaf
Dear Olaf,
First of all, I wish you a Very Happy New Year. Its always a great feeling, wishing an extremely magnanimous soul like you, as my heart wells up with gratitude. And, I take this opportunity to wish a Happy New Year to all the great masters and experts of our VbForums through whom countless many (which includes me also naturally) have got benefited and in turn passed on those benefits, in one way or other, to a further 'countless many' of the society, like a positive chain reaction.
Well, the following are in reference to this post of mine - https://www.vbforums.com/showthread....=1#post5627131 - Post #51
--
1. Is there any way of using ActiveScript to specify a language which would allow me to use LookBehinds in regular expressions?
2. ActiveScript was able to accept 'Chakra' as language. It did not seem to accept 'V8' as language though, as the language got automatically set as 'Jscript9' by your ActiveScript (as it was the case with any other random string I passed to it as language).
3. I tried WV.jsRun too, just to see what happens. It accepts lookbehinds in regex patterns, obviously. But, it was quite slow. May be it can be done in a way to make it run fast but I did not know how. Using jsRunAsync did not seem to be the right way to effect faster regex operations.
--
So, is there any way at all, as of today, either through ActiveScript or WV or any other technology, to use a flavour of JS, which, like pcre2, can effect regex operations with all the allowed specifications (incl. Lookbehinds, groups, etc. [since the 2018 ECMAScript specs, as I get to understand from the net]) and also effect such regex operations as fast as wonderful JpBro's Pcr wrapper (OR) your ActiveScript Js (OR) VB RegEx.
Thanks in tons, once again, for all your free offerings to the society.
Kind Regards.
Edit-1:
Just now, after posting the above, I checked out my referred post in JpBro's thread and I notice a new reply therein, from you!!!, Olaf. I will now go and read that fully.
Edit-2:
First of all, as ever, thanks a lot for your reply in JpBro's thread. I had not made that init/reinit optimisation (as in your code) in 'pcrTest' either. So, I started to make them (so that my future benchmarking will be on even scales). And, "to whatever level I could" do^ the optimisation, with my limited knowledge, and "to whatever level I have tested so far", as per my initial findings, I see a dramatic increase in processing speed in JpBro's pcrTest, w.r.t the non-English database. Once I have done a thorough testing for both non-English and English databases, I will share my results in JpBro's thread. At that time, I would request you to kindly help me know (if possible and if and when you find time) the ideal manner in which the pcrTest code shall be, so that it will carry the highest optimisation. In case my initial findings prove later to be not correct, I shall inform that also here. Thank you soooooo much once again for taking time, even amidst your hectic schedules, to give such clear-cut code snippets. Remaining in all humbleness, as always.
(^) I dont know whether I have handled the memory free-ings correctly. That's one more reason for which I have requested your kind help above. I wanted to post pcrTest code in my last reply in JpBro's thread itself but forgot.
Edit-3: The weblink I gave to "my post in JpBro's thread" was not working correctly because of the closing bracket getting added to the link, upon clicking it. So, I removed the enclosing brackets now. Also, mentioned the post no.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Is this thread strictly related to RC5 only or I can ask questions related to RC6 also?
If I can ask questions related to RC6 also, then can I ask questions related to everything RC6 (on sqlite, on cairo, on modules like 'FSO, Crypt etc.', on widgets, etc. except on webview2)? I am not including webview2 since I am aware of the separate thread for it (started by Olaf) and I have always posted questions related to webview2 therein only.
Any guidance on the above from anybody most welcome.
Kind Regards.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
softv
Is this thread strictly related to RC5 only or I can ask questions related to RC6 also?
Since user-code written for RC5 runs with an RC6-reference as well,
I don't see any problems with asking any RichClient-related questions here...
Alternatively, opening specific new threads here, when prefixed with [RC6] in the title,
should also work (without throwing anybody off).
RC6 plays in the same "ballpark" as other "big COM-reference-checkins for VB6" (like "MS ADO" for example).
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
Schmidt
(like "MS ADO" for example)
Olaf, I just spent some weeks (!) fighting with MS ADO. It's a horrible mess, with e.g. different arg counts for OpenSchema for C++, VB, C#, ...but in the end I got this working (pseudocode):
Code:
.if !OpenAdo(CL$()) ; command line, can be xls, xlsx, mdb or dbf files
For_ n=0 To OpenAdo(0)-1 ; 0=first sheet
PrintLine AdoTable$(n, 5) ; row n, column 5 (tab-delimited format)
Next
PrintLine "bye"
.endif
Back to RichEdit: has anybody noticed that on Win 10, you get artifacts on screen, tiny little vertical lines?
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
Schmidt
Since user-code written for RC5 runs with an RC6-reference as well,
I don't see any problems with asking any RichClient-related questions here...
Alternatively, opening specific new threads here, when prefixed with [RC6] in the title,
should also work (without throwing anybody off).
RC6 plays in the same "ballpark" as other "big COM-reference-checkins for VB6" (like "MS ADO" for example).
Olaf
Thanks as always, olaf.
Following is a RC6-related question.
It would be helpful, Olaf, if you can kindly let me know what is going wrong in the following process:
--
1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
2. I use b = str to save that string to b()
3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
4. Then I save b to a string (encryptedStr = b)
5. Then I save encryptedStr in a TEXT field in a sqlite database
--
In above process, in some cases (with regard to the strings stored in str), encryptedStr is stored in Sqlite as it is. Sometimes, not.
For e.g. if str is changed to str = "abcdefghijklmnopqrstuvwxyz':" (just the 'z' alone added), Sqlite does not store encryptedStr the same way as it is in VB6.
Of course, I am able to store b() as blob in Sqlite but I wish to know how to store encryptedStr itself in a TEXT field. In whatever I have come to understand in my limited knowledge, String and Bytes are interchangeable in VB6. So, I thought there should not be any problem for Sqlite. So, what is going wrong above? What mistake am I doing? Have I to use StrConv. If so, how?
// Alternatively, opening specific new threads here, ... .. . //
In my very humble opinion is, if there is just "one single thread" (just ONE and only one) in our forum where ALL sorts of questions can be asked to you (whether it be in VB6 or RC5 or RC6), that will be 'extremely' immensely useful for a person like me (and all others who have the same wish in their mind). I kindly request yourself to start such a thread, if at all you deem it fit. May be the thread's title/topic can be "Olaf - ANY questions related to VB6, RC5 or RC6". In case there are any other areas which I have missed (apart from VB6, RC5 and RC6) which are also permissible (by the forum mods) to be asked in that thread, I kindly request you to add them too in the thread title/topic. If you think such a single thread will be a burden of sorts to you (amidst your already hectic schedules), then no problems. Kindly ignore this request of mine. On the other hand, if you think my idea is good, then great. I believe the other gurus/experts will also chip in to help (in that thread), whenever they can, esp. when you are not in a position (for whatever reasons) to attend to our questions in time.
In all humbleness.
Ever in utmost gratitude to your selfless service.
Kind Regards.
Edit-1: I forgot to mention the way I stored the data in the text field. It was as follows:
--
Set localCnn = New cConnection
localCnn.CreateNewDB
localCnn.ExecCmd ("CREATE TABLE S (str TEXT NOT NULL)")
Set localCmd = localCnn.CreateCommand("Insert Into S Values(@str)")
With localCmd
.SetText !str, encryptedStr
.Execute
End With
localCnn.CopyDatabase dbFileLocal
--
Edit-2:
--
On further exploring with 4 different strings, it seemed like if there are bytes in the encryptedStr holding values in the 'Surrogates range' or in some specific range of the 'PUA range' of the Unicode block, it is causing problems while storing those strings in Sqlite DB. Well, I am not having time to explore further more. And, probably my exploration with the 4 strings is completely off the track too. So, let me await your reply now, when you find time, pointing out to the mistake(s) done by me at my end. Thanks in advance.
--
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
softv
1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
2. I use b = str to save that string to b()
3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
4. Then I save b to a string (encryptedStr = b)
5. Then I save encryptedStr in a TEXT field in a sqlite database
What's wrong in the above steps, is #4.
As soon as you leave "Unicode-String-Space" - and enter "Raw-Byte-Space"
(e.g. after applying an encryption-algo on the string-bytes) -
you should "stay in that universe of raw-bytes" and not treat such raw-bytes like string-content.
Here's an example:
Code:
Const Msg As String = "abcdefghijklmnopqrstuvwxyz':"
Const Pwd As String = "SomePassPhrase"
Dim M As cMemDB, B() As Byte
Set M = New_c.MemDB
M.Exec "CREATE TABLE T(EncStr BLOB)" 'encrypted Strings belong into properly typed Blob-Fields
B = New_c.Crypt.VBStringToUTF8(Msg) 'to ensure a usually smaller B (compared to a direct 1:1 UTF16-copy like B=Msg)
'B now contains the UTF8-encoded String-Bytes
New_c.Crypt.AESEncrypt B, Pwd 'inplace-encryption on the Bytes of B
'B now contains encrypted "raw-bytes" (which neither follow UTF16- nor UTF8-encoding conventions anymore)
M.ExecCmd "Insert Into T(EncStr) Values(?)", B 'store B in the Blob-Field of Table T as a new record
B = M.GetRs("Select EncStr From T").Fields("EncStr").Value 'here we get B back from the first record of the Rs
New_c.Crypt.AESDecrypt B, Pwd 'inplace-decryption on the just retrieved B-Blob
Debug.Print New_c.Crypt.UTF8ToVBString(B) 'back-conversion of the decrypted (now UTF8 again) B-Bytes into an UTF16-VBString
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
He said he didn't want to use a BLOB field in the database but use a TEXT field instead! :D
In this case I think one solution would be to encode the byte array to Base64, probably RC6 should have such as function as well...
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
Schmidt
What's wrong in the above steps, is #4.
As soon as you leave "Unicode-String-Space" - and enter "Raw-Byte-Space"
(e.g. after applying an encryption-algo on the string-bytes) -
you should "stay in that universe of raw-bytes" and not treat such raw-bytes like string-content.
Here's an example: ... .. .
... 'to ensure a usually smaller B
.. (which neither follow UTF16- nor UTF8-encoding conventions anymore)
.
Olaf
Thanks a TON, as always, Olaf.
Learnt a lot (incl. the cMemDB tip). Thank you so much.
Kind Regards.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
VanGoghGaming
He said he didn't want to use a BLOB field in the database but use a TEXT field instead! :D
In this case I think one solution would be to encode the byte array to Base64, probably RC6 should have such as function as well...
Sure, that would be one way, to keep the DB-Tables Field-Type as Text -
(at the cost of increasing the "occupied DB-StorageSpace" by 33% in that Table-Field).
Cannot see any advantage, to simply re-typing that Column to a Blob-Type
(since "Text-Searching" or any other DB-String-Ops on that Field are not possible anyways, when encrypted).
Another (easier) way would be, to encrypt the whole SQLite-DB with a passphrase.
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
https://www.vbforums.com/images/misc/quote_icon.png Originally Posted by softv https://www.vbforums.com/images/butt...post-right.png
1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
2. I use b = str to save that string to b()
3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
4. Then I save b to a string (encryptedStr = b)
5. Then I save encryptedStr in a TEXT field in a sqlite database
Quote:
Originally Posted by
Schmidt
What's wrong in the above steps, is #4.
As soon as you leave "Unicode-String-Space" - and enter "Raw-Byte-Space"
(e.g. after applying an encryption-algo on the string-bytes) -
you should "stay in that universe of raw-bytes" and not treat such raw-bytes like string-content.
Olaf
Just one thing I wish to understand regarding the above, dear olaf.
After step 4, if I do the following within VB6, 's' gets printed correctly for any string stored in 'str' initially. So, what is the basics surrounding this? May be I am not clear about those basics. And that's why I am asking this question. So, when possible, kindly educate me.
--
Dim bAgain() As Byte
Dim s As String
bAgain = encryptedStr
New_c.Crypt.AESDecrypt bAgain, Pwd
s = bAgain
Debug.Print s
--
Kind Regards.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
softv
https://www.vbforums.com/images/misc/quote_icon.png Originally Posted by softv https://www.vbforums.com/images/butt...post-right.png
1. I have a normal English string (str = "abcdefghijklmnopqrstuvwxy':")
2. I use b = str to save that string to b()
3. Then, I use RC6's Crypt.AESEncrypt to encrypt b.
4. Then I save b to a string (encryptedStr = b)
5. Then I save encryptedStr in a TEXT field in a sqlite database
After step 4, if I do the following within VB6, 's' gets printed correctly for any string stored in 'str' initially. So, what is the basics surrounding this? May be I am not clear about those basics. And that's why I am asking this question. So, when possible, kindly educate me.
--
Dim bAgain() As Byte
Dim s As String
bAgain =
encryptedStr
New_c.Crypt.AESDecrypt bAgain, Pwd
s = bAgain
Debug.Print s
--
Your encryptedStr-Variable above contains bytes, which - after prior encryption - are not:
"WChar-Bytes, which follow UTF16-rules" anymore...
...and as such, should not be fed e.g. into any Text-expecting or Text-Conversion-routine
like e.g. the WideCharToMultibyte-API (to convert them to UTF-8-text for SQLite-storage)
Your example above works, because the direct assignments (ByteArray=VBString and vice versa)
just make 1:1 data-copies of the content (without interpreting, or converting it in any way).
So in short, the VBString-Type is able to store "arbitrary byte-sequences" (which are not WChars) -
but you should be aware in such cases, that they do not contain proper UTF16-Text and treat them as "plain byte-buffers" then.
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Its fully clear now. Thanks a lot, olaf. It helps a lot when the basics become clear.
It is really so kind of you to take the extra mile, for my sake, and provide additional explanatory statements like "...and as such, should not be fed e.g. into any Text-expecting or Text-Conversion-routine like ... .. .", "without interpreting, or converting it in any way" and "in short, the VBString-Type is able to store 'arbitrary byte-sequences' (which are not WChars) but ... .. ." . These helped me so much, to get that perfect clarity in my mind. Thanks a lot, once again.
Kind Regards.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
This post is RC6-related.
Dear olaf,
Thanks a TON for the AppendText function in FSO. I have always wondered why a simple function to append text to text files did not exist straightaway. So, thanks a lot.
By the way, both in WriteTextContent and AppendTextContent, I am able to see option for writing to utf-8 but not for writing to UTF-16 file. Sorry if I am missing any such option. Kindly let me know how to write to UTF-16 encoded text files.
I tried WriteByteContent to see whether it can create UTF-16 encoded text files but did not succeed. In any case, in which specific scenarios (if any) WriteByteContent and ReadByteContent will be used while reading contents of text files?
And, as far as I see, ReadTextContent returns Unicode strings from both utf8 and utf16 files. There is no need to specify any extra option. Is my understanding correct? And, what is the "IsRaw16bit" option for?
Kind regards.
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Quote:
Originally Posted by
softv
... both in WriteTextContent and AppendTextContent, I am able to see option for writing to utf-8 but not for writing to UTF-16 file.
UTF-8 is kind of standard for TextContent-transport or -storage (whilst UTF16 is not).
That's the reason behind it...
If you want to append UTF16, you will have to do it by hand:
Code:
B = SomeVBString 'direct ByteArray-conversion of UTF16 into B
With New_c.FSO.OpenFileStream(FileName, STRM_WRITE Or STRM_SHARE_DENY_NONE, True)
.SetPosition 0, STRM_SeekFromEnd 'move to the end of the file...
.WriteFromByteArr B ' ...and write the byte contents
End With
Quote:
Originally Posted by
softv
...as far as I see, ReadTextContent returns Unicode strings from both utf8 and utf16 files.
There is no need to specify any extra option. Is my understanding correct? And, what is the "IsRaw16bit" option for?
The Method tries to "do things right" (when the Optional Params are left at their defaults) -
and it will get help from "the files themselves", in case they have "leading UTF8 or UTF16-BOMS".
As soon as you change the Opt-Params from their defaults (as e.g. setting IsRaw16bit = True),
you're "forcing" the routine to behave in a certain way...(e.g. when an UTF16-File does not have a BOM).
Since you're asking a lot of questions related to UTF16-storage -
what's the reason you seem to prefer that text-encoding over UTF8?
Olaf
-
Re: The 1001 questions about vbRichClient5 (2020-07-21)
Dear olaf,
// If you want to append UTF16, you will have to do it by hand //
Thanks a lot. I shall try that soon.
Actually, I process both utf-8 and utf-16 files. So, I was looking for utf-16 options too. Any chances, in the future? In fact, the options' defaults not being to utf-8 was somewhat of a surprise to me. You can kindly educate me on the same too as to why they are so.
Coming back to utf-16, your question on it prompted me to do some fresh testing at my end, now that I have started using RC6's FSO.
Around a 9mb Unicode file (utf-16le, carrying fully non-English characters) saved to utf8 and tested with both my 'existing' routine and RC6's gave the following results, while reading the files. Just thought of sharing with you.
--
49.32msec existing utf8 4560738
53.09msec existing utf8-bom 4560738
14.38msec existing utf16-bom 4560738
--
34.39msec RC6 utf8 11783558**
37.56msec RC6 utf8-bom 4560738
10.74msec RC6 utf16-bom 4560738
--
Note: 4560738 is the stored string's length
(**) this was with default settings.
With "New_c.FSO.ReadTextContent(fname, , CP_UTF8)", the results were:
--
46.21msec RC6 utf8 4560738
--
I find RC6 as 1000s of beautiful/beauty-filled tools/apps in one very "fast, compact & robust" framework. I Simply Love it. Thanks a TON, again.
Kind Regards.