Solved

Subclassing Notification

Posted on 1998-09-08
4
303 Views
Last Modified: 2013-11-20
In my dialog box I got 2 edit boxes. First one is subclassed
by CMyEdit ( a general class derived from CEdit ). In CMyEdit I've handled WM_KILLFOCUS. Now I need to handle the killfocus event of my first edit box in my dialog box also.
This is the situation. How do I give notification to
the dialog from CMyEdit class and how to handle it in my dialog class. please explain it in detail.
0
Comment
Question by:krpadman
[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
  • 2
4 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1321912
The dialog box is the parent window of the edit box. You may define a message and post it to the dialog box.

#define    WM_MYNOTIFICATION        (WM_APP + 1)

ON_MESSAGE(WM_MYNOTIFICATION, OnMyNotification)

LONG CMyDialog::OnMyNotification(UINT, LONG)
{
    //...
    return 0L;
}

void CMyEdit::OnKillFocus(CWnd *pNewWnd)
{
    //...
    CWnd *pWndParent = this->GetParent();
    if (pWndParent != NULL)
         pWndParent->PostMessage(WM_MYNOTIFICATION);
    //...
}
0
 

Author Comment

by:krpadman
ID: 1321913
Thank you for your response.
This is working. But since CMyEdit is a generic class, in some other dialog, we may
have to have more than one edit boxes to be subclassed with CMyEdit. In that case
the parent window may not be able to distinguish between the messages of the edit
boxes. So can you suggest any other way to solve this problem. What about ON_NOTIFY_REFLECT? can we use this here? Please give me the steps to implement this.

0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1321914
Pass the window handle and ID of the edit controls along with the notification message.

void CMyEdit::OnKillFocus(CWnd *pNewWnd)
{
    //...
    CWnd *pWndParent = this->GetParent();
    if (pWndParent != NULL)
         pWndParent->PostMessage(WM_MYNOTIFICATION, (WPARAM)(this->GetSafeHwnd()), (LPARAM)(this->GetDlgCtrlID()));
    //...
}

LONG CMyDialog::OnMyNotification(UINT wParam, LONG lParam)
{
    HWND hWndEdit = (HWND)wParam;
    int nIDEdit = (int)lParam;
    //...
    return 0L;
}

0
 

Author Comment

by:krpadman
ID: 1321915
Thank you very much.
0

Featured Post

Independent Software Vendors: 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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

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