?
Solved

PostMessage Help

Posted on 2003-03-24
9
Medium Priority
?
1,254 Views
Last Modified: 2013-11-20
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
Comment
Question by:ce34ll
[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
  • 5
  • 3
9 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 8200732
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
 

Author Comment

by:ce34ll
ID: 8200869
I tried to put the two : in front of it, still got this response

error C2660: 'PostMessageA' : function does not take 4 parameters
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8200889
Please show your code.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ce34ll
ID: 8200922
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
 
LVL 48

Expert Comment

by:AlexFM
ID: 8200935
Show your code which is not compiled.
0
 

Author Comment

by:ce34ll
ID: 8200954
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
 

Author Comment

by:ce34ll
ID: 8200974
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
 
LVL 31

Accepted Solution

by:
Zoppo earned 1000 total points
ID: 8201336
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
 

Author Comment

by:ce34ll
ID: 8206854
thanks I will try this later and let you know....
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

770 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