Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - how to access Document in CMainFrame
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to access Document in CMainFrame

 Post Reply Post Reply
Author
Message
lyric_li View Drop Down
Newbie
Newbie
Avatar

Joined: 12 June 2006
Location: China
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote lyric_li Quote  Post ReplyReply Direct Link To This Post Topic: how to access Document in CMainFrame
    Posted: 12 June 2006 at 10:31pm

Hi everyone,

I'm a new comer in using Xtreme Toolkit software.  I meet a problem with the UI development now. I used the demo codes which implements with outlook-style UI for the framework. And I want to  add some buttons in the toolbar to process some data in Doc.h, But I can't get the pointer to C**Doc class . Since CMainFrame class in this demo project is derived from CXTPFrameWnd, which seems not derived from MFC. So when I write

CWnd* pWnd= AfxGetMainWnd();

CMainFrame* pMainFrame= pWnd->GetParentFrame();

It doesn't wok well. pMainFrame always returns NULL. So I couldn't access Doc class by this way

C**Doc*  pDoc= pMainFrame->GetActiveDocument();

How could I get the reference to the frame window for this situation ?Hope anyone could give me a hand.

Thanks  very much,

 

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 12 June 2006 at 11:04pm

Hi,

must be

CMainFrame* pMainFrame= (CMainFrame*)AfxGetMainWnd()

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
lyric_li View Drop Down
Newbie
Newbie
Avatar

Joined: 12 June 2006
Location: China
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote lyric_li Quote  Post ReplyReply Direct Link To This Post Posted: 12 June 2006 at 11:28pm

thank you very much,it works

and how can I reference to Doc class by this pMainFrame pointer?

CMainFrame is derived from CXTPFrameWnd class which is not just like CFrameWnd class offered methods of accessing Doc class.

or there are some other ways to solve it? 

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 13 June 2006 at 7:45am

CXTPFrameWnd is derived from CFrameWnd... so

C**Doc*  pDoc= pMainFrame->GetActiveDocument();

will work.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
lyric_li View Drop Down
Newbie
Newbie
Avatar

Joined: 12 June 2006
Location: China
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote lyric_li Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2006 at 11:09pm
thanks very muchSmile
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.029 seconds.