Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PostMessage... GetMessage???

Posted on 2000-03-07
3
Medium Priority
?
458 Views
Last Modified: 2006-11-17
I want the new instance of an app to send a message to the old one.

For example I start MyProg by clicking "first.txt". After that I click on "second.txt" and I want the new MyProg to do something like :

PostMessage(oldMyProgHandle, WM_COMMAND, 0&, "second.txt")


But how do I Get the message ??
0
Comment
Question by:HellSlayer
[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 Comments
 
LVL 14

Expert Comment

by:mcrider
ID: 2594268
You need to create a message handler (windows hook) See the following microsoft KB articles:

HOWTO: Build a Windows Message Handler with AddressOf in VB
http://support.microsoft.com/support/kb/articles/q170/5/70.ASP?LNG=ENG&SA=MSDN&FR=0 

HOWTO: Pass String Data Between Applications Using SendMessage
http://support.microsoft.com/support/kb/articles/Q176/0/58.ASP?LNG=ENG&SA=MSDN&FR=0 

HOWTO: Hook Into a Window's Messages Using AddressOf
http://support.microsoft.com/support/kb/articles/Q168/7/95.asp?LNG=ENG&SA=MSDN&FR=0 


Cheers!®©

0
 
LVL 32

Accepted Solution

by:
Erick37 earned 280 total points
ID: 2594281
If you are trying to open associated files with one instance of your program, use DDE.  This sample code will populate a listbox with filenames as you double click the associated file.

Place Label1 and List1 on Form1:

Option Explicit

Private Sub Form_Load()
    ' At design time set Form's LinkMode property = 1 (Source)
    If App.PrevInstance Then
        On Error Resume Next
        Label1.LinkTopic = App.EXEName & "|cmdLine"
        Label1.LinkItem = ""
        Label1.LinkMode = vbLinkManual
        Label1.LinkExecute Command
        If Err Then
            MsgBox Err.Description, vbOKOnly, "Error " & CStr(Err.Number)
        Else
            Unload Me
            Exit Sub
        End If
    End If
    'First instance:
    Label1.Visible = False
    Show
    List1.AddItem Command
    Me.LinkTopic = "cmdLine" ' wait for "cmdLine" links
End Sub

Private Sub Form_LinkExecute(CmdStr As String, Cancel As Integer)
    'Command lines from other instances
    'will be passed thru CmdString
    List1.AddItem CmdStr
    Cancel = False
End Sub

Private Sub Form_Terminate()
    Beep
End Sub
 
0
 

Author Comment

by:HellSlayer
ID: 2602685
Really cool sample without any API !!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Suggested Courses

730 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