Solved

how do I raise an event?

Posted on 2004-09-13
7
175 Views
Last Modified: 2011-10-03
I use VB 6.0   I see that there are multiple places that I have to put code to handle events and
I keep getting it wrong.  I want to do I have a form that has a button.  When that button is clicked,
another program that is running at the same time as the first program catches a "p1_button_in"
event and turns a light on.
0
Comment
Question by:dwcronin
7 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12047788
You can not raise an event that happens in the 1st program in the second program.


However you can use Message API functions, so when that event happen in the 1st program

they send it to the second and second program turns the light on.
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12047801
Another easier ways is that when event happens in the 1st program it writes a flag variable to  a textfile and

seconds program check that files to do some action.
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12047810
if still unclear,
please explain more clearly.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:dwcronin
ID: 12047874
I was trying to avoid something like writing to a file.  That is going to use disk access and I know that is slow.
I am trying to get the second program to respond immediately to the first programs button click.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 125 total points
ID: 12048094
This sample may help you:

Share Data Between Apps Without COM
http://www.thescarms.com/vbasic/PassString.asp
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12048187
Then Consider writing and readiing from the registry which is very fast.

if you need the code I can supply it here.

0
 
LVL 3

Expert Comment

by:aParser
ID: 12048550
What you're talking about -- I think -- is interprocess communication.  There are many ways to do it, one of the most common is the textfile approach that unknown_routine gave you.

The approach that I used under NT 4.0 is to use mailslots.  The more modern approach is to use Microsoft Messaging.

You could also use callbacks.  It is a slightly more sophisticated approach, but one that requires a fair amount of coding.
http://msdn.microsoft.com/library/en-us/vb98/html/vbsmpCallback.asp?frame=true

You could also do something like store the hWnd of your "lightbulb" program, then when your "click" application starts, you read the hWnd (or title) from whereever you've stored it.  When the user clicks the button in the "click" application, you make the "lightbulb" application the foreground application and use SendKeys to send a key sequence that activates your lightbulb.

You could also look at the SendMessage and PostMessage APIs.  This would be a very low-level approach.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now