Results 1 to 6 of 6

Thread: [RESOLVED] Subclassing in VBA

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Oregon
    Posts
    60

    Resolved [RESOLVED] Subclassing in VBA

    Goal: Add a progressbar to a panel within a statusbar

    I have seen that subclassing as a solution to this online, but since I am stuck with using solely VBA, is there a way to subclass with it?

    Thanks


    Garrett

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Subclassing in VBA

    Did you try just drawing one inside of a panel?

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Oregon
    Posts
    60

    Re: Subclassing in VBA

    That did work, but can subclassing be done in general with VBA?

    Thanks by the way, I am just trying to learn as much as possible. I just don't want to spend time trying to find a solution if there isn't one to be found.

    Thanks again,


    Garrett

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Subclassing in VBA

    I would strongly recommend against subclassing in VBA, because subclassing is prone to crashing when you enter debugging mode.

    Due to the fact that VBA is hosted within another app, and that it regularly enters debugging mode automatically, crashing is very likely - and it is likely to crash the app as well as VBA.


    There are ways to significantly reduce the risks of subclassing (such as the "Paul Caton" method), but they don't eliminate it completely.

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Subclassing in VBA

    because subclassing is prone to crashing when you enter debugging mode.
    I absolutely agree with Si, however, it can be avoided. It takes some practice to figure out how to jump out of a program in the middle without crashing.

    Any time you subclass a program, you can easily crash the entire VBA IDE, losing any changes you have made. For example if you click the IDE's Halt button, the IDE does not clean up the subclassed WindowProc properly and crashes. The basic problem is the object doesn't have a chance to process the teardown messages normally because the original WindowProc doesn't run.

    To avoid serious inconvenience, save your program every time you run it so you don't lose a lot of work if you accidentally crash the IDE in this way.

    Don't use the halt button. Instead close the form normally. If you close it by unloading it or by clicking on the little X button in the upper right corner, VBA cleans up the mess and the IDE will not die...

    Hope this helps...

    ps: If you can avoid subclassing, avoid it...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Oregon
    Posts
    60

    Thumbs up Re: Subclassing in VBA

    I would like to thank you both for responding to my question and for your advice.

    Garrett

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