Solved

Message for a RUN TINE CREATED OBJECT

Posted on 2000-02-28
8
168 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now