Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - General MFC problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

General MFC problem

 Post Reply Post Reply
Author
Message
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post Topic: General MFC problem
    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
Back to Top
pascal View Drop Down
Groupie
Groupie


Joined: 07 February 2005
Location: Germany
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote pascal Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
pascal View Drop Down
Groupie
Groupie


Joined: 07 February 2005
Location: Germany
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote pascal Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
terrym View Drop Down
Senior Member
Senior Member


Joined: 13 April 2007
Status: Offline
Points: 836
Post Options Post Options   Thanks (0) Thanks(0)   Quote terrym Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
kylechen View Drop Down
Groupie
Groupie


Joined: 29 November 2004
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote kylechen Quote  Post ReplyReply Direct Link To This Post Posted: 12 September 2007 at 10:58am
Ever got the same problem here, thank you for reply.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.078 seconds.