Results 1 to 3 of 3

Thread: Alternative to DoEvents

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018

    Alternative to DoEvents

    I know this post is 13 years old, but I can't think of anywhere else to get the answer.
    I realize these methods are useful to only use DoEvents when specific messages are in the queue, but is there a way to only do specific events when DoEvents is triggered. For example, i'm using VBA for PowerPoint 2016, and I am continuously updating the shapes position with DoEvents, but DoEvents is also tracking mouse-movements, and is slowing down the shapes position update whenever it detects the mouse movement.

    I want a method that only does wm_paint events so that I can have the shape move without lag from mouse-movement.

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Near Nashville TN

    Re: Ok noobies, DoEvents is slow!!! Here's are faster methods:

    Hi nathanriddle66,

    Welcome to VBForums. This post is really in the wrong place though. It's a question, so it doesn't belong in the CodeBank area. Furthermore, it's probably more of a VBA question than a VB6 question (which is the area you're in). Although, I'm quite sure the VB6 folks can answer it.

    I'm going to ask the moderators to move it. So, if you see it moved, that's why.

    Now, it's been quite a few years since I've used the VBA with PowerPoint. However, I use it with Excel and Word rather frequently. Furthermore, I Automate Excel and Word from VB6 on a regular basis. From that experience, my thought is that you're taking the wrong approach with all of this. And there's also a mis-understanding about what DoEvents actually does (but I'll address that lastly).

    Rather than use DoEvents to updating shapes and/or their positions, I'd find the appropriate PowerPoint object to refresh, and use the Refresh method on that object. From a quick search of the PowerPoint VBA help, it seems that the Refresh method is primarily used on charts, but that may be precisely what you need. It's clearly available on other objects as well though.

    Using the Refresh method, you will do precisely what you're trying to do, rather than just generally attempting to tell PowerPoint to do all underlying business.

    Now, DoEvents doesn't "exactly" track mouse movements. What DoEvents does is to suspend your code (wherever it is), and then tell the application (PowerPoint in this case) to execute whatever events are immediately in the queue. And, when that's done, processing is returned to your code that was suspended. So, I suppose if you have some MouseMove events in the queue, in a sense, it may be tracking mouse movements. But, in general, it's not.

    Also, just as a note, DoEvents is specific to your application (again, PowerPoint in this case). Some people get it confused with the Sleep API function, but Sleep does something very different from DoEvents.

    Maybe that'll help. Best Of Luck,
    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
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    South Louisiana

    Re: Alternative to DoEvents

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