Print Page | Close Window

Calling GetActiveDocument from CMainFrame

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=7097
Printed Date: 12 November 2025 at 7:36pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Calling GetActiveDocument from CMainFrame
Posted By: gpeffers
Subject: Calling GetActiveDocument from CMainFrame
Date 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
 



Replies:
Posted By: Oleg
Date 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


Posted By: gpeffers
Date 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



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