Results 1 to 11 of 11

Thread: [RESOLVED] Lightweight Windowed Control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    350

    Resolved [RESOLVED] Lightweight Windowed Control

    What windowed control uses the least resources?

    I need something like a picturebox to use as a control handle to move and size controls. I understand that a picturebox uses a lot of resources so what might be the best windowed control to use that I can use like a picturebox for a handle.

    e.g. I can use a command button however it has a poor appearance as a handle because I cannot get it to look like a box since I cannot get the border to disappear.

    I need something that looks like a window object handle.

    Also, how can I tell the magnitude of resources used by a control ?
    Last edited by LorinM; Apr 14th, 2024 at 01:15 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,436

    Re: Lightweight Windowed Control

    A Frame?

    Quote Originally Posted by LorinM View Post
    Also, how can I tell the magnitude of resources used by a control ?
    If you use less than 10000 I don't think you'll have problems with anyone.

    About resources: https://www.vbforums.com/showthread....t-of-resources

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,738

    Re: Lightweight Windowed Control

    To my way of thinking, there are two issues, with a third consideration.

    1. Does it have a hWnd?
    2. Does it have a DC?
    3. Is it a single control or multiple controls? If multiple, the above two must be considered for each of them.


    And even some of the intrinsic control, such as the ComboBox are actually multiple controls.

    For the most part, the rest of it is window dressing, which isn't going to affect system resources much. Sure, many will have code that executes on a resize message (such as the frame re-drawing its border and caption), but that's really not going to consume resources.

    But yeah, these days, with the memory and horsepower we have, it takes a lot to really "feel" any lag from too many controls.

    p.s. Lightweight windowed control is really an oxymoron. The typical definition of a lightweight control is that it's windowless (i.e., no hWnd, and just drawn directly onto its parent).
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    350

    Re: Lightweight Windowed Control

    In my specific case for this question, I have two indexed controls. Based on Eduardo's suggestion the would be the pair fraHandleBeg(0), fraHandleEnd(0) and there would be (n) of each as desired by the user.

    Eduardo, Thank you for the Resources Code !

    My problem is this.
    I want to draw shapes on a form surface that I can move and size. A shape can be a component shape or a control. Component shapes are discoverable if not mouse-clickable.

    Other than a line, all is good and working well since I can do all I want and it only takes 9 handles total since handles can move to the the clicked on shape.

    But with lines there is a problem. If the Line is vertical or horizontal it is difficult to click on the line since there is no "open" area. Also, a box handle set for a line is not intuitive how to move the line. But if each line has a handle on its ends, that handle or the line can be clicked on. So for each line drawn to be manipulated it can be moved and sized. I have that code working also.

    Perhaps a different easier way exists but I have not discovered it ... yet.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,738

    Re: Lightweight Windowed Control

    Two things come to mind.

    1) It sure sounds like custom User Controls (UCs) will be your friend to get this all done. Also, just FYI, UCs have options on whether they're windowless and/or whether they have a DC. You could just put all your "grab handles" on the custom UC, wrapping it up nicely.

    2) It seems this has been done before. I'll let you search for it, but there's an entry in the CodeBank somewhere where someone designed controls that could be resized at runtime. It's been years ago, but I remember grab handles just like the ones we have on our IDE's designer forms.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,436

    Re: Lightweight Windowed Control

    I would copy how the VB show the handles.

    The Line control is selected by clicking near, and also moved by clicking near (not necessary to click exactly over it) and dragging.
    The Shape and all other controls show 8 handles. The Line control shows 2.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,436

    Re: Lightweight Windowed Control

    Quote Originally Posted by Elroy View Post
    2) It seems this has been done before. I'll let you search for it, but there's an entry in the CodeBank somewhere where someone designed controls that could be resized at runtime. It's been years ago, but I remember grab handles just like the ones we have on our IDE's designer forms.
    Yes, I also think I remember seeing something.

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,738

    Re: Lightweight Windowed Control

    I didn't download-and-examine, but this might be the one I once played around with. It might serve for some ideas on which to expand.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    350

    Re: Lightweight Windowed Control

    Yes, I saw that days ago. Nice code but does not do what I need.
    I have a totally different approach now.
    Thanks for your contributions.

  10. #10
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,547

    Re: Lightweight Windowed Control

    If using a UserControl ensure that DrawStyle = 5 - Transparent is set. This will safe you 1 GDI handle.

  11. #11
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,778

    Re: Lightweight Windowed Control

    Quote Originally Posted by LorinM View Post
    Perhaps a different easier way exists but I have not discovered it ... yet.
    Easier to code or easier for the end-user?

    Think of the end-user as having the crapiest mouse and being stricken with severe arthritis. The cannot click precisely, they miss clicks by 50 px at least. You have to guess as best as possible which control they wanted to click. This will usually be the closest one in X/Y direction but also in Z direction, the so called Z-order is important.

    I'm clicking withing 3px of a line which is in front of a textbox. Of course I want to select the line, not the box which is behind it.

    cheers,
    </wqw>

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