?
Solved

how do I raise an event?

Posted on 2004-09-13
7
Medium Priority
?
183 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
[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
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
Industry Leaders: 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!

 

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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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