Solved

Message for a RUN TINE CREATED OBJECT

Posted on 2000-02-28
8
176 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Named range not carried over 10 62
Shell script to login to remote m/c and execute commands 10 78
how to monitor remote shell execution on linux 9 97
sumNumber challenge 16 110
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

910 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

23 Experts available now in Live!

Get 1:1 Help Now