![]() |
Megaproblem |
Post Reply
|
| Author | |
Ky3bkuHa MaTb
Newbie
Joined: 13 March 2006 Location: Russian Federation Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Topic: MegaproblemPosted: 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. 2006-03-13_235601_test23.rar |
|
![]() |
|
Sven
Senior Member
Joined: 21 August 2003 Location: Germany Status: Offline Points: 127 |
Post Options
Thanks(0)
Quote Reply
Posted: 14 March 2006 at 7:02am |
AfxGetApp() returns a CWinApp object and not a CMainFrame. |
|
![]() |
|
Ky3bkuHa MaTb
Newbie
Joined: 13 March 2006 Location: Russian Federation Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
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 ? |
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 14 March 2006 at 3:59pm |
|
AfxGetMainWnd.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Red Devil
Newbie
Joined: 15 March 2006 Location: Zimbabwe Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 15 March 2006 at 12:04am |
|
Yes, my problem is disappear, thank you very match. Really good support.
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |