Solved

PeekMessage API

Posted on 1997-08-10
5
564 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
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:y96andha
Comment Utility
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
Comment Utility
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 30 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

728 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

12 Experts available now in Live!

Get 1:1 Help Now