Page 1 of 4 1234 LastLast
Results 1 to 40 of 140

Thread: [RESOLVED] LED.OCX & Windows 11 Pro

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    81

    Resolved [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

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by daveyk021 View Post
    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    81

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by Elroy View Post
    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.

  4. #4
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,470

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by daveyk021 View Post
    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    81

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by Eduardo- View Post
    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

  6. #6
    Member
    Join Date
    May 2021
    Posts
    35

    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?

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,470

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by daveyk021 View Post
    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.

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by daveyk021 View Post
    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).
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    81

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by Eduardo- View Post
    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
    Attached Images Attached Images   

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

    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    81

    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-).

  12. #12
    Addicted Member
    Join Date
    Jan 2018
    Posts
    219

    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.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Sep 2022
    Posts
    81

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by ahenry View Post
    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.

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

    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    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.

    Name:  Led.png
Views: 289
Size:  2.2 KB

    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.
    Attached Files Attached Files
    Last edited by Elroy; Sep 14th, 2022 at 02:46 PM.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    Re: LED.OCX & Windows 11 Pro

    Ok, I added both a Size and BorderWidth property.
    Attached Files Attached Files
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    Re: LED.OCX & Windows 11 Pro

    I guess you also need a BackColor for the thing. That's now been added as well.
    Attached Files Attached Files
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  19. #19
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,810

    Re: LED.OCX & Windows 11 Pro

    Now all you need to do is antialias the circles.

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by dilettante View Post
    Now all you need to do is antialias the circles.
    Boooo. Yeah, I saw that, but I'm not going to fire up the GDI+ for this thing.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  21. #21
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,810

    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.

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by dilettante View Post
    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  23. #23
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,470

    Re: LED.OCX & Windows 11 Pro

    I made one but without caption.
    It has antialias since it is based on ShapeEx that uses GDI+.

    Name:  LED_Scr.png
Views: 272
Size:  6.6 KB

    PS: Updated, I made a couple of adjustments.
    Attached Files Attached Files

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by Eduardo- View Post
    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.

    We'll get this guy really fixed up.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    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:

    Name:  Led4.png
Views: 278
Size:  3.4 KB

    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.

    Name:  Led5.png
Views: 281
Size:  2.6 KB
    Attached Files Attached Files
    Last edited by Elroy; Sep 14th, 2022 at 03:46 PM.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  26. #26
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,470

    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.

  27. #27
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,810

    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

  28. #28
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,470

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by dilettante View Post
    How about a little more 3D "gemmy" appearance?
    Done.

    Name:  LED_Scr1_3D.png
Views: 256
Size:  8.1 KB

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

    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    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:
    Name:  Led6.jpg
Views: 211
Size:  31.1 KB

    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.

    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.
    Attached Files Attached Files
    Last edited by Elroy; Sep 16th, 2022 at 12:59 PM.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  31. #31
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,810

    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?

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by dilettante View Post
    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by dilettante View Post
    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  34. #34
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,470

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by Elroy View Post
    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 View Post
    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.

  35. #35
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,810

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by Eduardo- View Post
    A Timer control does not prevent you from making a UserControl windowless.
    Good catch. I was rushing and did not think it through.

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

    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  37. #37
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    622

    Re: LED.OCX & Windows 11 Pro

    Enthusiastic friend

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

    Re: LED.OCX & Windows 11 Pro

    Ok, here it is as LightWeight and caption that wraps (using DrawTextW instead of TextOutW).

    Anything else?

    And hmmm, I wonder if Davey is ever coming back.
    Name:  Led7.jpg
Views: 182
Size:  34.8 KB
    Attached Files Attached Files
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  39. #39
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,810

    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.

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

    Re: LED.OCX & Windows 11 Pro

    Quote Originally Posted by dilettante View Post
    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.
    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. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

Page 1 of 4 1234 LastLast

Tags for this Thread

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