PeekMessage API

can someone show me the use of this api?
i need something like that:
two programs.
the first sends message to the second program
the second program, using peekmessage, or getmessage
gets it, and shows a msgbox...
very simple interface.
one with a button, which sends a message
and one the waits to the message.
LVL 2
msimanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

y96andhaCommented:
You won't be able to use this in VB. This type of message is used for all window management, such as moving or sizing a window or whenever keys are pressed. VB retrieves all messages itself using GetMessage, and they'll never stay in the queue enough time for you to pick them up.

Try DDE instead, thats a much easier way to send messages between applications.
msimanAuthor Commented:
i guess the answer is ok, but not full:
could you show me a very simple piece of code
that creats dde connection, between two programs,
and transfer any data between them?
MSIMAN
y96andhaCommented:
OK, here it comes:

Create a project with a label on a form and set the LinkMode property of the form to source. Name this project RECEIVER, make an exe file and start it.

Create a second project with an edit box and a command button on a form containing this code:

Sub Command1_Click
    Text1.LinkTopic = "RECEIVER|Form1"
    Text1.LinkItem = "Label1"
    Text1.LinkMode = 2
    Text1.LinkPoke
    Text1.LinkMode = 0
End Sub


When you run the second project, you can enter text in the textbox and then click the command button to make the text appear in the first program.

When using this in a real project, you can make the controls hidden, and use the Label1_Changed event to receive the messages.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
msimanAuthor Commented:
i graded you, but still i have a small quesstion regarding
the code.
in command1_click event, on line 2, the RECIEVER,
is it the other program caption or EXE filename?
msiman
y96andhaCommented:
It is the module name, which mostly is the same as the EXE file name but not always. From the help topic "LinkTopic Property":

The application element that the destination application uses, which is either the Visual Basic project filename without the .VBP extension (if you're running your application in the Visual Basic development environment) or the Visual Basic application filename without the .EXE extension (if you're running your application as a stand-alone executable file).  The EXEName property of the App object provides this string in your Visual Basic code unless the filename was changed by the user.  (EXEName always returns the actual filename of the application on disk; DDE always uses the original name that was specified in the Make EXE dialog box.)
      
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.