Print Page | Close Window

Megaproblem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=3771
Printed Date: 16 September 2024 at 4:20pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Megaproblem
Posted By: Ky3bkuHa MaTb
Subject: Megaproblem
Date Posted: 14 March 2006 at 12:08am
VC++ 6.0 SP 6

I create SDI app with your wizard and adding members to MainFrame class. When i getting this variables (public variable or get function) i always getting zero.

Example.
Add to MainFrame : public: int num;
In MainFrame constructor: num = 10;
In View class add function :
void CMyView::OnAnyMenuItem() {
     char buf[10];
     sprintf(buf, "%d", ((CMainFrame*)AfxGetApp())->num);
     AfxMessageBox(buf); // 0 , but must be 10
}

On my example its function menu Edit -> Test.

If create function in CMainFrame.
void CMainFrame::OnAnyMenuitem() {
     char buf[10];
     sprintf(buf, "%d", num);
     AfxMessageBox(buf); // 10 right
}

They works rigth. I nothing understand.

uploads/Ky3bkuHaMaTb/2006-03-13_235601_test23.rar - 2006-03-13_235601_test23.rar





Replies:
Posted By: Sven
Date Posted: 14 March 2006 at 7:02am
Quote sprintf(buf, "%d", ((CMainFrame*)AfxGetApp())->num);

AfxGetApp() returns a CWinApp object and not a CMainFrame.


Posted By: Ky3bkuHa MaTb
Date Posted: 14 March 2006 at 12:39pm
I suspect.
But how call function from CMainFrame class? If  AfxGetApp() is not enable do this, what enable do this ?


Posted By: Oleg
Date Posted: 14 March 2006 at 3:59pm
AfxGetMainWnd.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Red Devil
Date Posted: 15 March 2006 at 12:04am
Yes, my problem is disappear, thank you very match. Really good support.



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