Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1296
  • Last Modified:

PostMessage Help

Please help me,

I am try to write a C++ application that I need to work with a VB application I already have. I want to allow the applications to talk to each other via the post message function.

When I try to call the postmessage function in my C++ application I get the following error:

error C2660: 'PostMessageA' : function does not take 4 parameters

but it in fact does take 4 the parameter browser says it only takes 3 parameters, but every other piece of documetation for this points to four parameters. Please help
0
ce34ll
Asked:
ce34ll
  • 5
  • 3
1 Solution
 
AlexFMCommented:
MFC CWnd::PostMessage:

BOOL PostMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 );

PostMessage API (without MFC):

BOOL PostMessage(
  HWND hWnd,      // handle to destination window
  UINT Msg,       // message
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);

If you call PostMessage from CWnd-derived class in MFC application, you should use MFC function (without first hWnd parameter) or non-MFC function with "::"

PostMessage(nMessage, 0, 0);  // MFC function
::PostMessage(hwnd, nMessage, 0, 0);  // API
0
 
ce34llAuthor Commented:
I tried to put the two : in front of it, still got this response

error C2660: 'PostMessageA' : function does not take 4 parameters
0
 
AlexFMCommented:
Please show your code.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ce34llAuthor Commented:
I dont have any code, nothing will compile right.

This will not work

::PostMessage(hwnd,WM_USER + 1,0,0)

not does this
PostMessage(hwnd,WM_USER + 1,0,0)

I have included the windows.h file which includes the winuser.h file and has the dec in it:

WINUSERAPI
BOOL
WINAPI
PostMessageA(
    HWND hWnd,
    UINT Msg,
    WPARAM wParam,
    LPARAM lParam);
WINUSERAPI
BOOL
WINAPI
PostMessageW(
    HWND hWnd,
    UINT Msg,
    WPARAM wParam,
    LPARAM lParam);
#ifdef UNICODE
#define PostMessage  PostMessageW
#else
#define PostMessage  PostMessageA
#endif // !UNICODE
0
 
AlexFMCommented:
Show your code which is not compiled.
0
 
ce34llAuthor Commented:
PostMessage is the first line of my code, I have nothing to show at this point. Show me a win32 dll where this message does work, and I'll give the question to you, better yet, show me a vb application sending and receiving strings using the post message API and I will open 4 more questions, each worth 250 points and award them all to you.
0
 
ce34llAuthor Commented:
PostMessage is the first line of my code, I have nothing to show at this point. Show me a win32 dll where this message does work, and I'll give the question to you, better yet, show me a vb application sending and receiving strings using the post message API and I will open 4 more questions, each worth 250 points and award them all to you.
0
 
ZoppoCommented:
Hi ce34ll,

this DLL can be compiled:

// test.h file
#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif

TEST_API void func(void); // declaration


// test.cpp file
#include <windows.h>
#include "test.h"

// This is an example of an exported function.
TEST_API void func(void)
{
     ::PostMessage( HWND_BROADCAST, WM_USER + 1000, 0, 0 );
}

ZOPPO


PS: You really should post the code which cannot be compiled ...
it's really hard to find the problem by just guessing how
you code may look like.
0
 
ce34llAuthor Commented:
thanks I will try this later and let you know....
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now