Query related to posting message from a regular dll to Client Application?

This is a discussion on Query related to posting message from a regular dll to Client Application? within the Windows Programming forums, part of the Platform Specific Boards category; Hi I have a dll & its client application. The dll is a Regular MFC dll & the client is ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    17

    Query related to posting message from a regular dll to Client Application?

    Hi
    I have a dll & its client application.
    The dll is a Regular MFC dll & the client is an SDI MFC application.

    I am having trouble posting message from the dll to the client application.

    The dll is implicitly linked to the client application. The exported function <DisplayMsgBox1()> is being called from the client side.

    From within the <DisplayMsgBox1()> function on the dll side, a message is posted to the client but it never reaches the client app.

    Code on the dll side : <DisplayMsgBox1()>

    Code:
    #define 	WM_MSG_FROM_DLL		WM_APP+100
    
    
    extern "C" __declspec(dllexport) BOOL	CFindFile::DisplayMsgBox1()
    {
        AFX_MANAGE_STATE(AfxGetStaticModuleState());
    
        AfxMessageBox("DisplayMsgBox() of the dll called!");
    
        HWND hWnd	=	FindWindow(NULL, "VC++");
    
        if(hWnd)
        {
    	AfxMessageBox("Window is found!");
    	BOOL	ret = 0;
    	ret	= PostMessage(hWnd, WM_MSG_FROM_DLL, 0, 0);
        }
        else
    	AfxMessageBox("Window not found!");
    
        return	0;
    }
    When the control comes inside the <DisplayMsgBox1()> function, the FindWindow() returns success but PostMessage() is failing.

    Code on the client side:

    Code:
    #define	       WM_MSG_FROM_DLL  	WM_APP+100
    
    BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    	//{{AFX_MSG_MAP(CMainFrame)
    
    	ON_MESSAGE(WM_MSG_FROM_DLL, OnMsgFromDll)
    
    	//}}AFX_MSG_MAP
    	// Global help commands
    END_MESSAGE_MAP()
    
    
    //This function is called in response to the user pressing the Edit->Call dll //function sub menu item
    void CMainFrame::OnEditCalldllsfunction() 
    {
    	CFindFile	obj;
    	obj.DisplayMsgBox1();
    }
    
    
    LRESULT	CMainFrame::OnMsgFromDll(WPARAM	wParam, LPARAM	lParam)
    {
    	AfxMessageBox("Message from DLL");
    	return	0;
    }
    Please suggest where am i going wrong

    waiting for suggestions

    Regards

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    have a look at

    SendMessageCallback()
    HWND_BROADCAST
    RegisterWindowMessage()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unicode vurses Non Unicode client server application with winsock2 query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-16-2005, 08:26 AM
  2. Query related to recv()?
    By dp_76 in forum Networking/Device Communication
    Replies: 4
    Last Post: 05-16-2005, 08:25 AM
  3. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 01:34 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21