Small MFC Note: TabCtrl Sons window delivery message

First, demand

MFC interface has a setting dialog, the actual use of the sub-dialog TabCtrl + form. When setting the parameters in the sub-dialog, you require the results back to the bottom of the parent window. Such unified information output. This article addresses the question: How in the sub-window, get the parent window handle, and output in the parent window Static Control.

Second, the design

Dialog interface, the main window is a TabCtrl, below is a Static control. The process is omitted.

Third, coding

In the sub-header file dialog window pointer declaration:

CWnd* m_pTabParentWnd; // Tab父类窗口指针,注:m_pParentWnd在父类中已有定义,故改名

Get pointer to the parent window in the sub-dialog OnInitDialog function:

m_pTabParentWnd = GetParent()->GetParent();

Note that you need to call two GetParent()functions, the father of the child dialog window, actually TabCtrl, TabCtrl the parent window is the main interface window. (But reads hidden layer, directly call the parent window)
m_pTabParentWnd i.e. the parent window pointer, in the corresponding response function by the parent window pointer, to obtain GetDlgItem call control, call again to output information SetWindowTextW. Such as:

m_pTabParentWnd->GetDlgItem(IDC_STC_SET_TIPS)->SetWindowTextW(L"参数设置成功");

Other sub-dialog can be subjected to the same treatment.

Published 481 original articles · won praise 244 · Views 1.1 million +

Guess you like

Origin blog.csdn.net/subfate/article/details/103651141