[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Subclassing Notification

Posted on 1998-09-08
4
Medium Priority
?
316 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

650 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