Results 1 to 4 of 4

Thread: [VB6 Menus + Toolbars] RC6 Challenges with Menus/Toolbars

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    [VB6 Menus + Toolbars] RC6 Challenges with Menus/Toolbars

    I literally spent this entire day (with the occasional breaks of course) studying and playing around with the RC6 Menus and Toolbars code.

    https://www.vbforums.com/showthread....=1#post4681121

    My old VB6 charting app uses a 3rd party Menu/Toolbar library called SSActiveToolbars (IIGToolBars50.ocx) from Infragistics. (And also their ActiveTabs Control IGTabs40.ocx).

    It has worked really well. Once I've added the control to the form, you click on 'Configure' and create your buttons, menu, etc.

    Clicking on a menu or toolbar button will trigger a ToolClick event where the Tool is passed and can be put through a Select...Case to execute the menu or button's action code.

    =====================

    So why am I bothering with the RC6 menu/toolbar code?

    1. Because I have RC6 already being used for Cairo and SQlite in my TestChart project.
    2. Figured if I can cut out additional controls, etc. and if simple enough, why not?


    After a whole day working on this, I think that there is just too much going on with the RC6MenuToolbar setup.

    I get it. The drop-in control clearly has much of this overhead stuff packed inside it and shields the complexity from users like myself.

    How far did I get with the RC6MenuToolbar?

    Well, I created a menu and a toolbar and added a couple of subitems to them. So setting up the MenuResources using JSON and cMenuItem wasn't too bad. I was able to follow how the Menu items and the Sub Menu items were tacked on and passed as the MenuBar.DataSource. Creating a few ToolbarEntries was also figured out.

    I tried to find just those methods required for creating the menus and tool buttons, and especially how to act on them. It got really deep when I tried to follow the HOME button action because it acted like the buttons I usually need. When you press it, it remains down (or appears so), until you click it again.

    But I had difficult figuring out how to interact with that button. And the Draw() routines I gather must all be for the simple illusion of a pressed button. That's a lot of graphics coding! Frankly, I don't really want to write a large chunk of code that just makes a button look pressed.

    Now I know that on the Form you have the Toolbar object where there are two methods: Click() and ArrowClick(). Click is obvious. ArrowClick is when you click the little arrow image found next to Dropdowns.

    So obviously for ToolBar clicks I can place a Select...Case to act on them based on "Sender.Caption". I can determine state based on "Sender.Checked".

    There is just so much going on several classes and interacting and creating the look and feel of toolbuttons that it is easy to get lost and overwhelmed and not simply focus on the area to add menus, toolbars, and their actions.

    =====================

    I have to wonder, is that the easiest that the RC6 menu/toolbar gets?

    MENUS are easy that comes with the VB6 IDE. Just use the Menu Editor.

    Toolbars, other than the control I added, I don't know.


    What are your thoughts on VB6 Menus and Toolbars? Found any easy menu/toolbar approaches?

    I'm going to stop here and take a break until tomorrow. Then I'll consider removing all those cwMenuBar and cwToolbar classes and declares and possibly add my 3rd party ActiveToolBars control to this TestChart project so as to proceed with functionality, UNLESS a reply to this thread gives me a better idea.


  2. #2
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    368

    Re: [VB6 Menus + Toolbars] RC6 Challenges with Menus/Toolbars

    This might help you? I don't use menu's or whatever yet. But I do use clickable buttons.
    I make all the buttons prior to running the game. So I do this function whenever I need a bunch of new buttons in their pushed states.

    Below is the code for examining a file, in a directory, and making a 'Pushed DOWN' version of it.
    It then saves said PNG into a directory called "DOWN" and adds the suffix " DOWN" to the new push button.
    One can modify it however, add glow lights, shrink it further etc. I found this does a nice job for what I'm making at least.




    I have the code for finding all buttons in a directory if you need it (not posted below)

    Code:
    Sub Button_Press_Image_Maker(My_Picture As String, My_Path As String)
    '---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===
    '   Make the Physical Image of a Button Press
    '---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===
    'This sub creates a button press image from the image provided
    Dim Height As Integer 'Get image dimensions
    Dim Width As Integer 'Get image dimensions
    Width = Cairo.ImageList.Item(My_Picture).Width 'Get image dimensions
    Height = Cairo.ImageList.Item(My_Picture).Height 'Get image dimensions
    Dim My_Surface As cCairoContext 'Surface for building the press image
    'Set the size of the surface
    Set My_Surface = Cairo.CreateSurface(Width, Height, ImageSurface).CreateContext
    'Blank the surface
    Call Blank_My_Surface(My_Surface)
    'Copy down the image, make it shrink a bit
    My_Surface.RenderSurfaceContent Cairo.ImageList.Item(My_Picture), 2, 2, Width - 4, Height - 4, CAIRO_FILTER_FAST
    'Create a darkened version of it
    My_Surface.SetSourceColor RGB(0, 0, 0)
    My_Surface.Operator = CAIRO_OPERATOR_ATOP
    My_Surface.Paint 0.33
    My_Surface.Operator = CAIRO_OPERATOR_OVER
    'Save that press button as an image
    Cairo.ImageList.AddSurface My_Picture & " DOWN", My_Surface.Surface
    'Save the File
    'Remove any .PNG from the filename first
    Call Remove_Dot_PNG_From_Filename(My_Picture)
    '----------------------------------------
    'Does the "DOWN" directory exist?
    If Does_Folder_Exist(My_Path & "DOWN\") = False Then
        MkDir (My_Path & "DOWN\") 'Make the directory as it doesn't exist
    End If
    '----------------------------------------
    'Save the image to the 'DOWN name'
    My_Surface.Surface.WriteContentToPngFile My_Path & "DOWN\" & My_Picture & " DOWN.png"
    End Sub
    Code:
    Public Sub Blank_My_Surface(Current_Surface As cCairoContext)
    '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    '   Blanks the surface sent to this routine
    '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    'Erase a surface of all data, making it transparent
    Current_Surface.SetSourceColor RGB(0, 0, 0), 0
    Current_Surface.Operator = CAIRO_OPERATOR_CLEAR
    Current_Surface.Paint
    Current_Surface.Operator = CAIRO_OPERATOR_OVER
    End Sub
    
    Public Sub Remove_Dot_PNG_From_Filename(ByRef Filename As String)
    '---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===
    '   Remove .PNG from a filename
    '---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===---===
    'This sub deletes the .PNG from an imagefile
    Dim Trimmed_Name As String 'Trimmed name
    Dim Text_Length As Integer 'Length of filename
    'Does it have .PNG in the name? If not, skip it
    If InStr(1, Filename, ".PNG", vbTextCompare) > 0 Then 'Check for PNG's Only
        '----------------------------------------------------------
        'Make the Trimmed name
        '----------------------------------------------------------
        Trimmed_Name = Filename 'Get the filename
        Text_Length = Len(Trimmed_Name) - 4 'find length minus .PNG
        Trimmed_Name = Left(Trimmed_Name, Text_Length) 'Cut out the .PNG
        Filename = Trimmed_Name 'return the value
    End If
    End Sub
    Last edited by -Corso->; Sep 20th, 2023 at 11:13 PM.

  3. #3
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,066

    Re: [VB6 Menus + Toolbars] RC6 Challenges with Menus/Toolbars

    Quote Originally Posted by webbiz View Post
    There is just so much going on several classes and interacting ...

    I have to wonder, is that the easiest that the RC6 menu/toolbar gets?
    Well, sometimes you complain that it is too "BlackBoxy" what goes on in RC6-Classes,
    (and that you'd prefer to "know exactly what happens") - now it's apparently too much "what's going on"...

    Anyways, if you want the whole Demo simplified,
    then use the default-"Widget-Encapsulation-lib" which ships in the RC6-Bundle: RC6Widgets.dll

    Here is the same Menu-Tool- and StatusBar-Demo, now making use of these precompiled Widgets:
    https://vbRichClient.com/Downloads/M...dStatusBar.zip

    For this whole bunch of (code-wise) predefined Menu- and Toolbar-Items (including Icon-Definitions) -
    the total Lines of Code in this Demo-Project are outright "sparse".

    And I dare say, that one is faster with Code-based (Copy&Pastable) MenuDef-Construction-Routines -
    than with VBs built-in Menu-Editor-GUI (with the additional advantage of "GitHub-Diffability").

    Another advantage is, full DPI-awareness (e.g. of Icon-Renderings in the ToolBars and Menus) -
    and the regfree deployability of the RC6-based stuff (no Common-Dialog-Controls needed and no OCX-dependencies).

    Your choice though... <shrug>

    Olaf

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Re: [VB6 Menus + Toolbars] RC6 Challenges with Menus/Toolbars

    Quote Originally Posted by Schmidt View Post
    Well, sometimes you complain that it is too "BlackBoxy" what goes on in RC6-Classes,
    (and that you'd prefer to "know exactly what happens") - now it's apparently too much "what's going on"...

    Anyways, if you want the whole Demo simplified,
    then use the default-"Widget-Encapsulation-lib" which ships in the RC6-Bundle: RC6Widgets.dll

    Here is the same Menu-Tool- and StatusBar-Demo, now making use of these precompiled Widgets:
    https://vbRichClient.com/Downloads/M...dStatusBar.zip

    For this whole bunch of (code-wise) predefined Menu- and Toolbar-Items (including Icon-Definitions) -
    the total Lines of Code in this Demo-Project are outright "sparse".

    And I dare say, that one is faster with Code-based (Copy&Pastable) MenuDef-Construction-Routines -
    than with VBs built-in Menu-Editor-GUI (with the additional advantage of "GitHub-Diffability").

    Another advantage is, full DPI-awareness (e.g. of Icon-Renderings in the ToolBars and Menus) -
    and the regfree deployability of the RC6-based stuff (no Common-Dialog-Controls needed and no OCX-dependencies).

    Your choice though... <shrug>

    Olaf
    Well, sometimes you complain that it is too "BlackBoxy" what goes on in RC6-Classes,
    (and that you'd prefer to "know exactly what happens") - now it's apparently too much "what's going on"...
    Me complain? Nah. I swane poetic.

    You're right. I do want to know what exactly happens in an educational way.

    As a production-way, I prefer the nicely packaged, easy to deploy, and well documented stuff.

    I don't mind the Copy/Paste approach for code that is like "copy these mods/classes, add this line to this, and to this. Now use these methods x,y,z to do this using this format..."

    Anyways, if you want the whole Demo simplified,
    then use the default-"Widget-Encapsulation-lib" which ships in the RC6-Bundle: RC6Widgets.dll

    Here is the same Menu-Tool- and StatusBar-Demo, now making use of these precompiled Widgets:
    https://vbrichclient.com/Downloads/M...dStatusBar.zip

    For this whole bunch of (code-wise) predefined Menu- and Toolbar-Items (including Icon-Definitions) -
    the total Lines of Code in this Demo-Project are outright "sparse".
    Well thanks for sharing those suggestions and link. I will spend today digging into this.

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