Solved

Message for a RUN TINE CREATED OBJECT

Posted on 2000-02-28
8
209 Views
Last Modified: 2013-11-20
I created a SDI application using the application wizard.

Then i simply created a button which would float at the position where the right click of the mouse occurs.

Now i want to do
MessageBox("sucessful");

when the user clicks on the floating button . How can i do this?

How is the Message map constructed and used ?

Thanks for our help.

NPG
0
Comment
Question by:ghimireniraj
[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
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:gelbert
ID: 2566217
You should use OnRButtonUp() to find out position of button, move and display it there (MoveWindow()).
You would need to implement ON_BN_CLICKED( ButtonID ) handler to catch when user click on button.
0
 
LVL 3

Author Comment

by:ghimireniraj
ID: 2567214
thanks that was helpful for me

can you tell me how i can create my own message and use it.Please explain

0
 
LVL 8

Accepted Solution

by:
VinExpert earned 10 total points
ID: 2567421
Hi niraj,

It is like this...

1. First declare Ur own message as
#define WM_MYMESSAGE WM_USER+10

2.Then in the .h file make the message map entry as

afx_msg void OnMyMessage(WPARAM wParam, LPARAM lParam);

3. Then in cpp file, between

BEGIN_MESSAGE_MAP
....
ON_MESSAGE( WM_MYMESSAGE, OnMyMessage)
....
END_MESSAGE_MAP()

4. Then write the function body as
void XXXXX::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
//whatever U want to do
}

Try it out.

VinExpert
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:ghimireniraj
ID: 2569710
Thanks VInExpert

IS it VIN--- KUM---?

Tell me how i can generate this message
event?
I mean like to activate this message?

PostMessage?

Thanks
0
 
LVL 3

Author Comment

by:ghimireniraj
ID: 2569753
how is WPARAM and LPARAM used
0
 
LVL 8

Expert Comment

by:gelbert
ID: 2569977
1.All messages are sent by Windows

2.Inthe .h file make the message map entry as

afx_msg void OnRButtonUp( UINT nFlags, CPoint point);

3. Then in cpp file, between

BEGIN_MESSAGE_MAP
.....
ON_WM_RBUTTONUP()
ON_BN_CLICKED( MyButtonID, OnButtonClicked)
.....
END_MESSAGE_MAP()

4. Then write the function body as
void XXXXX::OnMyMessageOnRButtonUp( UINT nFlags, CPoint point)
{
  m_pMyButton->MoveWindowWindow( point.x, point.y )
}

5. When you press button(whcih has style WS_CHILD), Windows generates BN_CLICKED. Write function
void OnButtonClicked()
{
   AfxMessageBox("Clicked!!");
}


0
 
LVL 8

Expert Comment

by:VinExpert
ID: 2571356
Hi,

Yes, U guessed it right.

And, yes again, U have to use

SendMessage(WM_MYMESSAGE, 0, 0);
or
PostMessage(WM_MYMESSAGE, 0, 0);

to trigger that message.

U can use the WPARAM and LPARAM parameters for passing additional information to Ur function. If U say

SendMessage(WM_MYMESSAGE, 1, 0);

Then in Ur function wParam will be 1.

Like that U can use it.

Try it out.

VinExpert
0
 
LVL 3

Author Comment

by:ghimireniraj
ID: 2631578
thx
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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