Print Page | Close Window

General MFC problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=7978
Printed Date: 13 November 2025 at 11:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: General MFC problem
Posted By: terrym
Subject: General MFC problem
Date Posted: 11 September 2007 at 4:19pm
Anybody know what function is called after OnShowWindow() in MFC ???
 
As I need to make sure a window is shown before showing a dialog, currently have in a timer, but this sometimes fails.
 
Any help much appreciated
 


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey



Replies:
Posted By: pascal
Date Posted: 11 September 2007 at 5:37pm
Hi,
I use a workaround for this:
    - I define a member BOOL m_bFirstActivation, initialized with FALSE
    - catch the message WM_ACIVATE - ON_WM_ACTIVATE()
    - toggle m_bFirstActivation in the message method, do the first initialization

void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);

// TODO: Add your message handler code here
switch( nState )
{
case WA_CLICKACTIVE: case WA_ACTIVE:
if( m_bFirstActivation == FALSE )
{
OnFirstActivation();
m_bFirstActivation = FALSE;
}
break;
case WA_INACTIVE:
break;
}
}
Hope that it will help you. There is may be a better way ...

BR
Pascal


-------------
Pascal Verdier
Software Engineer Manager


Posted By: pascal
Date Posted: 11 September 2007 at 5:40pm
Sorry, i make a mistake:
...
- I define a member BOOL m_bFirstActivation, initialized with TRUE
...
case WA_ACTIVE:
if( m_bFirstActivation == TRUE )
{
OnFirstActivation();
m_bFirstActivation = FALSE;
}
break;

that is
Pascal



-------------
Pascal Verdier
Software Engineer Manager


Posted By: terrym
Date Posted: 12 September 2007 at 6:13am
Cheers, for that, as much better than timer implementation


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey


Posted By: terrym
Date Posted: 12 September 2007 at 7:46am
Found a better implementation, is to start a timer, then in the timer function to have
 
IsWindowVisble()
 
and if not then exit timers
 
Also playing with WM_WINDOWPOSCHANGED
 
Cheers
Terry
 


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey


Posted By: terrym
Date Posted: 12 September 2007 at 9:41am
Ok the best method is to handle this in the WM_WINDOWPOSCHANGED message as this happens just after the window has appeared
 
It works perfect now, cheers


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey


Posted By: kylechen
Date Posted: 12 September 2007 at 10:58am
Ever got the same problem here, thank you for reply.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net