How can i get a mouseevent message? help me!

I make a programme with Borland c++ Builder 4.0.
I want get a mouseevent message when mouse lbutton down,and i make a message handle,but it can't work,please help me.

There is the code:

#define MI_ICONEVENT (WM_APP + 1);
class TForm1 : public TForm
{
__published:      // IDE-managed Components
        TPopupMenu *PopupMenu1;
        TMenuItem *status;
        TMenuItem *n1;
        TMenuItem *close1;
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
protected:
  void __fastcall IconOnClick(TMessage &message);
BEGIN_MESSAGE_MAP
   MESSAGE_HANDLER(MI_ICONEVENT, TMessage, IconOnClick)
END_MESSAGE_MAP(TForm)
private:      // User declarations
  bool statu;
 void installicon();
 void changeicon(bool statu);
  void uninstall();
   public:            // User declarations
        __fastcall TForm1(TComponent* Owner);
 };

void __fastcall TForm1::IconOnClick(TMessage &message)
{ POINT p;
if (message.LParam=WM_LBUTTONDOWN)
ShowWindow( Application->Handle, SW_SHOW );
if (message.LParam = WM_RBUTTONDOWN)
{GetCursorPos(&p);
Form1->PopupMenu1->Popup(p.x,p.y );
}}

When i compile it,BDE give me a error message said "case statement expected;",
but i search it in help,there is no case statement.why??

thank you for answer.
afengAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZoppoCommented:
Hi afeng,

I'm not sure because I have no expierence with Borland, but with VC++ the BEGIN_MESSAGE_MAP/END_MESSAGE_MAP must appear outside of the class decleration.

hope that helps,

ZOPPO
0
gaurangbhattCommented:
Dear Afeng,

Just check out with the if condition statements.

They are as below :
if (message.LParam=WM_LBUTTONDOWN)

They should be
if (message.LParam == WM_LBUTTONDOWN)

The comparision is done using == and not =.

= means assignment and is not a case statement.
A case statement is one which compares.


The two statements you need to change are
if (message.LParam=WM_LBUTTONDOWN)  and
if (message.LParam=WM_RBUTTONDOWN)
           TO
if (message.LParam == WM_LBUTTONDOWN)
if (message.LParam == WM_LBUTTONDOWN)

 

Good Luck.
0
ZoppoCommented:
The error message occurs because BEGIN_MESSAGE_MAP, MESSAGE_HANDLER and END_MESSAGE_MAP are macros which implement a switch/case block to map the messages to the functions.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

ZoppoCommented:
gaurangbhatt : something like 'if ( a = b )' does not produce a compiler error, because it's legal expression. It's also not a case statement! You're right mentioning these errors (which I did not see in cause of hurry), but they're not the cause for the compiler error.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gaurangbhattCommented:
Yes you are right, Zoppo.
0
afengAuthor Commented:
Hi:
 thank you all!
 The trouble is gone.After I correct the the error in "if message.LParam=WM_LBUTTONDOWN)  
if (message.LParam=WM_RBUTTONDOWN) " ,
the error message also in. I hardly find the true mistake.Then, I seached the topic in help,found the example about it.I found "#define MI_ICONEVENT (WM_APP + 1); " in the example have no the char ";",so ,I delete the char,
and the trouble has gone.
 
 thanks you a lot!,Zoppo
 thank you al!


 
0
ZoppoCommented:
Just for interest:

Do you sill have the BEGIN_MESSAGEMAP/END_MESSAGEMAP within the declaration of the class?

ZOPPO
0
afengAuthor Commented:
thank you all!
the error has gone.
the trouble is come from the line"#define .........;",
after i delete the char ";",trouble gone.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.