Results 1 to 11 of 11

Thread: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    [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

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

    Quote Originally Posted by yogiyang View Post
    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).

    Quote Originally Posted by yogiyang View Post
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    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

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

    Quote Originally Posted by yogiyang View Post
    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

  5. #5
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    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)

  6. #6
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

    Quote Originally Posted by xiaoyao View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  7. #7
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

    Quote Originally Posted by Niya View Post
    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

  8. #8
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    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.

  9. #9
    Addicted Member
    Join Date
    Feb 2022
    Posts
    217

    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

  10. #10
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,892

    Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

    Quote Originally Posted by taishan View Post
    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?

  11. #11
    Addicted Member
    Join Date
    Feb 2022
    Posts
    217

    Re: [VB Rich Client] - Possibilities of linking VB6 Object Events to Cairo GUI

    Quote Originally Posted by jpbro View Post
    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
  •  



Click Here to Expand Forum to Full Width