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
Solved

Message for a RUN TINE CREATED OBJECT

Posted on 2000-02-28
8
193 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 147
Line meaning 9 87
Fibonacci challenge 11 132
Annoying "thing" blocks my view 4 115
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. …
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.

840 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