Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Calling GetActiveDocument from CMainFrame
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Calling GetActiveDocument from CMainFrame

 Post Reply Post Reply
Author
Message
gpeffers View Drop Down
Newbie
Newbie


Joined: 02 May 2007
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote gpeffers Quote  Post ReplyReply Direct Link To This Post Topic: Calling GetActiveDocument from CMainFrame
    Posted: 09 May 2007 at 3:36pm
I'm trying to call GetActiveDocument() from within a CMainFrame class derived from CXTPFrameWnd, but the call always returns NULL.  Tracing into the GetActiveDocument() call, it appears to return NULL  because the View is also NULL.
 
I'm working on an app using a ShortcutBar.  Just to see if I could narrow down the problem, I've taken the Codejock ShortcutBar sample app and added a call to GetActiveDocument() in the CMainFrame::OnCustomize member and I still see NULL returned for the document.  I chose this member function only because everything should have been completely initialized by the time is was available.
 
Can anyone give me a clue as to what I'm doing wrong?  I'm working with XTP 11.1.0.
 
Thank you,
Glenn
 
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2007 at 1:29am
Hi,
if you use MDI its correct behavior.
 
call GetActiveFrame()->GetActiveDocument() instead.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
gpeffers View Drop Down
Newbie
Newbie


Joined: 02 May 2007
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote gpeffers Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2007 at 9:07am
oleg,
 
I'm sorry, but this does not fix it.  The document is still returned as NULL even in the Codejock ShortcutBar sample.
 
Just to clarify, what I've done is added a line of code to the standard Codejock ShortcutBar sample as shown below:
 
void CMainFrame::OnCustomize()
{
 
  GetActiveFrame()->GetActiveDocument();
 
  // get a pointer to the command bars object.
  CXTPCommandBars* pCommandBars = GetCommandBars();
  if (pCommandBars == NULL)
    return;
 
  ...........
 
I've added the code here only as a test to see if I can get the active document once the app is up and running.  Inside GetActiveDocument(), the call to GetActiveView() returns NULL and therefore returns NULL for the document as well.
 
I'm not sure if it's ShortcutBar related, but this works fine in other applications.
 
Thanks,
Glenn
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.063 seconds.