-
[RESOLVED] LED.OCX & Windows 11 Pro
I have one that has left me stumped for several days now.
The problem exists in both VB6 and VBA for Office. My more extensive instrument control and test are actually written in VBA under access (for the databasing and reports).
For years, I have used a very old ActiveX control LED.OCX.
My first Windows 11 machine was last December, an HP that was supposed to have Windows 11 on it but came from SAMS Club with Windows 10. HP Remoted and updated it to Windows 11 (HOME). All my programs, both VB6 and VBA with LED.OCX work fine on that machine.
Last week, I built up a new computer myself (gaming power machine), but it is still my shop's main desk computer. From the start, I installed Windows 11 Pro.
I can not get any of my VBA or VB6 Programs to see the LED.OCX control. I can reference it without error (it is not one you register with the OS) on both VB6 and VBA. The forms do not have access to it and it can not be found on the list of available activeX controls to choose from.
The main difference between the two Windows 11 machines is Home verse Pro. I do not use any of the pro features, so WIM should not be active. I do not touch bitlocker. So, I am not sure what the difference is. Both systems are 64 bit.
Thoughts, help, an LED.OCX alternative (would have to be backwards compatible to 32 bit Windows 7)?
Thanks kindly,
Dave
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
daveyk021
I can not get any of my VBA or VB6 Programs to see the LED.OCX control. I can reference it without error (it is not one you register with the OS) on both VB6 and VBA.
I've never heard of such a thing. You must either register it (with RegSvr32) or you must locally (within the app) register it through a manifest with the SxS technology. I know of no other way to use an OCX file.
Or, if your app is correctly "installed" with a good installer, that installer software should register it.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
Elroy
I've never heard of such a thing. You must either register it (with RegSvr32) or you must locally (within the app) register it through a manifest with the SxS technology. I know of no other way to use an OCX file.
It didn't even register in Windows 7. You register it with the IDE of both VB6 and VBA. Under References, IDE Code section, you browse, find it and select it. Then it shows up as LEDD.
As I said, I have been using it for years that way.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
daveyk021
It didn't even register in Windows 7. You register it with the IDE of both VB6 and VBA. Under References, IDE Code section, you browse, find it and select it. Then it shows up as LEDD.
As I said, I have been using it for years that way.
Are you running the IDE elevated (with admin rights)?
You need to run the IDE elevated to be able to register components.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
Eduardo-
Are you running the IDE elevated (with admin rights)?
You need to run the IDE elevated to be able to register components.
Yes, and not sure how you would do that in VBA (office).
I figure it may be an added security layer in the Pro addition of Windows 11?
There may be a newer/better way to represent and LED indicator these days? Although I would not look forward to re-coding all the projects I used LED.OCX in.
Dave
-
Re: LED.OCX & Windows 11 Pro
For VBA, the relevant Excel.Application needs to have been instaniated in admin mode - https://answers.microsoft.com/en-us/...d-7226869ecc5b
Are you using Office 64bit or 32bit?
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
daveyk021
There may be a newer/better way to represent and LED indicator these days?
If you explain what it does, and better if you post some images, maybe someone could have or recommend something.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
daveyk021
It didn't even register in Windows 7. You register it with the IDE of both VB6 and VBA. Under References, IDE Code section, you browse, find it and select it. Then it shows up as LEDD.
As I said, I have been using it for years that way.
Yeah, if you re-compile the OCX's source code on a specific computer (if you're elevated), the IDE will register it during compilation. But, one way or another, it's got to be registered to use the OCX (unless it's set up for SxS in the program's manifest).
-
2 Attachment(s)
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
Eduardo-
If you explain what it does, and better if you post some images, maybe someone could have or recommend something.
This example (attached) is one of the more crude examples, but it was at-hand. You can make them look better than this. While a given test is running, its LED will blink yellow. If the test passes, it then changes to a solid green. If it fails, the LED changes to a solid RED.
I'll have to find a better example.
Dave
-
Re: LED.OCX & Windows 11 Pro
Ohh, are we talking about an LED-looking control? Hmm, all the registering stuff still applies ... but I thought we were talking about actually controlling some physical LED.
If all we want is some control that "looks like" an LED, for goodness sakes, just quickly write a user control that does it.
Shucks, if you give me some pictures and specifications, I'll knock it out for you.
-
Re: LED.OCX & Windows 11 Pro
See above please. Need a color and a blink attribute (don't want a timer control), and hopefully a title/tag (i.e. "PA Amplifier RF Filters.."). I'm sure you can make a better looking one. It will require a rework of several programs, but that should not take all that long.
I've never tried to make my own control and could use pointed to lesson for that 8-).
-
Re: LED.OCX & Windows 11 Pro
Sounds like you didn't register it in an elevated command prompt. regsvr32 should work for any normal OCX, and it doesn't sound like this is anything special.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
ahenry
Sounds like you didn't register it in an elevated command prompt. regsvr32 should work for any normal OCX, and it doesn't sound like this is anything special.
Oh yea I have. I know to open CMD as Admin.. You can not register LED.OCX even under Windows 7/32. You just reference it in your program IDE and it works that way, but not under Windows 11 Pro.
-
Re: LED.OCX & Windows 11 Pro
daveyk021,
Ok, I'll mock something up.
Is it ok if I use a Timer API call? I don't see another way to do it without doing that. And it'll be slow enough that you'll never notice it in terms of system resources or performance. A timer that slow isn't going to hurt anything.
-
Re: LED.OCX & Windows 11 Pro
Actually, I'm going to put a timer control on the user control so I don't need a BAS module for the callback. Again, I don't see how this can be a problem.
-
2 Attachment(s)
Re: LED.OCX & Windows 11 Pro
NOTICE: Grab the latest version in subsequent posts below.
Here, see if this'll get you going.
I've attached a demo project. But, to use it, just drag that LedUserControl.CTL file into your project, and then it'll appear in your toolbox. Use it wherever you like.
This picture doesn't show it blinking, as I didn't want to mess with capturing a video.
Attachment 185751
Here are the custom properties it has:
- State (on or off)
- BlinkIt (boolean)
- BlinkRate (milliseconds)
- LedColor (an OLE_COLOR)
- BorderColor (another OLE_COLOR)
- Font (for the caption)
And the only event I setup was a Click event. If you want other events let me know and I'll set them up for you.
EDIT: Ohhh, I wanted to give you a way to size the LED light. Give me a moment and I'll set that up.
-
1 Attachment(s)
Re: LED.OCX & Windows 11 Pro
Ok, I added both a Size and BorderWidth property.
-
1 Attachment(s)
Re: LED.OCX & Windows 11 Pro
I guess you also need a BackColor for the thing. That's now been added as well.
-
Re: LED.OCX & Windows 11 Pro
Now all you need to do is antialias the circles. ;)
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
dilettante
Now all you need to do is antialias the circles. ;)
Boooo. :p Yeah, I saw that, but I'm not going to fire up the GDI+ for this thing.
-
Re: LED.OCX & Windows 11 Pro
Well the other alternative is to render to a secondary hDC at 4x, then downscale by 4x using StretchBlt() in HALFTONE mode. Does a pretty good job, and you can either use an invisible PictureBox or a memory DC as the secondary. Of course the latter doesn't let you use VB's drawing primitives, so you need a few more API calls.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
dilettante
Well the other alternative is to render to a secondary hDC at 4x, then downscale by 4x using StretchBlt() in HALFTONE mode. Does a pretty good job, and you can either use an invisible PictureBox or a memory DC as the secondary. Of course the latter doesn't let you use VB's drawing primitives, so you need a few more API calls.
hahaha, yeah, well, I'll wait and see what he has to say. We didn't even get any pictures of what he has now, which would have been nice. I also thought about putting a shadow on it, or make it a bit more 3D, but hey, it's free. :)
Also, that thing doesn't currently have any API calls in it.
-
2 Attachment(s)
Re: LED.OCX & Windows 11 Pro
I made one but without caption.
It has antialias since it is based on ShapeEx that uses GDI+.
Attachment 185765
PS: Updated, I made a couple of adjustments.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
Eduardo-
I made one but without caption.
It has antialias since it is based on
ShapeEx that uses GDI+.
I haven't even looked at it, but maybe I should use it as a sub-UC to mine. :lol:
We'll get this guy really fixed up. :)
-
3 Attachment(s)
Re: LED.OCX & Windows 11 Pro
Ok, here it is with Eduardo's GDI+ improvement (anti-aliasing to draw the circle).
Now, to use it, you've got to copy these three files into your project's source folder:
LedUserControl.ctl
ShapeEx.ctl
ShapeEx.ctx
And then grab the LedUserControl.ctl and ShapeEx.ctl user controls and put them into your project.
Here's a picture. It does look nicer:
Attachment 185761
ADDED: And here's a picture of the Size property made much smaller, and the control's BackColor the same as the form. It looks good.
Attachment 185766
-
Re: LED.OCX & Windows 11 Pro
I've put mine in the Codebank (an improved version of what I posted on message #23): LED control.
-
Re: LED.OCX & Windows 11 Pro
How about a little more 3D "gemmy" appearance?
Quick hack, no antialiasing, just to give an idea of what I mean:
Code:
Option Explicit
Private Declare Function Ellipse Lib "gdi32" ( _
ByVal hDC As Long, _
ByVal Left As Long, _
ByVal Top As Long, _
ByVal Right As Long, _
ByVal Bottom As Long) As Long
Private Sub LED(ByVal X As Long, ByVal Y As Long, ByVal Color As Long, ByVal Delta As Long)
Dim L As Long
Dim T As Long
Dim R As Long
Dim B As Long
Dim I As Long
L = X - 1
T = Y - 1
R = L + 2
B = T + 2
DrawWidth = 2
ForeColor = Color
For I = 1 To 5
Ellipse hDC, L, T, R, B
ForeColor = ForeColor - Delta
L = L - 1
T = T - 1
R = R + 1
B = B + 1
Next
For I = 6 To 15
Ellipse hDC, L, T, R, B
ForeColor = ForeColor - 6 * Delta
L = L - 1
T = T - 1
R = R + 1
B = B + 1
Next
ForeColor = vbBlack
Ellipse hDC, L, T, R, B
End Sub
Private Sub Form_Load()
AutoRedraw = True
LED Int(ScaleX(ScaleWidth / 2, ScaleMode, vbPixels)) - 30, _
Int(ScaleY(ScaleHeight / 2, ScaleMode, vbPixels)), _
vbRed, _
&H2&
LED Int(ScaleX(ScaleWidth / 2, ScaleMode, vbPixels)) + 30, _
Int(ScaleY(ScaleHeight / 2, ScaleMode, vbPixels)), _
vbGreen, _
&H200&
LED Int(ScaleX(ScaleWidth / 2, ScaleMode, vbPixels)), _
Int(ScaleY(ScaleHeight / 2, ScaleMode, vbPixels)) + 35, _
vbYellow, _
&H201&
LED Int(ScaleX(ScaleWidth / 2, ScaleMode, vbPixels)), _
Int(ScaleY(ScaleHeight / 2, ScaleMode, vbPixels)) - 35, _
&HFFD000, _
&H10200
End Sub
-
1 Attachment(s)
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
dilettante
How about a little more 3D "gemmy" appearance?
Done.
Attachment 185775
-
Re: LED.OCX & Windows 11 Pro
daveyk021, just as an FYI, if you ever come back, and you're truly interested in learning how to make your own custom-user-controls (UC), start by exploring what I gave you in post #18. It's a straightforward example with no API calls, and it has all the essentials of making your own UC.
Eduardo's StyleEx.ctl (and it's ctx) are clearly prettier, but that StyleEx UC has a thunk (inserted machine code) as well as subclassing in it, in addition to using the GDI+ library ... all of which are at a pretty high level. And that's also a chunk of code with much in it that you don't need. Just saying.
I'm tempted to write a version with GDI+ that does the anti-aliasing (and maybe also the 3D appearance), all included in the LedUserControl.CTL, but I'll wait to see where you're at with all of this.
-
2 Attachment(s)
Re: LED.OCX & Windows 11 Pro
I didn't have anything better to do, so I went ahead and got my version working with GDI+. I must admit that I peeked at Eduardo's ShapeEx.ctl while doing it. Eduardo, I certainly hope you don't mind that.
Here are the features:
- All in one CTL (and no CTX).
- No thunk (machine code).
- No subclassing.
- Ring is anti-aliased for smoothing.
- LED has 3D option.
- Unicode caption.
Here are the properties (other than the properties automatically supplied, such as Visible, Index, Size, etc.:
- State (On, Off, Blinking)
- BackColor (of the actual control)
- BorderColor (of the LED light)
- BorderWidth (of the LED light)
- BlinkRate (in milliseconds)
- CaptionColor (of the font)
- Caption
- LedColor (of the actual LED light)
- LedSize
- ThreeD (of the LED light)
Also, just as an FYI, I didn't tie anything to the size of the control, so you are responsible for making sure the LED and the Caption will fit.
There's also a Refresh method. The only time that's really necessary is when you grab a reference to the Font property, and then use that reference to change the font. Grabbing that reference that way, the "Set Font" is never called, so it doesn't get a chance to refresh. I initially had a timer, but that really wasn't so good.
Here's a picture of what the demo now looks like:
Attachment 185786
To use it, just put the LedUserControl.CTL into your project, and it'll appear in your ToolBox. I didn't put a specific Icon in it, as I didn't want a CTX file generated.
Ok Dil, what else can be done to it. :p
Enjoy
And, as a note to davey, I still say you start with my post #18, and not this one. That post #18 is quite simple, and has the basics of custom-user-control creation.
-
Re: LED.OCX & Windows 11 Pro
Well if you don't use a Timer control is there any good reason not to make it a LightWeight (windowless) control?
Does it do text-wrapping for long Caption values?
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
dilettante
Well if you don't use a Timer control is there any good reason not to make it a LightWeight (windowless) control?
I do use the timer control, just not for Font changes. I suppose I could use the timer API, and have the callback into that CTL. Not exactly sure what that buys us though.
Hmmm, lightweight? Don't know if that's needed or not. I do use the UserControl's Font to store the Font, but I could create a Font object to do that.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
dilettante
Does it do text-wrapping for long Caption values?
hahaha, I just spotted that. :)
That'd be a chunk of work, given that I'm using TextOutW for the caption.
EDIT: I might also want to vertically center the LED on the control. I'm just currently putting it at the top-left. But, if centered, I could also just center the caption. That'd work out better for any multi-line caption.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
Elroy
I didn't have anything better to do, so I went ahead and got my version working with GDI+. I must admit that I peeked at Eduardo's ShapeEx.ctl while doing it. Eduardo, I certainly hope you don't mind that.
The code I share is for people to use it, so of course I don't mind.
Quote:
Originally Posted by
dilettante
Well if you don't use a Timer control is there any good reason not to make it a LightWeight (windowless) control?
A Timer control does not prevent you from making a UserControl windowless.
BTW, my ShapeEx and LED controls both have timers and are windowless.
You only can't have windowed controls but can have windowless and invisible controls inside.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
Eduardo-
A Timer control does not prevent you from making a UserControl windowless.
Good catch. I was rushing and did not think it through.
-
Re: LED.OCX & Windows 11 Pro
I just toggled the WindowLess property on mine and nothing complained. So, I'll just leave it to whoever wants to use it. :)
-
Re: LED.OCX & Windows 11 Pro
-
2 Attachment(s)
Re: LED.OCX & Windows 11 Pro
Ok, here it is as LightWeight and caption that wraps (using DrawTextW instead of TextOutW).
Anything else? :p
And hmmm, I wonder if Davey is ever coming back.
Attachment 185793
-
Re: LED.OCX & Windows 11 Pro
It hasn't been clear to me why an Image and Label control and a series of GIFs for the required colors wasn't good enough to do the entire job anyway. Easy enough to hold the GIFs in a series of invisible Image controls.
Ok, maybe blinking, but still no big deal. Either wrap it in a UserControl or not as required.
-
Re: LED.OCX & Windows 11 Pro
Quote:
Originally Posted by
dilettante
It hasn't been clear to me why an Image and Label control and a series of GIFs for the required colors wasn't good enough to do the entire job anyway. Easy enough to hold the GIFs in a series of invisible Image controls.
Ok, maybe blinking, but still no big deal. Either wrap it in a UserControl or not as required.
Probably would have been. :)