Solved

Get OnNotify on Dialog

Posted on 2011-09-29
6
1,212 Views
Last Modified: 2012-05-12
Hello,
I use a custom CProperySheet to catch the Tab SelChange Message. Eerything no problem, but how can I bypass it to the parent CDialog? I use attached code in the sublcass CPropertySheet.
Do I have to work with Reflect messages?

Ocrana
BOOL CResizablePropertySheet::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
	NMHDR* pNMHDR = (LPNMHDR) lParam;
	
	// The sheet resizes the page whenever it is activated
	// so we need to resize it to what we want
	if (pNMHDR->code == TCN_SELCHANGE)
		// user-defined message needs to be posted, not sent, because
		// page must be resized after TCN_SELCHANGE has been processed.
		PostMessage(WM_RESIZEPAGE);

	return CPropertySheet::OnNotify(wParam, lParam, pResult);
}

Open in new window

0
Comment
Question by:Ocrana
[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
  • 4
  • 2
6 Comments
 
LVL 34

Expert Comment

by:sarabande
ID: 36889992
the current code sends a WM_RESIZE to the property sheet itself, such that you can handle the message in OnResizePage:

LONG CResizablePropertySheet::OnResizePage(UINT, LONG)
{
   CPropertyPage * pPage = GetActivePage();
   ASSERT (pPage);
   pPage->MoveWindow(&m_rectPage);
   return 0;
}

Open in new window


here the GetActivePage would return a pointer to the new child dialog.

Sara
0
 

Author Comment

by:Ocrana
ID: 36890009
BUt the : return CPropertySheet::OnNotify(wParam, lParam, pResult); do not have any effect to the Parent window? I assume it will be send to the parent, too.
0
 
LVL 34

Expert Comment

by:sarabande
ID: 36890080
what parent do you mean? the property sheet is the parent window of all its pages. you can get a page window by GetActivePage() or GetPage(index) in the property sheet class (your derived class). then you can cast that pointer to the appropriate dialog class and call functions of that dialog. no need to send any notifications.

Sara
0
Industry Leaders: 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!

 
LVL 34

Expert Comment

by:sarabande
ID: 36890088
the call CPropertySheet::OnNotify(wParam, lParam, pResult) will change the active page of its tab control member. so before and after that call you would get old and new page by GetActivePage.

Sara
0
 

Author Comment

by:Ocrana
ID: 36890171
@sarabande
The parent iis the CDialog where the CPropertySheet is added to, please read my question.

So the parent window (CDialog) will not be able to receive the OnNotify message, too? Nothing about bypassed or reflected?
0
 
LVL 34

Accepted Solution

by:
sarabande earned 500 total points
ID: 36890281
if you have a parent dialog of the property sheet you can get a pointer to it by

CMyParentDialog * pParDlg = (CMyParentDialog *)GetParent();
if (pParDlg != NULL)
{
   pParDlg->notifyPageChange();
}

Open in new window


the notifyPageChange would be a public member function you have to provide. of course you can add arguments like old_page_index, new_page_index and more to the function.

Sara
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restore Windows 7 Snipping Tool function to Windows 10 10 107
asp Google Map 2 93
visual C++ 1 43
Visual Studio Start / Browser Emulator menu different 2 40
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

751 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