View / Childframe activation
-
Hi, is there a function or message that is sent to a Childframe or view when it becomes active? In other words, I have a few MDI documents open and would like to be notified when the user selects one (it becomes the view that gets focus), or if one of the child's views becomes the active one. I need to know when the user selects between these views when they are selected, but not simply which one is the active view at any given time. Thanks!
-
Hi, is there a function or message that is sent to a Childframe or view when it becomes active? In other words, I have a few MDI documents open and would like to be notified when the user selects one (it becomes the view that gets focus), or if one of the child's views becomes the active one. I need to know when the user selects between these views when they are selected, but not simply which one is the active view at any given time. Thanks!
Take a look at CWnd::OnMDIActivate -- jlr http://jlamas.blogspot.com/[^]
-
Take a look at CWnd::OnMDIActivate -- jlr http://jlamas.blogspot.com/[^]
Too freaking simple! :mad: Thank you for the direction. I needed to tweak it a bit, but it is perfect! :)
LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) { if(((HANDLE) wParam == this->m_hWnd) && (IsWindowVisible())) TRACE("ChildFrame - I'm Activated!\n"); return 0L; }
-
Too freaking simple! :mad: Thank you for the direction. I needed to tweak it a bit, but it is perfect! :)
LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) { if(((HANDLE) wParam == this->m_hWnd) && (IsWindowVisible())) TRACE("ChildFrame - I'm Activated!\n"); return 0L; }
Paul Belikian wrote: LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) Hmm... Since you are using MFC, a simpler approach would be as follows: In your class declaration :
afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
In your class implementation file:
BEGIN_MESSAGE_MAP(CWinCTestFrame, [baseClass])
//{{AFX_MSG_MAP(CWinCTestFrame)
ON_WM_MDIACTIVATE()
.
.
.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CWinCTestFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
CMultiFrame_base::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
if (bActivate)
TRACE("ChildFrame - I'm Activated!\n");();
}bActivate
will beTRUE
orFALSE
, depending on whether the child is being activated or deactivated, whilepActivateWnd
andpDeactivateWnd
will point to the child being activated or deactivated, respectively. More details at MSDN[^] BTW, I don't think the call to IsWindowVisible() in your code is making any difference; 'visible' is not the same as 'active'. -- jlr http://jlamas.blogspot.com/[^] -
Paul Belikian wrote: LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) Hmm... Since you are using MFC, a simpler approach would be as follows: In your class declaration :
afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
In your class implementation file:
BEGIN_MESSAGE_MAP(CWinCTestFrame, [baseClass])
//{{AFX_MSG_MAP(CWinCTestFrame)
ON_WM_MDIACTIVATE()
.
.
.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CWinCTestFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
CMultiFrame_base::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
if (bActivate)
TRACE("ChildFrame - I'm Activated!\n");();
}bActivate
will beTRUE
orFALSE
, depending on whether the child is being activated or deactivated, whilepActivateWnd
andpDeactivateWnd
will point to the child being activated or deactivated, respectively. More details at MSDN[^] BTW, I don't think the call to IsWindowVisible() in your code is making any difference; 'visible' is not the same as 'active'. -- jlr http://jlamas.blogspot.com/[^]Thanks again! Your suggestion also looks cleaner :) and I'll do it the way you suggested. Jose Lamas Rios wrote: BTW, I don't think the call to IsWindowVisible() in your code is making any difference; 'visible' is not the same as 'active'. Yes, that's true, but in my application, when the view becomes 'active' it sends a message to the mainframe to trigger further action (it's a long story :^) ). The IsVisible call prevents the childframe from sending that message to the mainframe when the child is being closed. Once again, thank you for your help and responses! :-D Paul...