?
Solved

Detect event in VB6 program

Posted on 2003-03-02
2
Medium Priority
?
165 Views
Last Modified: 2012-06-22
I have a VB6 application that need almost 100% of cpu time. If I include a DoEvents in my program loop then this will desturb the outputs from my program.
Is it possible to check for a command button event, or something to make it possible to terminate my program loop.
The problem is that DoEvents take to long time.
0
Comment
Question by:sek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
clavrg earned 300 total points
ID: 8052697
If you want to use event from command button you have to dispatch a window's message queue. Simplest way to do so is to use GetMessage (WinAPI) and DispatchMessage(WinAPI) you can try to play around with parameters of these functions in order to speed up this process. DoEvents do the same, I do not know whether you going to gain any improvement if you do it manually. I would try to change process' priority class to (e.g. to real-time) and call DoEvents as seldom as possible. I.e. you do not need to check message queue 100s times a second. 1 time a second should be enough.

Maybe you can think on this idea.
Instead of getting event from command button. You can show message smth like "Press and hold Ctrl key to interupt execution". And then check status of the keyboard. I do not know how to do so. Just note that if you will call "GetKeyStat" (WinAPI) will not work since this function also relies on the message queue.
0
 

Expert Comment

by:CleanupPing
ID: 8900911
sek:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question