?
Solved

PeekMessage API

Posted on 1997-08-10
5
Medium Priority
?
578 Views
Last Modified: 2008-03-04
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.
0
Comment
Question by:msiman
[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
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:y96andha
ID: 1430154
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.
0
 
LVL 2

Author Comment

by:msiman
ID: 1430155
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
0
 
LVL 5

Accepted Solution

by:
y96andha earned 120 total points
ID: 1430156
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.

0
 
LVL 2

Author Comment

by:msiman
ID: 1430157
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
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1430158
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.)
      
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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses

801 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