Solved

how do I raise an event?

Posted on 2004-09-13
7
178 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

860 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