Solved

Message for a RUN TINE CREATED OBJECT

Posted on 2000-02-28
8
186 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 88
Perl Awk Need Help 3 120
centeredAverage challenge 8 167
noX challenge 17 120
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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