Here, this is my very latest version of the thing. I forget if this is what I last posted or not, but here it is:
Printable View
Here, this is my very latest version of the thing. I forget if this is what I last posted or not, but here it is:
Ahhh!!! Wonderful!! I missed that, but my eyes are really burning right now. I was looking for size and my eyes never settled on LEDSIZE - lol.
I also need to read the link, way back when, you left for designing user controls. I have loaded your control in VB6 in design mode and do not see how you are making the round LED (which is PERFECT by the way). The form associated with it just looks like a large form with a time control on it and no drawing of the LED. I started to look at the code behind the user control and my head started throbbing. I will look at it further tomorrow.
Hopefully, I can link a bunch of them together as a control array and assign each one its own index value.
Ahhh, yeah, I left you messages about how to get started with User-Controls. Both Eduardo and I sort of got carried away with this thing.
The latest version is using a Windows graphing library called GDI+, which does a very nice job of drawing things. However, it's fairly advanced to use. In this latest version, that's what's being used to draw both the LED dot and the border around it. The fact that it's done with GDI+ is why it looks so nice.
If you want to start learning about User-Control, my post #18 is a much better starting place. That version of the control uses standard VB6 drawing objects and a label control on the custom User-Control ... and it's far less code in it. I don't think it even has any API calls in it.
It works fine, it's just not nearly as "pretty" as the latest version.
I doubt that "Cumulative Update for SP6" is SP6 itself.
Worse yet, it sounds like the thing they also called "Security Rollup" that actually broke a lot of controls, inserting off-by-one errors in many places that could cause program crashes and data corruption. The security issues it was meant to address only mattered for OCXs for deployment as part of IE web pages anyway.
I can't even find a Microsoft download for SP6 any more. The newest one that I have here is Vs6sp6d.exe and that may have been the last one.
That message indicates that what you were trying to install at that point was not VB 6.0 SP6, but instead, a cumulative update for devices already running VB 6.0 SP6. I see you posted below that you found the actual SP6 and got that installed, but I wanted to mention this for your own sake and for anyone else down the road that might be reading this.
A little anomaly I found, maybe you can splain. Here I added two control, each with a different index. Looks fantastice:
Attachment 185890
I move the control and it goes blank unless I resize it:
Attachment 185891
I just looked and I forgot to put a "Caption" property in that post #18 version (to change the label's caption), but it might be a good exercise for you to figure out how to do that.
Basically, a Public Get and Public Let Property named Caption, set the Label's caption with the incoming Public Let's argument. And then also read & write them to the control's property bag.
I'm willing to just continue on with this thread if you'd like to try and understand user-controls more. Personally, I think they're fun. :)
Also, it's always best to save your pictures as PNG files if you can do that. JPGs also work, but PNGs are better.
Ahhh, I figured it out from your notes.
Upon runtime, it all works fine ... so there's that.
When you move the control, it's just not getting a refresh during design-time. If you close-and-reopen the form, that also fixes it.
I'll look at it though. Without doing subclassing, I'm not positive I can detect those moves though. Also, I disabled the blinking during design-time. If I enabled that, that'd also fix it.
Attachment 185892
Attachment 185893
If I change any parameter of the control, it comes back. If I move the control, it looks like it does in the second picture.
What I can do is leave the background color different than the form. That way, I can always see where the LED is at. Then during the load event, change the background color to match the form background.
I do not think it will take me that long to adapt the programs that use it to your user control. It is still funny that in the "home" machine, the old .ocx control works perfect. Well, I can not waste any more energy in trying to figure that out. It is what it is and your control is most probably a lot more powerful.
BTW, good night, I must head upstairs to the TV and what not.
Dave
I fixed it. No subclassing needed. Just the following line in the Repaint event:
New version attached.Code:
mbFullRefresh = mbFullRefresh Or Not RunTime
Attachment 185894
Yes, it is fixed!! Perfect. Now I must head up; thank you so kindly, and good night.
I think that's a good idea.
Good to hear. :)
Personally, I think it's better to have all the source code to everything, and have it all in one project (if possible).
Have a nice evening. :)
Good morning Elroy,
I will put an image of my finished form with your control when I have it updated.
The hard of an array in Frame container is that I can not copy Paste as VB6 will not link them then even if I rename the control and set the correct index, plus it disappears in the frame. So, I must add the control and then do all the color and size changes, index change, and everything else. I wish I could just paste, change the index and caption.
Anyway, working on it a bit now, then I must get to doing some real paying work in the shop.
Dave
Good morning Dave,
Well, another option is to edit the code of the custom UC (being sure to close your other forms first), and edit the defaults.
Here's the code you'd edit:
Changing any of those would change the initial values of things when placing a new control on your form.Code:Private Sub UserControl_InitProperties()
mnLedSize = 300!
mlState = Blinking
mlBlinkRate = 1000&
mlBackColor = vbButtonFace
mlBackStyle = vbTransparent
mlBorderColor = vbBlack
msCaption = "Caption"
mlLedColor = vbRed
mlBorderWidth = 1&
mbThreeD = True
End Sub
And the Font is a bit different. If you wish to change the default caption font, just open the UC's designer form (closing other forms first), and then change the font of the UC's designer form. That's where the font is stored for this UC (to be used for the caption).
You may ask why I keep saying to "close other forms first". If you simultaneously have a form open that has a custom UC on it, and also have that custom UC open for editing, the IDE sometimes gets confused and changes all those custom UCs on the other form to PictureBoxes. If your other forms are just sitting in the Project Window (unopened), this never happens.
And this sort of makes sense, considering all the things the Intellisense is trying to do (show you all the properties and methods of everything).
I do see that there is not an "Enable" parameter. That is not a big deal, but I typically, in the load event, or by default, have the LED not enabled, until after the program has made the serial connection to the instrument under test.
So the form comes up, you can see all the controls, but they are all disabled except for the the Serial Communication Port pull-down. Once a connection to the instrument under test, has been established, all controls are enabled. Typically that is done to any control with a given TAG.
Ahhh, ok, I'll add that. Give me a few minutes. :)
I'm going to disallow blinking if it's disabled, and I'm also going to add other new properties: Disabled-LED-Color & Disabled-Caption-Color. I'll just use light gray for those defaults.
Also, if you tell me what you'd like for the size defaults, I'll change those too.
Here is what the LED portion of my test screen looks like:
Attachment 185902
At one point, and I have not been able to duplicate, I moved the frame, and all the controls "hashed out".
As far as the enable, I easily take care of that with a global ControlsEnable Boolean variable. So don't worry about it.
Too cool; thank you. Light grey disabled is grey. Defaults? I seen to like a boarder size of 2, size 200. I'm not sure of color. I have these at yellow, but, I will probably change that to clear, then during a test, blink yellow, after test, if the test passes, it will be solid green or solid red if the test fails.
Dude, you really came up with something great here. You should sell this! I need to compensate you. In my shop it is just me and these control and test programs I write make my life easier. I plan to keep the shop going for at least two and a half years yet, before going full hobby. Life gets shorter and shorter, I probably should quit when I'm 64.5. Right now, it is still fun! I'm not sure if they make me more efficient, or give me more time to watch YouTube when I should be working - lol.
Let me know your email.
I guess not "clear" as such but to the form background color.
Okay, it hashes out once I go to your control to look at all the options
Attachment 185903
I'm not sure what it take to un-hash them.
Ok, working on it. Another few minutes.
Ok, here's the lastest.
Here's what I've done:
- Added an "Enabled" property.
- Added a "CaptionDisabledColor" property.
- Added a "LedDisabledColor" property.
- Added a "LedOffColor" property.
- Changed "BorderWidth" property's new default value to 2.
- Changed "LedSize" property's new default to 200.
- Changed "LedColor" property's new default to vbYellow.
Ok, you also mentioned the BackColor property, and maybe having a transparent option. That's not as totally easy as it might seem. The reason is that I don't necessarily know the container's back-color until runtime. So, here's what I can do. I can give you a Transparent property, but it will only work during runtime. Would you like that?
And, a related question. When the LED is blinking, but off, should it also use that container's back-color? Or should it stick with it's own LedOffColor? Or, should I have another "LedBackStyle" property (opaque/transparent) that determines that?
Work attached.
p.s. No payment needed. I'm a 70yo retired guy who just enjoys trying to keep my mind sharp. I don't mind giving you my email though, but I'd rather just stick with this thread regarding this LED work.
Ok, I've added two more properties:
- ControlBackStyle
- LedOffStyle
Both have two options, Transparent or Opaque.
If ControlBackStyle is Opaque it used the BackColor property. If ControlBackStyle is translucent, it uses the UC container's BackColor property.
The LedOffStyle is a bit trickier. Here's the Select Case statement for what it does:
That only executes when the LED is off (but not disabled), such as blinking off, or just turned off. Otherwise it's filled with the LedColor value.Code:
Select Case True
Case mlLedOffStyle = styleOpaque: iFillColor = mlLedOffColor
Case mlControlBackStyle = styleOpaque: iFillColor = mlBackColor
Case Else: iFillColor = Ambient.BackColor
End Select
Work attached.
Eduardo: I just vertically center both the LED and the caption, so I don't really worry about clipping. And also, the caption wraps, so horizontal clipping doesn't really make sense. Regarding vertical clipping, I suppose I could monitor changes to both the LED and the caption's font, and resize accordingly, but the caption wrapping would make even that difficult. That caption just complicates auto-sizing, and that's why I just didn't bother with it. Just let him work it our during designing.
I mean, "transparent" being transparent.
Well, that was easy enough. I saw the commented out lines, and the new lines.
Dave, not sure you'll use it, but Eduardo has given you the ability for a more true transparency, in the case where your container has a picture in its background.
He used my latest code and patched it up, so it's got all of my latest changes. I've taken his work and I'm calling it the "latest".
Ok, one more change.
If both ControlBackStyle=transparent, and LedBackStyle=transparent, you now get the picture in the center of the LED, as it should be.
The new Select Case for that (when the LED light isn't shining):
Work attached (including Eduardo's mod):Code:
Select Case True
Case mlLedOffStyle = styleOpaque: iFillColor = mlLedOffColor
Case mlControlBackStyle = styleOpaque: iFillColor = mlBackColor
Case Else: iFilled = False
End Select
Dave,
Just as an FYI, I know you're trying to get some design work done.
For ALL of these recent changes, to implement them, all you have to do is to open the UC's code window, delete all the code, and then paste the code from the latest version. (Again, closing all your other forms when you do this.)
But, done this way, all the changes will just automatically appear on all your design work with this UC.
Yes, but there was an issue in the first version that I posted, I fixed that soon but you had already downloaded.
The issue is that the control is not painted at runtime until it blinks.
Here is your latest version but with the fix.
BTW, JFYI, with the HitTest event you could just make the hit when the user clicks on the LED if you want.