Page 1 of 2 12 LastLast
Results 1 to 40 of 52

Thread: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

  1. #1

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Resolved [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Hi all,
    Question regarding the setup of a class.
    I'd like to make the Class Universal, it's a new inventory screen, which will be used all over the place.
    But, the inventory screens for your character, merchants, bags, chests, etc are all different sizes.
    So, when I ask the class to initialize, during it's Initialize phase, it doesn't yet know the dimension size it wants to be.
    This is a problem as I need to draw borders, setup vertical scroll bars and so on, per each Inventory Screen.
    Ie: This doesn't work below, if I want to setup a matching size surface (for background pictures)

    Private Sub Class_Initialize()
    Set W = Cairo.WidgetBase 'Setup the Basic Widget
    '-------------------------------
    ' CREATE SNAKE BORDERS
    '-------------------------------

    Dim Width as integer: Dim Height as integer
    Width = W.Width'Get size of container, doesn't work as size isn't ready
    Height = W.Height'Get size of container, doesn't work as size isn't ready
    'Configure the drawing surface when started
    Set Border_Surface = Cairo.CreateSurface(Width, Height, ImageSurface).CreateContext
    End Sub

    So, I am unable to setup the backdrop, nor the Vertical Scroll Bar or any of the important dimensions till after the widget is fully created.

    Is there a way of doing this during the Initialize Phase? Or doesn't it work that way?

    Thanks for helps!

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

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by -Corso-> View Post
    Hi all,
    Question regarding the setup of a class.
    I'd like to make the Class Universal, it's a new inventory screen, which will be used all over the place.
    Then make this an "inventory-widget", which always pops up in the same size -
    and accounts for "different amount of records" by using a cwVList-Widget as one of its "Sub-controls".

    As e.g. shown here:
    https://www.vbforums.com/showthread....ame-Scenarios)

    The data-source for the Grid-like cwVList-Widget is (in that demo) a JSON-cCollection.
    But you can use also a cRecordset (derived from an SQLite-table) as the data-source.

    To make your inventory-widget-class generic, you can give it an Init-method,
    which allows to pass along parameters like e.g.:
    - a Caption (which you then set to a Label-Caption inside)
    - a DataSource (either as cCollection or as cRecordset) ... to fill the cwVList-grid with

    HTH

    Olaf

  3. #3
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Initializing a Class, where can I get or set size dimensions?

    I avoid classes as much possible.
    in my game, that is quite big already, I only have classes that are mostly one-way.
    so the music-engine and the direct2d-engine.
    everything else is modules.
    each one with specific needs.
    I do have one module that is the "core" module where the game-loop is, the key/mouse part, initialization and most structures (UDT) that will be used in the game.
    tons of PUBLIC variables that can be used anywhere.

    I did the mistake of using classes at the early stage of my development.
    and when I saw that I needed two-way communication and inter-communication between classes I gave up and rewrote everything.

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

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by baka View Post
    I avoid classes as much possible.
    Whilst that might have worked in your case - it's nevertheless bad advice.

    Quote Originally Posted by baka View Post
    I did the mistake of using classes at the early stage of my development.
    and when I saw that I needed two-way communication and inter-communication between classes I gave up and rewrote everything.
    Especially when it comes to "elegant-communication", Classes are the way to go...
    (Modules cannot "receive COM-Events" - and can also not raise COM-Events).

    Olaf

  5. #5

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Initializing a Class, where can I get or set size dimensions?

    Thanks Olaf,
    I've actually got the data in globals for the moment (for testing). So I'll worry about that a bit later.
    Right now I'm just trying to get a handle on reusing classes, a bit more throughly than what I am already doing.

    As another way to skin a cat, I just set up a Module which recieves the Class type and configures it.

    Set Inventory_Screen = W.Widgets.Add(New Class_Inventory_Universal, "Inventory_Screen", 40, 98, 820, 432, true)
    Call Setup_Class_Dimensions_And_Backing_For_Inventory_Screen(Inventory_Screen)'Setup the background, dimensions, VSB, picture, borders everything.

    This module re-positions everything and draws all the bits inside the Class instance (becasue it now knows it's size).

    So, it's what I need to call each time a new inventory screen is built. I was hoping to put all the dimensioning code inside the class (because I'm a neat freak). But I've never come across Init-method. ? How does one use that?

    Baka, classes are suuuuuper handy. They are a fast way of re-doing, buttons, screens, character portraits, icon sets. They do save a lot of time.
    Last edited by -Corso->; May 29th, 2023 at 03:23 AM.

  6. #6
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Initializing a Class, where can I get or set size dimensions?

    if u want performance, module > class.
    classes are a bit slower to use (just a bit)

    Olaf, if I follow your advice I would be posting thread like -Corso- asking for advice and help all the time.
    but guess what? I didnt and my game runs smoothly. no issues in fullHD mode, no issues adding any kind of UI,
    the game is multilayered, with effects, tons of animations, parallax, monsters running around.
    and I can show a UI above all that (like the inventory, bestiary, questscreen, settings etc) with hundreds of items,
    that I can hover with mouse to show another semi-transparent information panel and the CPU is still at 1-3% usage.
    also, when showing any UI above game-screen, I use a darkener layer.

    so, yeah. u know best right? as u always points out. and surely u do most cases, but this time you are wrong.
    modules are much better and RC6 is not the best to create games.

    now, I hope Corso the best. I like his project and want nothing for his success.
    and here u are very helpful (u always is) and in that aspect u should get credit for it.
    almost unlimited knowledge. but arrogance don't suit u.

    I know right now its too late. but if Corso would have started today, I would tell him, follow my advice.
    Im a game/game-editor creator for many years. I have learned from all my mistakes and today I have a working method that "maybe" seems odd for the VB6-programmer
    dil and others asks why Im using VB6 as Im not coding in VB6-like. and thats because Im coding to create a game that require a different approach.

    so back on subject.
    yeah. I like Class but I also dislike it.
    instead of a class I just use Arrays. here a picture of how it looks: https://i.postimg.cc/4xKSSC7H/Image1.png
    and as u see, classes are just for music/engine. a__xxxxxx (are used in my 2nd and 3rd EXE, so I have 3 EXE running. one for music+screenshot+wordchecker and one for sound)
    z_xxxxxx are editor-modules, so only used when in editor-mode. w_loadsaveUI will load/save quest-data but also save-file (as the game is real-time and saving is happening all the time)
    also important how u load/save to speed it up. I create a byte() using copymemory I fill it up and when done I save the whole byte. its much faster than saving UDT. (my quest-data is 25MB and saves are from 30-500kb)

  7. #7
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Initializing a Class, where can I get or set size dimensions?

    example how it works (theres are many different UI, theres like 40 of those here 2 to show)

    Code:
    Select Case .ui
                    Case 0 ' map
                        If Keys.Down Then MapMoveDown Ply.mm
                        If Keys.up Then MapMoveUP Ply.mm
                        If Keys.right Then MapMoveRight Ply.mm
                        If Keys.Left Then MapMoveLeft Ply.mm
                        If .Center Then MakeCenterMap
                        map_RenderBack
                        npc_render
                        mob_Render
                        map_RenderPortal
                        map_RenderFront
                        mob_FrontRender
                        npc_Bubbles
                        npc_FrontRender
                        map_OptionRender
                        Skills_Render
                        If .tick = 0 Then SecondOption
                        map_MapLoading
                        engine.Rendering
                    Case 1 ' inventory
                        map_RenderBack
                        npc_RenderEx
                        mob_RenderNon
                        map_RenderFront
                        inv_Render
                        map_OptionRender
                        map_MapLoading
                        engine.Rendering
    when 0, it means ure in "free-mode" u can move around. while 1, the inventory screen is open.
    each function calls to a specific thing. map_RenderBack is used in both while mob_Render I use mob_RenderNon where the monster is showing but not acting. we could say a "pause-mode"
    I found this structure easy and if I need a new UI I just add it. its easy to switch between UI, just change the ".ui" to the # I want. of course theres a "in-out" between UI, so I have a procedure for that
    what happens when u exit UI and enter UI. like a shop. if u moved items to the "exchange" screen but u didnt click "trade" those items need to get back to character inventory.
    and so on.

    not sure how u write your game, most likely different from me.
    another thing. each "function" is also in specific order.
    map_RenderBack will be drawn to a bitmap before npc_render. so of course UI need to be placed "after" as u see in inventory. inv_Render. is created above the other
    and engine.Rendering means it will render to screen.

  8. #8
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by -Corso-> View Post

    Set Inventory_Screen = W.Widgets.Add(New Class_Inventory_Universal, "Inventory_Screen", 40, 98, 820, 432, true)
    Call Setup_Class_Dimensions_And_Backing_For_Inventory_Screen(Inventory_Screen)'Setup the background, dimensions, VSB, picture, borders everything.

    This module re-positions everything and draws all the bits inside the Class instance (becasue it now knows it's size).

    So, it's what I need to call each time a new inventory screen is built.
    And you're right, that an internal method would be much "neater".

    I'm not entirely sure, whether you are aware about the "ton of W-Events" inside your own Widget-Classes...?
    After you have defined the usual: Private WithEvents W As cWidgetBase -
    you can (in the Class-Editor which contain this definition), use:
    - the left-top Editor-DropDown-list, to select one of the "Event-Throwing-Classes" (in our case "W")
    - the right-top Editor-DropDown, to select available Events (so far not used ones, are not rendered in Bold)

    Quote Originally Posted by -Corso-> View Post
    I was hoping to put all the dimensioning code inside the class (because I'm a neat freak).
    But I've never come across Init-method.
    Since you mainly want to react to "the new Widgets current dimensions",
    you don't need an additional (Public Init(...)) method -
    just placing your code inside the class-internal W_Resize() is probably enough.

    Please take a look at this small Demo (which will require RC6 and RC6Widgets references):
    cwInventory.cls
    Code:
    Option Explicit
    
    Private WithEvents W As cWidgetBase, WithEvents V As cwVScrollBar
    
    Private Sub Class_Initialize()
      Set W = Cairo.WidgetBase
      Set V = W.Widgets.Add(New cwVScrollBar, "V") 'add an internal Child-Widget to this Widget
    End Sub
    
    Public Property Get Widget() As cWidgetBase: Set Widget = W: End Property
    Public Property Get Widgets() As cWidgets: Set Widgets = W.Widgets: End Property
    
    Private Sub W_Resize() 'the first resize-event will happen, when the widget is "sited" (via Widgets.add)
      Debug.Print W.Width, W.Height
      V.Widget.Move W.Width - Cairo.Theme.GetScrollerSize, 0, Cairo.Theme.GetScrollerSize, W.Height
    End Sub
     
    Private Sub W_Paint(CC As RC6.cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
      CC.Paint 1, Cairo.CreateSolidPatternLng(W.FocusColor, 0.3)
    End Sub
     
    Private Sub V_Change() 'react to the Scroller-Event internally (or optionally re-raise it to the outside)
      Debug.Print V.Value
    End Sub
    Normal, empty VB-Form:
    Code:
    Option Explicit
    
    Private WithEvents Panel As cWidgetForm, Inventory As cwInventory
     
    Private Sub Form_Load()
      Cairo.ImageList.AddSurface "bg", Cairo.CreateCheckerSrf(4, &H444444)
      
      Set Panel = Cairo.WidgetForms.CreateChild(hWnd)
          Panel.WidgetRoot.ImageKey = "bg"
          Panel.WidgetRoot.ImageKeyRenderBehaviour = ImgKeyRenderRepeat
          Panel.WidgetRoot.Zoom = Panel.WidgetRoot.CurrentMonitor.Zoom
          
      Set Inventory = Panel.Widgets.Add(New cwInventory, "Inventory", 20, 20, 200, 200)
    End Sub
     
    Private Sub Form_Resize()
      ScaleMode = vbPixels: Panel.Move 0, 0, ScaleWidth, ScaleHeight
    End Sub
    Name:  SubWidgetResize.png
Views: 384
Size:  38.5 KB

    So, the above code has produced your Inventory-Widget with a single (Add)-line of code in Form-Load.
    All the rest (e.g. the positioning of its internal child-widget, the VScrollBar) happens internally in cwInventory.cls.

    HTH

    Olaf
    Last edited by Schmidt; May 29th, 2023 at 05:53 AM.

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by baka View Post
    ...so, yeah. u know best right? as u always points out.
    If that was the case, you'd be able to quote the passage where I said that.

    Quote Originally Posted by baka View Post
    ...and surely u do most cases, but this time you are wrong.
    If Classes were useless, they would not exist in any modern language ... period.

    Quote Originally Posted by baka View Post
    ... modules are much better ...
    That's incorrect - modules are *different* ... would be a true statement.

    Quote Originally Posted by baka View Post
    ... and RC6 is not the best to create games.
    You've never developed an RC6-based game - so you are not qualified to be the judge of that...

    And besides, Corsos question was not about "the game"(engine) itself -
    but about User-Interface-design - which is exactly the area, where Classes shine.
    (just in case you're not aware, VBs Forms and Controls all are based on COM-Classes.)

    Olaf

  10. #10
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Initializing a Class, where can I get or set size dimensions?

    but u dont use controls. u draw directly into the canvas.
    thats the difference. u create classes for all kinds of needs. u need to adjust its coordination, u need to know where it is in the "layer" depth.

    while I just draw directly into the canvas. theres no window/widget to think about. everything is in 1 canvas.
    when I need to create a button. I create a function in a module. lets take a button:
    that button function is making its shape, colors, sizes, font etc. so I can use the function "button" anywhere, how many times I need.
    the button will also tell me if the mouse is over, if I used the mousebutton and which one.
    I have numerous functions that creates different things. like the Inventory-Widget u showed. I have that too, and I decide 100% its graphic-style theres no limitation on that.

    benefit? they are all created in the "buffer" and rendered one time together with everything.
    if I need to resize. I just resize 1 canvas, not all pieces. if I need an effect on everything, I just do it in the "current" canvas step.
    like making it darker when more layers need to be draw above, say we add another "box-enter your name" and u want everything below it to be darker.

    I have been following Corso for awhile, and unfortunately I can't help him, since he is stuck with RC6.
    some things that he needs, I see that RC6 is good, can give him something now with a couple of lines.
    but some things require him lots of work to do, even limitation that force him to disable some effect, something that in my game-loop would have been easy to add without much efforts.

  11. #11

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Initializing a Class, where can I get or set size dimensions?

    Ah, the Resize event, makes sense.
    I got it working when I put all the dimension resizers in there.
    Thank you Olaf.
    Plus it's handy for the drag-resizing of the inventory window later too.

    Yes, Baka, it's a bit tricky learning this language. Not much resources. But the other way is even worse. Most of the DirectX-2d stuff has vanished or is unusable. I spent many, many fruitless days chasing rainbows.

    If Olaf, one day manages to hook up OpenGl, or the likes, then Cairo would be out of this world, and hyper relevant to actual real-life game design for pro's. If that does pair with cross platform one day and Twin Basic(I guess), then we are seriously talking heavyweight development. VB is super-speed-easy-code, Cairo is professional 'looking' everything, graphics card tie in would be insane.

    The main issues I find, I can't stuff code behind a button that I drew on screen. But, the counterwieght to that is, one can make incredible looking buttons and replicate it's functionality endlessly (via reusable classes). This is hyper-important, to make the visuals look 'Photoshop Perfect'. Good looking things attract your audience. What one sacrifices in ease of design, you get double that back with visuals and interoperability.

    There is a lack of material resource, 'simple' coding, 'one thing at a time', heavily green texted tutorials. And equally, full scale documentation. So, this is a big problem for newbies. I must admit, it's a definitive wall. There are some Pycairo resources, and they are good. But not everything is covered.

    So, it's a bit of a this or that. But, the thing is, once something is learned and clearer, it becomes quite wild on how one can utilize it in bizzare but cool ways in Cario.

    I can appreciate where you're coming from, but I'm super impressed with Cairo's functionality. So I'll stick with it.
    Last edited by -Corso->; May 29th, 2023 at 07:20 AM.

  12. #12
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by baka View Post
    I just draw directly into the canvas.
    ...theres no window/widget to think about.
    It's a bad idea, to put additional "strain" on the render-loop with additional UI-control-rendering.

    Corso is currently using an approach, which does render the (transparent) UI-TopLevel-Window -
    with "OS-GPU-support" on top of the render-output of the game-loop (which happens in a different Window below the UI-Window).

    It's much better desinged this way.

    With your approach, you cannot write a similar example to the one I've posted above -
    not with the same amount of code-lines...
    Sure, with a few "helper-functions" you can save some of these lines -
    but your helper-functions are game-specific implementations -
    far less generic (commonly usable), to what one can accomplish with Class-based UI-hierarchies.

    Quote Originally Posted by baka View Post
    I have been following Corso for awhile, and unfortunately I can't help him, since he is stuck with RC6.
    I'd say, that his game-renderings play in a different league entirely (compared to yours).
    You never posted ScreenShots of your game, why?

    Quote Originally Posted by baka View Post
    ... some things require him lots of work to do, ...
    If you are so sure, then by all means specify them - don't make blanket statements about things you have no experience with.

    Quote Originally Posted by baka View Post
    ...even limitation that force him to disable some effect,
    something that in my game-loop would have been easy to add without much efforts.
    No, neither you, nor the trick have posted so far, how to accomplish a true "Overlay-Blend-effect" via Direct2D.
    (which in cairo is a one-liner).

    So, please post code...

    Olaf

  13. #13
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by -Corso-> View Post
    The main issues I find, I can't stuff code behind a button that I drew on screen.
    I don't understand whether this was related to baka's "way of drawing buttons" -
    or to "the cairo-widgets-way" of using button-Classes (like cwButton for example) in an UI-Hierarchy.

    Do you mean "Click-Event-utilization" (when you talk about "stuffing code behind a button")?

    Olaf

  14. #14
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Initializing a Class, where can I get or set size dimensions?

    please be careful Olaf.
    u think your classes are floating outside the computer?
    anything u see is doing the same circle of painting to the monitor.

    the difference is that I prepare it beforehand and let direct2d send it to the monitor at the right time.
    while your classes will do it as well even if u don't need to tell it. the same is any component in vb6.
    that is why double-buffering is important and works.
    we could say I work in low-level while u work in mid-level. since I handle the paint event as well.
    while I just paste a bitmap into a bitmap u need the class-object. I wonder who are straining more? its ridiculous if u think my approach takes more strain than your RC6.

    also, since I work in multilayer. everything is changing constantly so, the canvas most of the time need to be repainted completely.
    to be able to "not do it" will require lots of checks. better to just cls every circle. the bitmap are already there so no need to create those.
    its just paste into the canvas. its like calling bitblt.

    the trick shared something to add effects. but its nothing I need. I dont need blurry effect in my game so I have not added it.
    the same way I dont need directwrite even if its available, as I work in bitmap-fonts.

    anyway, Corso, as long it works for u and u can do what u need and want, go for it.
    RC6 seems to be good enough for your need, while for me its a bad choice. I rather use a typelib and directly use that engine power.
    and I can use direct2d and wic, quite robust and strong, and I can use webp without adding anything to the code.

  15. #15
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by baka View Post

    I just paste a bitmap into a bitmap u need the class-object.
    I wonder who are straining more?

    its ridiculous if u think my approach takes more strain than your RC6.
    Your "pasting-operation" is part of your renderloop.

    In Corsos case, the UI is not part of the renderloop.

    Instead the UI is rendered into a separate hWND, which for the most time -
    is not requiring any redrawing - but just "sits there, statically" ...
    Leaving the OS==DWM.exe - with the task of the GPU-powered-Alpha-Overlay of this mostly static UI-Window.
    Meaning, that the Process which hosts the Game, is absolutely unaffected with the (overlayed) UI-Window as long as it is static.

    You have much to learn still, when it comes to "low-level" baka.

    Olaf

  16. #16
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Initializing a Class, where can I get or set size dimensions?

    Let me see if I can add some clarity to this argument. Having some a bit of experience with this myself I think I can understand where baka is coming from.

    It's not that classes are useless for writing games. I mean if you look at the Doom source code, you'd see classes all over the place. I'd say it's a very good way to represent in-game entities. Now that being said, what you do not want to do is create and destroy objects in your game's hot-paths. That's a big no-no. If you have a game that runs at even a modest 30 FPS, I think we can all agree that creating and destroying hundreds of objects on every frame would eat your performance. It's a very easy trap to fall into when you venture into this kind of thing for the first time.

    As for the comment about RC not being viable for games, I think what he really means is Cairo is not viable which objectively speaking isn't true. You can make games with Cairo. However you will be somewhat gated due to the fact that Cairo is not hardware accelerated. You see, for some games you might find yourself composing scenes that require a lot of blending operations. I'm talking from dozens to hundreds of blending operations per frame and at high frame rates, you are going to suffer using software rendering. I've had this experience using GDI and GDI+ renderers and moving to something that provides hardware acceleration made those problems go away.

    Now based on the screenshots I've seen of Corso's game, I think he will be fine with Cairo because of the nature of his game. He seems to be making an RPG type game like Zelda. Typically these class of games don't have much happening on screen. You might have a few entities moving, like maybe a bird or two flying across the screen with the player fighting an NPC or something but the scenes are mostly static and unchanging. He can definitely get away with a software renderer here.
    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

  17. #17
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by Niya View Post
    He can definitely get away with a software renderer here.
    Yes, but your comments are also still "game-loop related".

    What Baka does not understand in this context is,
    that one can move out the UI-rendering completely (from the game-loop) -
    and still show the UserInterface "as if embedded in the game, without the user noticing" -
    when the Win-OS-support (via DWM.exe) for TopLevel-AlphaOverlay-rendering is used.

    *That* was my point ...
    (and that "classes are useful, especially for UI-purposes" goes without saying).

    Edit: have posted a zipped code-example for that "UI-isolation-approach" in this prior thread here:
    https://www.vbforums.com/showthread....=1#post5567473

    Olaf
    Last edited by Schmidt; May 29th, 2023 at 09:21 AM.

  18. #18
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Initializing a Class, where can I get or set size dimensions?

    Well if the game loop isn't involved then yea, there is a lot of breathing room. I'm familiar some of the problems baka is talking about but you're correct, it's really only about the game loop. It's very easy to tank your framerate in a game-loop if you're not careful about how you implement things.
    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

  19. #19
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Initializing a Class, where can I get or set size dimensions?

    u will never be able to do my game with your approach Olaf.
    I can't do it with GDI32 and I was using only alphablend. some maps I got fps under 10 if trying to upscale.

    the game is kind of like this: https://www.youtube.com/watch?v=bh4Uo66ClaQ
    in terms of background, animations, movements etc. of course its different, but still like this.
    plus my game is RPG with thousands of items, hundreds of monsters. the entire package is around 2GB of assets (music included)

    of course I can add classes instead of hosting the characters/mobs/pictures/etc in arrays.
    but the difference is minimal. in classes I need to create and destroy when changing maps.
    in my case, I just call the "map-cleanup" that will destroy the bitmap of each (different) monster and after that erase the monster-array.

    also, everything is exposed. I can use the monster-UDT array when I call the inventory, library, bestiary.
    its available in the editor-zone. I don't need to think of "class.getmonsterwidth" I just use mob(150).whateverproperty and its done
    and this is true for everything.

    my first attempt of the game, many years ago, I did have "classes" and "hwnd" windows to show stuff. it was terrible.
    surely your RC6 is much better. but Im sure I would get to a point where I would get stuck and forced to redo everything. because u can not do magic.
    Last edited by baka; May 29th, 2023 at 10:44 AM.

  20. #20

  21. #21
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by The trick View Post
    I was going through this, as soon as you posted it - but "the Overlay" we were talking about
    (as a performance-degrading operation, when applied to the "total Surface-area" in a final call in corsos renderloop) -
    was not really related to the "common understanding" of the term.

    In Corsos scenario it means a very specific "math-pixel-blend-op", which is defined in Adobe- and cairo-docus:
    - usable via Cairo-wrapper by applying CAIRO_OPERATOR_OVERLAY
    - and an explanation where I pointed out the underlying math-terms is here: https://www.vbforums.com/showthread....=1#post5597129

    Not entirely sure, whether I've overlooked this exact blend-operation in your Linked examples -
    but I think not.

    Olaf

  22. #22
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,671

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by Schmidt View Post
    I was going through this, as soon as you posted it - but "the Overlay" we were talking about
    (as a performance-degrading operation, when applied to the "total Surface-area" in a final call in corsos renderloop) -
    was not really related to the "common understanding" of the term.

    In Corsos scenario it means a very specific "math-pixel-blend-op", which is defined in Adobe- and cairo-docus:
    - usable via Cairo-wrapper by applying CAIRO_OPERATOR_OVERLAY
    - and an explanation where I pointed out the underlying math-terms is here: https://www.vbforums.com/showthread....=1#post5597129

    Not entirely sure, whether I've overlooked this exact blend-operation in your Linked examples -
    but I think not.

    Olaf
    See Overlay demo. https://learn.microsoft.com/en-us/wi...direct2d/blend

  23. #23
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by The trick View Post
    Ok, have indeed overlooked the Overlay-Operator ... (sorry for the noise...)

    It's included in the MS-enum - and the math-formula seems to be the correct one, too.

    So, Corso now has a fast way (about 1msec according to my timings),
    to perform these "final sunrise/sunset-blend-ops" on his large "aggregating game-Surface".
    (if he doesn't want to wait for my cOGL2D.cls, which I'm still working on).

    Olaf

  24. #24

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by Schmidt View Post
    I don't understand whether this was related to baka's "way of drawing buttons" -
    or to "the cairo-widgets-way" of using button-Classes (like cwButton for example) in an UI-Hierarchy.

    Do you mean "Click-Event-utilization" (when you talk about "stuffing code behind a button")?

    Olaf
    I'm referring to the nice-ness of VB6 object placement:
    1) One just places a preset button on a page and lines it up visually.
    2) Put a number "0" in the Index box to make instant replicants.
    3) You always know immediately where to look in the code if you want to find a button's function.

    Cairo doesn't do that as nicely. So I often find myself hunting in various spots trying to find where the button code is, or similar such things. Ie: stuffing code behind a button, I at least know where the code it is without thinking about it.
    It's a slight issue, as the more elements, the more hunting. Because classes are used all over the place, buttons can come from vastly different areas. So I'm purposefully trying to put as much relevant code in classes now, just to make finding things easier.

    And yeah, I'll definitely wait to see the OpenGL implementation. That will be crazy.

  25. #25

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Ok, another question.

    I'm now making a Universal Filter Bar, this hosts the 'press and hold' buttons for filtering data in the Universal Inventory.
    So far, it sends the Class the images and positions of the buttons, and then it builds them.
    Pressing the buttons shows the 'Pressed' version picture.
    So far, so good.
    But, here is the problem.
    I need to reset all the 'active buttons' to their unpressed versions due to functionality. Ie, choosing another button resets all the other buttons pictures back to default.
    I've got all the button picture names in a cCollection, which works for sender, press event very nicely.

    But, I need some kind of Object Array for storing all the active buttons. But Classes don't like arrays in the declaration area.

    How does one store a collection of Buttons in a class?
    Ie:
    Public Button_0 as cwImage
    Public Button_1 as cwImage
    Public Button_2 as cwImage
    Public Button_3 as cwImage

    This would allow me to reset all their images in a loop, (except for the pressed button number).

    Thanks for helps!

  26. #26

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Ah, never mind, I feel stupid.
    Private Button(10) as cwImage
    does the trick.
    Last edited by -Corso->; May 29th, 2023 at 11:40 PM.

  27. #27

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?


    And now we have the second component. A self building filter bar.
    It just digs in a directory for the image buttons, makes the pressed versions, then assembles them on the filter bar. It figures out their size and positioning on the fly.
    So, to add more filters, one only needs to draw the button.
    I'll also do this with the sorting bar.
    Filtering/sorting is not functional for the new one yet, the old one was. This new version when done will allow bags, chests, buckets, merchants and general inventories to arrange how you want (from their respective picture directories). Which means it's super handy. Different buttons sizes, different styles, and repositioning/resizing of the bars too.
    The big snake widget below is also part of the new Universal Inventory. Making that functional comes after the sorting bar. Ie: re-hooking-up the inventory to the new display.

  28. #28
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by -Corso-> View Post
    Ah, never mind, I feel stupid.
    Private Button(10) as cwImage
    does the trick.
    If you need to arbitrarily insert/remove cwImage objects from the array, it would be worth taking a look at the RC6.cArrayList class.

    Below is a quick comparison using RC6.cArrayList for inserting/removing cwImage objects vs. a vanilla VB6 Array (untested air-code, but it should illustrate the advantages of cArrayList vs. Array for inserts/removals):

    Code:
    Option Explicit
    
    Private mo_Images As RC6.cArrayList
    Private ma_Images() As cwImage
    
    Private Sub Command1_Click()
       ' Compare RC6.cArrayList vs. VB6 Array Intialization
       InitArrayList 10 
       InitArray 10
       
       ' Compare RC6.cArrayList vs. VB6 Array Insert at arbitrary index
       InsertIntoArrayList New cwImage, 5
       InsertIntoArray New cwImage, 5
    
       ' Compare RC6.cArrayList vs. VB6 Array Remove at arbitrary index
       RemoveFromArrayList 5
       RemoveFromArray 5
    End Sub
    
    Private Sub InitArrayList(ByVal p_Count As Long)
       ' Initialization of cArrayList and VB6 Object Array is about the same amount of code
       
       Dim ii As Long
          
       Set mo_Images = New_c.ArrayList(vbObject)
       
       For ii = 1 to p_Count
          mo_Images.Add New cwImage
       Next ii
    End Sub
    
    Private Sub InitArray(ByVal p_Count As Long)
       ' Initialization of cArrayList and VB6 Object Array is about the same amount of code, but has the risk of making an off-by-one error with your Array UBound
       
       Dim ii As Long
       
       ReDim ma_Images(0 to p_Count - 1)
       
       For ii = LBound(ma_Images) To UBound(ma_Images)
          Set ma_Images = New cwImage
       Next ii
    End Sub
    
    Private Sub InsertIntoArrayList(po_ImageObject As cwImage, Optional ByVal p_BeforeZeroBasedIndex As Long = -1)
       ' Inserting objects into a cArrayList is a simple one-liner
       
       ' If p_BeforeZeroBasedIndex < 0 then the object will be added to the end of the arraylist
       
       mo_Images.Add po_ImageObject, p_BeforeZeroBasedIndex
    End Sub
    
    Private Sub InsertIntoArray(po_ImageObject As cwImage, Optional ByVal p_BeforeIndex As Long = &H80000000)
       ' Inserting objects into an array requires more lines of code, and opens up the risk of logic errors
       ' (did I get my indexes right? I may have an off-by-one error)
       
       ' If p_BeforeZeroBasedIndex = &h80000000 then the object will be added to the end of the array
       ' Hopefully our array doesn't have an LBound of &h80000000!!
       
       Dim ii As Long
       
       ReDim Preserve ma_Images(LBound(ma_Images) To UBound(ma_Images) + 1)
       
       If p_BeforeIndex = &H80000000 Then
          ii = UBound(ma_Images)
       
       Else
          For ii = UBound(ma_Images) To p_BeforeIndex + 1 Step -1
             Set ma_Images(ii) = ma_Images(ii - 1)
          Next ii
       End If
       
       Set ma_Images(ii) = po_ImageObject
    End Sub
    
    Private Sub RemoveFromArrayList(ByVal p_ZeroBasedIndex As Long)
       ' Removing objects from a cArrayList is a simple one-liner
       
       mo_Images.Remove p_ZeroBasedIndex
    End Sub
    
    Private Sub RemoveFromArray(ByVal p_Index As Long)
       ' Removing objects from an array requires more lines of code, and opens up the risk of logic errors
       ' (did I get my indexes right? I may have an off-by-one error)
       
       Dim ii As Long
       
       For ii = p_Index + 1 To UBound(ma_Images)
          Set ma_Images(ii - 1) = ma_Images(ii)
       Next ii
       
       ReDim Preserve ma_Images(LBound(ma_Images) To UBound(ma_Images) - 1)
    End Sub
    Last edited by jpbro; May 30th, 2023 at 07:50 AM.

  29. #29

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Private mo_Images As RC6.cArrayList

    Ah, neat. Thanks JpBro. I'll see about changing things.

    Ok, but how does one change or select something once it's in the array list?

    Like below: Each contain cwImage
    'Set the positions
    Button(A).Widget.Move X + A * dX, 0, dX, dY

    'Set the positions
    Arraylist_Button(A) ???
    Last edited by -Corso->; May 30th, 2023 at 05:00 PM.

  30. #30
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    You can access the ArrayList objects directly like this:

    Code:
       mo_Images(A).Widget.Move X + A * dX, 0, dX, dY
    But you lose Intellisense. To get Intellisense, you can declare a cwImage variable and Set it to the return value of the cArrayList at a specific index:

    Code:
       Dim lo_Image As cwImage
    
       Set lo_Image = mo_Images(A)
       lo_Image.Widget.Move X + A * dX, 0, dX, dY
    Since it's kind of annoying to have to declare variables everywhere you want to access a cwImage object, you could create a helper function that returns a cwImage (something like the GetImage function below):

    Code:
    Private Function GetImage(ByVal p_ZeroBasedIndex As Long) As cwImage
       Set GetImage = mo_Images(p_ZeroBasedIndex)
    End Function
    
    Private Sub Command1_Click()
       GetImage(A).Widget.Move X + X * dX, 0, dX dY   ' No cwImage temp variable to declare + we get to use Intellisense :)
    End Sub

  31. #31

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Ok, that's kinda handy as I can swap the code for what I've already got.
    Buuuuuuuut,
    Tell me if something is wrong here. I'm only using Rc6

    Declare section:
    Private Button As cArrayList
    Class_Initialize Section:
    Set Button = New_c.ArrayList(vbObject)
    Resize Section:
    Button.RemoveAll ' I assume this clears anything, I need to do this on resizing the window each time.
    Dim A As Integer
    For A = 0 To Button_Image_Names.Count - 1 'This cCollection has all the button names
    Button.Add New cwImage'Pop cwImage into the Arraylist
    Next A
    'Configure all the buttons
    For A = 0 To Button_Image_Names.Count - 1
    'Set the positions
    Button(A).Widget.Move X + A * dX, 0, dX, dY
    'Get the image name
    Image_Name = Button_Image_Names.KeyByIndex(A)
    'Set the image
    Button(A).Widget.ImageKey = Image_Name
    'Switch it on
    Button(A).Widget.Visible = True
    Next A

    All the above works for Button(n) as a normal VB object array. But nothing shows when it's an arraylist.
    Not sure why?

  32. #32
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by -Corso-> View Post
    All the above works for Button(n) as a normal VB object array. But nothing shows when it's an arraylist.
    Not sure why?
    I don't see anything obvious that would prevent buttons from appearing using a cArrayList vs. using regular VB Arrays, but that's assuming the air-code is equivalent to the real code.

    The first thing I would do is check the values of X, dX, and dY to make sure they are as expected, but please post some actual working/non-working code that can be compared if possible.

  33. #33
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Just want to mention, that neither a Private "normal Array", nor a cArrayList should be needed -
    (especially, when there's a Container-Widget, which holds only ChildWidgets of one specific type and purpose)

    When we talk about cw-Classes (Widgets) - these only really come to live,
    when they are "sited" at some time - via SomeContainerParent.Widgets.Add(...)

    And it is that Widgets-Collection (let's say in a cwMyButtonBar-Container-Widget) -
    which holds all children - and is making these child-widgets enumerable and accessible:
    - at the inside (of cwMyButtonBar) via W.Widgets
    - as well as on the outside via oMyButtonBarInstance.Widgets.

    The Widgets-Collection allows access to specific Widgets via their Key, given at "Add-Time" -
    or alternatively via one-based-Index.

    For Control-Array like scenarios, these work best when an "easy splittable Key" like "Btn_0" - "Btn_10" is used.

    One can then easily detect (in the Bubbling-Event of the Container, as e.g. cwMyButtonBar) -
    which of the Child-Widgets was clicked just now - and - assuming an "OptionButton-Group-scenario":
    - the prefix of these Keys (e.g. "Btn_") can be used to "uncheck all Widgets in that group in an enumeration over W.Widgets"
    - after that, Sender.Checked = True could be set - and the current Sender.Widget.Key could be stored in this Parent
    ..(e.g. to hand out a "CurrentlySelectedFilterButton" via a nice Public Property Get-definition)

    Olaf

  34. #34

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by jpbro View Post
    I don't see anything obvious that would prevent buttons from appearing using a cArrayList vs. using regular VB Arrays, but that's assuming the air-code is equivalent to the real code.

    The first thing I would do is check the values of X, dX, and dY to make sure they are as expected, but please post some actual working/non-working code that can be compared if possible.
    Ok, will do in a while. I'm currently rewritting the whole Items/input module into a more streamlined system. (That's all the pickup-able game things (for the inventory)). So, the whole thing is offline till that's done. Might be a tomorrow thing for the above samples.
    Well, I can't check the value of x/y right now, but I can state that
    :Private Button(9) As cwImage as a vb array was straight up replaced with
    :Private Button As cArrayList

    The code in the resize event ends up being identical.
    ie:
    Button(A).Widget...

    So, I didn't do anything at all to the code, apart from declaration and Intialize. The VB array works perfectly.
    Anyway, when I get this overhaul done I'll post both.

    Ok Olaf, that's some thinking I'll have to do to make sure I understand. I'll take a closer look when I'm done with the above. Though, the Button(A) array thing is still pretty fast and clean for handling stuff.

  35. #35

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Ah, the new Item Loader is done. Hmmm, rather smoothly. I was expecting it to take a bit longer, but copy pasting old code makes it easy.
    Every item now lives in a cateogry folder, with manifest. So, no more giant spreadsheet of data,price,weight,description,etc. Makes it easy for me to add stuff over time.

    Here's the code for button-ation of the filter bar, this works well using the old VB array. Max of 9, which needs to change (now that the new Item Category thing is done).

    I just can't get it to work with the arraylist, as per up above in the earlier code.
    I removed all the button pressing, image changing, bubbling event code.

    Code:
    Option Explicit
    '---===---===---===---===---===---===---===---
    '   Class_Inventory_Universal_Filter_Bar
    '---===---===---===---===---===---===---===---
    'This class makes the Multipurpose Inventory System Filter bar and buttons
    Private WithEvents W As cWidgetBase 'Allocate the object. Set it up
    Public Button_Image_Names As cCollection 'Record of all the BUTTON IMAGE NAMES for the (Cairo Imagelist)
    Private Button(9) As cwImage 'The private list of buttons 
    '------------------------------------------------
    Private Sub Class_Initialize()
    Set W = Cairo.WidgetBase 'Setup the Basic Button
    W.ImageKeyRenderBehaviour = ImgKeyRenderNone 'Switch to render only when required
    '------------------------------------------------
    'NOTE: All buttons are setup externally
    Dim A As Integer 'Counter
    'Instantiate the buttons to a default value
    For A = 0 To 9
        Set Button(A) = Widgets.Add(New cwImage, "Button" & CStr(A), 0, 0, 10, 10, False)
    Next A
    'Setup the button image names colleciton.
    'These image names are used to also make the pressed versions.
    Set Button_Image_Names = New_c.Collection
    'NOTE:
    'Call Load_All_Images_Items_And_Names_Into_An_Array()
    'is used to load in all the directory images. It is done externally.
    End Sub
    
     
    Public Sub W_Resize()
    '-------------------------------------
    '   PLACE ALL THE BUTTONS
    '-------------------------------------
    On Error GoTo Error_Term
    'Is there anything in the collection yet?
    If Button_Image_Names.Count >= 1 Then
        'Yes, we have actual content
        Dim X As Integer 'X position start
        Dim Y As Integer 'Y position start
        Dim dX As Integer 'Width
        Dim dY As Integer 'Height
        Dim A As Integer 'Counter
        Dim B As Integer 'Maximum amount of buttons
        Dim Image_Name As String 'Get the image name
        'We now need to structure out all the buttons given, draw their image and visibly show them
        'Get the image name from 1st entry, required to find sizes. Note: All images are the same size.
        Image_Name = Button_Image_Names.KeyByIndex(1)
        'Set the image
        dX = Cairo.ImageList.Item(Image_Name).Width 'Set the dimensions
        dY = Cairo.ImageList.Item(Image_Name).Height 'Set the dimensions
        X = 0 'Set the dimensions
        Y = 0 'Set the dimensions
        B = Button_Image_Names.Count - 1 'Subtract 1, as we start from 0
        'Run through all of the buttons
        For A = 0 To B
            'Set the positions
            Button(A).Widget.Move X + A * dX, 0, dX, dY
            'Get the image name
            Image_Name = Button_Image_Names.KeyByIndex(A)
            'Set the image
            Button(A).Widget.ImageKey = Image_Name
            'Switch it on
            Button(A).Widget.Visible = True
        Next A
        '------------------------------------
        '   RESIZE THE ENTIRE BAR
        '------------------------------------
        W.Move W.Left, W.Top, (B + 1) * dX, W.Height 'Resize to match the number of buttons
    End If
    Exit Sub
    Error_Term:
    End Sub

  36. #36
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    FWIW, here's an Implementation of your scenario, "as minimally as possible", using:
    - fTest.frm (with cWidgetForm-Panel) as "Root"
    -- cwInventory.cls (as the larger Container for Inventory-Listings)
    --- cwFilterBar.cls (as the "ToolBar-like Container, which aggregates the "Buttons")
    ---- cwFilterBtn.cls (as a self-implemented Image-based Button-Widget, at the lowest level)

    So, the above does not use any pre-defined Widget from RC6Widgets.dll (only an RC6-reference is needed).
    The code per module above, amounts to only ~15 lines on average.

    Here is, what it looks like:
    Name:  FilterBar.png
Views: 307
Size:  70.0 KB

    And here's the Source-Zip:
    FilterBar.zip

    Perhaps that gives you some ideas, you might "steal" from it...

    Olaf

  37. #37

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Ah, so this is the operative function

    For Each Chld In W.Parent.Widgets
    Chld.Checked = False
    Next

    Seeing your filter buttons are in another class, will the above work within the filterbar?
    As in cwImage 's built/declared inside the filterbar (not an external class)?

  38. #38
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    Quote Originally Posted by -Corso-> View Post
    Ah, so this is the operative function

    For Each Chld In W.Parent.Widgets
    Chld.Checked = False
    Next

    Seeing your filter buttons are in another class, will the above work within the filterbar?
    If you want to deactivate the cwFilterBtn - W_Click-Handling -
    and instead shift the Handling into the Parent-Widget (cwFilterBar) -
    then the following should work (inside its Bubbling-Event)
    Code:
    Private Sub W_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)
      If EventName = "W_Click" Then
      
         Dim ChSt: ChSt = Sender.Checked 'buffer the checked state
         Dim Chld: For Each Chld In W.Widgets: Chld.Checked = False: Next 'ensure that all children get unchecked
         Sender.Checked = Not ChSt 'set the new "checked state" on the Sender
         W.Refresh 'let's "refresh ourself" (this Bar, and all its child-widgets)
         
         RaiseEvent FilterChanged(Sender) 'and inform the outside world, of what just happened
      End If
    End Sub
    Though note, that the cwImage does not have a Checked-Property you can read- and set.

    Quote Originally Posted by -Corso-> View Post
    As in cwImage 's built/declared inside the filterbar (not an external class)?
    I'd suggest, that you define your own little cwImageBtn or cwImageSomething Class -
    to be able to define a few Extra-Properties - and Events on it, which match better with your use-cases (as e.g. multiple Images for Up- Down- etc.).

    The cwImage is a very simple Widget and easy to replace with your own "nearly bare-bone" Class -
    because in its Paint-Event - you will only have to ensure "stretched rendering of the current W.ImageKey" in a single Line, this way:

    Code:
    CC.RenderSurfaceContent W.ImageKey, 0, 0, W.Width, W.Height
    That's basically, what my little cwFilterBtn already does, which you could use as a template for your own Image-Widget-Class.

    HTH

    Olaf

  39. #39

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    I was using the just using the Button(A).Widget.ImageKey to tell me what state the button was in, when one compares it to it's original keyword, Button_Image_Names.KeyByIndex(A). If they don't match, then the button is Down.

    I'm deciphering your example now. But, will have to stop soon due to sleep deprivation. I noticed a few new magic words in there I haven't seen before.

  40. #40

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: [RESOLVED] Initializing a Class, where can I get or set size dimensions?

    By the way, do you have any demos on these terms? "New_c.FSO"
    I noticed a few neat things in there, like checking for file existence, and getting a directory list. But I have no idea where to start looking for usage info...

Page 1 of 2 12 LastLast

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