-
Apr 14th, 2024, 01:12 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Apr 14th, 2024, 02:02 AM
#2
Re: Lightweight Windowed Control
A Frame?
 Originally Posted by LorinM
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
-
Apr 14th, 2024, 09:47 AM
#3
Re: Lightweight Windowed Control
To my way of thinking, there are two issues, with a third consideration.
- Does it have a hWnd?
- Does it have a DC?
- 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.
-
Apr 14th, 2024, 10:12 AM
#4
Thread Starter
Hyperactive Member
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.
-
Apr 14th, 2024, 10:19 AM
#5
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.
-
Apr 14th, 2024, 10:28 AM
#6
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.
-
Apr 14th, 2024, 10:30 AM
#7
Re: Lightweight Windowed Control
 Originally Posted by Elroy
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.
-
Apr 14th, 2024, 10:42 AM
#8
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.
-
Apr 14th, 2024, 02:55 PM
#9
Thread Starter
Hyperactive Member
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.
-
Apr 17th, 2024, 01:01 AM
#10
Re: Lightweight Windowed Control
If using a UserControl ensure that DrawStyle = 5 - Transparent is set. This will safe you 1 GDI handle.
-
Apr 17th, 2024, 04:42 AM
#11
Re: Lightweight Windowed Control
 Originally Posted by LorinM
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|