Solved

Sending messages to child windows from dialog box in another class

Posted on 1998-09-10
3
217 Views
Last Modified: 2010-08-05
Hi...

I need to know how for example to create a new child window in an mdi application from a click on a button in a modeless
dialog box with its own class
and not by..clicking the menu buttons or toolbar buttons. Do i have to post messages to my main frame/client window then
send messages to my child window again....

please please help...i'm stuck
p.s i'm using visualc++, mdi class wizard to create my program
0
Comment
Question by:ramesh_mirpuri
[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
  • 2
3 Comments
 
LVL 2

Expert Comment

by:duneram
ID: 1172449
Windows is event driven.

If the user presses a button, you should create the window at that point in time.  If you choose to send messages, its better to use the PostMessage api to do it.  Why?  its asynchronous when you do it that way

In your MainFrm.cpp file take a look in classwizard for
ID_FILE_OPEN
use it to create a function.  You basically want this functionality to execute whenever this event is suppsoed to happen.


0
 
LVL 1

Accepted Solution

by:
softev earned 50 total points
ID: 1172450
The most common way is to PostMessage and add a message
handler for the specific message sent into the object you
want to open the window.  

If this is or will become common functionality in your application, consider setting up your "own" notification system.
Base it on Posting user defined messages ( WM_USER+ some number for each distinct message ) and catch them in areas of the application that will deal directly with that message.

You can easily acheive this by placing a message manager in
your main application and registering every object ( or window )
that you would have process a given message.  For example, use a
pMainApp->RegisterMe( this ) type of call to register the window.
All you will need is a Object pointer array in the main app
to store registered objects. All notification messages get sent like this from other objects pMainApp->SendNotify( WM_USER + 123 ).  When MainApp gets the notification it can send it down directly to objects that are interested
in receiving it ( in the array ).



0
 
LVL 2

Expert Comment

by:duneram
ID: 1172451
I would say you would in general be better off using RegisterWindowsMessage for your unique message ID's.  if you use that API you are guaranteed uniqueness....   If you use the WM_USER+... there is a chance you may walk on something else or vice versa..  If a different app uses the same one you pick and happens to use HWND_BROADCAST you would then respond to his message thinking its your message.  RegisterWindowsMessage is a better way to go.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

726 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