mfc >> How can a CEdit notify his parent dialog of a change?

by R2Vv » Sat, 29 Jan 2005 21:49:02 GMT

Hi to all,

I'm using an edit box as a protected user input. The edit box is by default
read-only and it allows only digits to be entered.

When the user wants to write into the edit box, he has to double click on it
to enable writing (read-only = FALSE). When he finishes entering his info, he
has to double click on the edit box again to apply the entered value. The
edit box will then switch back to read-only.

I'm doing this by creating a new class CRoEdit (for read-only) derived from
CEdit which all it does is catch the double click and set the read-only
accordingly. Here's the only member function in CRoEdit:

void CRoEdit::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if ((GetStyle() & ES_READONLY) == ES_READONLY)
SetReadOnly(FALSE);
else
{
// The user has finished entering his value. Set the edit box back
to read-only
// and inform the parent dialog of a change in the value.
SetReadOnly(TRUE);
}
CEdit::OnLButtonDblClk(nFlags, point);
}

My problem is that I don't know how can I make the CRoEdit class notify the
CDialog class (which contains the edit control) that a new value has been
entered so that CDialog could read it with "m_roEdit.GetWindowText()" to get
the value entered.

I appreciate any help or suggestions.

Thanks,

Geo



mfc >> How can a CEdit notify his parent dialog of a change?

by Scott McPhillips [MVP] » Sat, 29 Jan 2005 22:49:54 GMT






Hi Geo,
Define a custom message
#define UWM_GEO_MESSAGE (WM_APP + 1)

..and send it to the parent dialog like this:
GetParent()->SendMessage(UWM_GEO_MESSAGE, 0, 0);

The parent dialog message map will need
ON_MESSAGE(UWM_GEO_MESSAGE, OnGeoMessage)

and the message handler must match this prototype:
LRESULT CxxDlg::OnGeoMessage(WPARAM w, LPARAM l)

--
Scott McPhillips [VC++ MVP]




mfc >> How can a CEdit notify his parent dialog of a change?

by R2Vv » Sat, 29 Jan 2005 23:15:05 GMT

Thanks a lot Scott, it's working fine although by mistake I used:
SendMessage(UWM_GEO_MESSAGE, 0, 0);

instead of:
GetParent()->SendMessage(UWM_GEO_MESSAGE, 0, 0);

Do you think it's important?

Thanks again,
Geo






How can a CEdit notify his parent dialog of a change?

by Ajay Kalra » Mon, 31 Jan 2005 00:48:33 GMT

When you use GetParent()->SendMessage, you are sending it to the parent,
thats your goal. When you use it simply as SendMessage, you are sending it
to the control itself(thats not what you want).






notify the
been
to get




Similar Threads

1. modeless child dialog notifying parent

How do you get the child modeless dialog to notify the parent that the user 
closed the window?

I have a push button that is depressed when the window is visible, and 
normal when the window is invisible.  I need to know if the user closed the 
window so I can reset the push button.

Running spy++ shows that there isn't a message being sent that could 
identify the child window being closed.  The closest I could do is 
WM_ACTIVE, when the parent window is activated and the last active window 
was the child, I could then check to see if the child is hidden or not... 
however is it a fact that if my child closes, the next active window will be 
its parent?


Thanks,

Nick



2. Dynamically-created CEdit != CEdit from dialog template

3. Notifying MDI parent

On Wed, 5 Nov 2003 20:32:40 -0000, Tito Serenti< XXXX@XXXXX.COM > 
said ...
> Could someone please tell me how I can (in a sensible way) notify the MDI
> parent form that MDIChildCount is 0 after the last child form closes? The
> only way I can think of is to include the notification (like send a message)
> in OnClose or OnDestroy of the child form, but at that time MDIChildCount is
> still 1. I need to disable the FullScreen button when there are no child
> forms.

1) You could use PostMessage instead of SendMessage

2) You could disable the button when you get a notification with one form 
open since you know what's going to happen next

3) I think the real solution is Actions which update themselves 
automatically

Marc

4. Parent-Child DataGridViews and how to tell when the parent record changes - CSharp/C#

5. Closing a child Dialog when the Mouse button is clicked outside the Parent Dialog

Hai
  I Have a Parent Dialog and a ChildDialog associated with that and when the
mouse is clciked outside the Parent Dialog the child window has to be closed
and the parent dialog has to minimized to the taskbar please let me know how
to handle this situation
                     Thanks and Regards
                              sures h


6. Is it possible to put a Dialog in a Parent Dialog

7. Child Modeless Dialogs Always Hide Parent Modeless Dialog

My app is dialog based. The main dialog is essentially a web browser. It has 
menu items that open other modeless dialogs. (One shows the page source, one 
shows the current search path set.) The problem that I am having is that the 
child dialogs (source and paths view) always hide the parent. They do not 
hide each other. (i.e. the active one always comes to the top of the display 
stack)

The main dialog is run modeless (using Create), and has its parent window 
pointer set to NULL.

I can activate the main dialog, but it remains hidden behind the others if 
they are on the screen. What I want is to be able to activate any of the 
three windows and have it displayed in front of the others.

I have tried the following:
1) Setting m_pMainWnd to NULL in the app's InitInstance method. This just 
causes the app to close immediately after it starts.

2) Runing the main dialog using DoModal, rather than Create. This changed 
nothing. (The modeless child dialogs were created and could be activated. 
Somehow, I thought this wouldn't work if their parent was a modal dialog. It 
seems to violate the "modal-ness" of the parent. That's why I made the main 
dialog be modeless to begin with.)

3) Having the child dialogs pass a NULL pParent pointer to the CDialog 
constructor. This changed nothing.

I have also edited the resource file using the text editor and made sure 
that the dialogs are created with the same styles. This changed nothing.

How can this be done? I have considered making an invisible modeless dialog 
that is the main window for the app, then running all of mine as children of 
that one, but it seems like a rather roundabout approach. Is there something 
simple that I have missed?

Thanks,
Rush

8. Modeless Dialog is not allowing the parent Modal dialog