|
-
Apr 29th, 2016, 08:04 AM
#1
Thread Starter
Addicted Member
[VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
Hello Olaf,
I have been waiting for a solution that will allow visually developing application using VBRichClient's Cairo GUI easily. But till date there is no useful solution.
So I thought a way out for myself. The way is to build the GUI using VB6 Forms and controls and at runtime generate a complete Cairo GUI based on VB6 Forms. Till here things seem to work to an extent. But unfortunately I am not able to find any way to link events of VB6 to Cairo GUI.
Does anyone know of any way by which we can link (or rather map) the events as well as calls to VB6 controls to their respective Cairo GUI controls. Here by call to VB6 controls I mean setting properties of VB6 controls will automatically propagate to the respective Cairo GUI control.
If this is possible then it would be very easy to build Cairo GUI using VB6 Forms and use the all powerful Cairo GUI in VB6. 
TIA
Yogi Yang
-
May 1st, 2016, 01:54 PM
#2
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
 Originally Posted by yogiyang
I have been waiting for a solution that will allow visually developing application using VBRichClient's Cairo GUI easily. But till date there is no useful solution.
So I thought a way out for myself. The way is to build the GUI using VB6 Forms and controls and at runtime generate a complete Cairo GUI based on VB6 Forms.
Sure, writing a little VB *.frm-File-Parser for at least the intrinsic Controls is not really difficult.
(Below is an example, how a simple one could be structured, hosted in a "drop-in" *.bas-module).
 Originally Posted by yogiyang
Till here things seem to work to an extent. But unfortunately I am not able to find any way to link events of VB6 to Cairo GUI.
I guess, you mean: "How to link from the dynamically created cairo-Widgets to existing VB-EventHandlers".
There's several ways to do that - but it would be good when we could refer to the example below
(which currently only ensures the Widget-Construction from a given *.frm content-string) -
when talking about further examples or "ways to supply the demo with Event-Support"...
Here's the Demo in a Zip: Forms2Cairo.zip
Here's the *.frm File-Definition (no VB-code inside this VB-Form, just the VB-Form-Designer was used):

And here's, what the Parser creates on a cairo-WidgetForm:

Here's the same Widget-Form with Zoom-Factor=2 (as needed e.g. in High-DPI-scenarios):

Olaf
-
May 2nd, 2016, 01:22 AM
#3
Thread Starter
Addicted Member
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
Olaf,
This works like a charm as long as we do not use any inline control.
But how can we link event code entered in VB forms to the controls or is there any other way to write events in a module and link them at runtime?
TIA
Yogi Yang
-
May 4th, 2016, 06:02 AM
#4
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
 Originally Posted by yogiyang
But how can we link event code entered in VB forms to the controls or is there any other way to write events in a module and link them at runtime?
In the above example, the fMainDef.frm is just a "plain View-Definition" which contains
only the visual arrangements of intrinsic Controls using the normal VB-Form-Designer
(not a single Line of real Form-Code - and I would leave it that way...)
This View-Definition (fMainDef.frm) is currently never loaded by the Application (as a VB-Form) -
it is just parsed TextFile-Content, to produce a cWidgetForm-instance (with Replacements
of the intrinsic VB-Controls against their vbWidgets.dll Counterparts).
But, we have "The View" at least.
What now remains, is "The Model" (usually Recordsets, Arrays or Collections) which
contain the Data this "Form-View" will interact with - and we need "A Controller" too
(a Class, which handles the Events, the View will generate from User-Interaction).
As for the Model, you could mock that up with e.g. a Class, named cmMyModel:
Code:
Option Explicit
Public Function InitFromRecordset() As cmMyModel
Debug.Print "Model was initialized with concrete Data"
Set InitFromRecordset = Me
End Function
Public Sub SaveData()
Debug.Print "Saving Data from inside the Model-Class"
End Sub
With that Mockup-Model-Class in place, the Controller is not that difficult.
For example, when (in an existing, old VB-Form) you had Event-Handler-code for the
(yellow) Command1-Button of the above example, like:
Code:
Private Sub Command1_Click()
Model.SaveData 'just another terminology for e.g.: RsFormData.UpdateBatch
End Sub
Why not cut these Event-Handler-Definitions out from your original VB-Form -
and placing them (as Public Subs) in a Controller-Class - e.g. named ccMyController:
Code:
Option Explicit
Public Model As cmMyModel
Public Sub Command1_Click()
Model.SaveData 'just another terminology for e.g.: RsFormData.UpdateBatch
End Sub
In the aboves examples cfMain.cls (the WidgetForm) you could then extend the few lines
of code it contained, to the new code-content below (the additions are in dark-red):
Code:
Option Explicit
Public WithEvents Form As cWidgetForm
Public Controller As New ccMyController, Model As New cmMyModel
Private Sub Class_Initialize()
Set Controller.Model = Model.InitFromRecordset '<- intialize the Model - and make it known to the Controller as well
Set Form = Cairo.WidgetForms.Create(vbSizable)
' Form.WidgetRoot.Zoom = 2 '<- check, how the Widgets would be rendered in a High-DPI-scenario
Dim sFrmDef As String
sFrmDef = New_c.FSO.ReadTextContent(App.Path & "\fMainDef.frm") 'read the *.frm content
CreateWidgetsFromFrmDefOn Form, sFrmDef 'initialize from string (could also come from a DB-Field)
End Sub
Private Sub Form_BubblingEvent(Sender As Object, EventName As String, P1 As Variant, P2 As Variant, P3 As Variant, P4 As Variant, P5 As Variant, P6 As Variant, P7 As Variant)
' Debug.Print Sender.Widget.Key, EventName 'in case one wants to take a look, what all comes in here
If Sender.Widget.Key = "Command1" And EventName = "Click" Then Controller.Command1_Click
'or generically per: CallByName Controller, Sender.Widget.Key & "_" & EventName, VbMethod
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Forms.Count Then Unload fDummy 'exit from the VB-provided MessageLoop
End Sub
HTH
Olaf
-
Apr 29th, 2023, 10:52 PM
#5
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
how to download vbWidgets.dll?
err from here:
ClassName="cwframe"
Set New_w = CreateObject("vbWidgets." & ClassName)
-
May 1st, 2023, 12:28 AM
#6
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
 Originally Posted by xiaoyao
how to download vbWidgets.dll?
You get that file from the RichClient library:-
https://www.vbrichclient.com/#/en/Downloads.htm
At the top of the above page you will see two zips. The first one is contains that file.
-
May 1st, 2023, 04:55 AM
#7
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
 Originally Posted by Niya
At the top of the above page you will see two zips. The first one is contains that file.
FWIW, both "BaseDll-Package-Zips" contain an additional Widgets-Dll:
- it is named vbWidgets.dll in case of the older vbRichClient5.dll
- and named RC6Widgets.dll in case of the new RC6.dll
In both cases (if not already done), one will have to register them as the COM-Dlls they are,
before they can be selected in the Project-References Dialog...
Olaf
-
May 1st, 2023, 07:41 PM
#8
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
Yes, I forgot to register this DLL.
Maybe the best way is to turn it into a control.It is similar to the use of vB6 standard controls.Very easy to learn to use.
-
Sep 1st, 2023, 08:02 PM
#9
Addicted Member
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
At some point, jpbro is going to write us a converter to catapult us all from vb6 controls to Cairo widgets.
He's way too smart, industrious, savvy, and way too prosperous to let us languish in misery without this tool...
I hereby nominate jpbro for the job. 
Cheers
-
Sep 2nd, 2023, 10:31 PM
#10
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
 Originally Posted by taishan
At some point, jpbro is going to write us a converter to catapult us all from vb6 controls to Cairo widgets.
He's way too smart, industrious, savvy, and way too prosperous to let us languish in misery without this tool...
I hereby nominate jpbro for the job. 
Cheers
Yikes. I'm none of those things, and I don't think I've ever claimed to be. I'm not sure why I'm being passive-aggressively called out in this thread?
-
Sep 2nd, 2023, 11:51 PM
#11
Addicted Member
Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI
 Originally Posted by jpbro
Yikes. I'm none of those things, and I don't think I've ever claimed to be. I'm not sure why I'm being passive-aggressively called out in this thread?
jpbro, I sincerely apologize for that intent... I never meant anything like that! I just think you are the most qualified because of your extensive previous posts to compile them into some kind of resource for us all. Your command of extreme documentation in the reg-free RC5-6 led me to this conclusion. Please forgive the intrusion. Cheers bro, and peace.
Last edited by taishan; Jan 31st, 2024 at 07:02 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|