Solved

Get OnNotify on Dialog

Posted on 2011-09-29
6
1,169 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
  • 4
  • 2
6 Comments
 
LVL 32

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 32

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 32

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 32

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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.
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now