-
June 14th, 2004, 09:17 AM
#1
Form view
Hi all,
Is it possible to make an application written by VC++/MFC looks exactly like VBasic forms.
Thanx in advance for any help.
-
June 14th, 2004, 09:50 AM
#2
The answer is yes, since it is all Windows, but you'll need to be more specific than that to get any real help.
-
June 14th, 2004, 09:51 AM
#3
Re: Form view
Originally posted by froten_140
Hi all,
Is it possible to make an application written by VC++/MFC looks exactly like VBasic forms.
Thanx in advance for any help.
Everything is possible, but who needs it?
VB forms looks better? I don't think so.
Anyhow, you can use your time and energy for a better ideal.
-
June 14th, 2004, 10:04 AM
#4
thanx all for your replay,
I was programming in VB, for some time ago a moved to VC++ and Im trying to write some VB programs in VC++, because in VB I was using some commands like hide.me and show.form1. I would like to write the programs but in VC++.
What I need is how to write programm with its view is a form and how to show and hide that form to show another one.
thanx again for any help.
-
June 14th, 2004, 10:27 AM
#5
Well, it seems that you are at the very beginning in VC++/MFC.
No problem we all were in the point 0 once.
But that makes to be difficult for me to give you an answer.
Start learning using AppWizard and create a dialog-based application, and...
Search for VC++/MFC tutorials and go ahead.
Good luck,
Ovidiu
-
June 14th, 2004, 10:42 AM
#6
Originally posted by froten_140
thanx all for your replay,
I was programming in VB, for some time ago a moved to VC++ and Im trying to write some VB programs in VC++, because in VB I was using some commands like hide.me and show.form1. I would like to write the programs but in VC++.
What I need is how to write programm with its view is a form and how to show and hide that form to show another one.
thanx again for any help.
Don't try to learn C++ by forcing it conform to what you know in VB. It is a much different languaue and approach to programming. Learn it for what it is and you won't look back.
-
June 15th, 2004, 02:10 AM
#7
I'm not a very beginer to VC++, I have done many programs in VC and have a good understanding of the language and MFC, just few Tips will be enough . I derived my view class from CFormView in SDI application, but I want to remove that small edge in the main frame of the application, tried to change the window styles in the create struct (cs) in the CMainFrame::PreCreateWindow but it didn't work.
any tips will be usefull.
Last edited by froten_140; June 15th, 2004 at 02:14 AM.
-
June 15th, 2004, 04:25 AM
#8
Hmm, I just finished a project like that:
Basically what you are asking is how to write a Multi-View SDI application.
Unfortionatly from what I have seen, it is not a trivial task in MFC as opposed to VBASIC or other languages.
I recommend that you do a search on the net "multi-view SDI".
There is an example in the ENROLL step 4 that switches between two views in an ODBC application.
Also read my thread where I mention that I just completed a 4 screen formview project.
All I can say is that don't feel like a the LONE-RANGER, it's not a trivial task, but once you get it down, it will really open up your imagination:
If you can understand the code below, you will be on your way!!
void CMainFrame::SwitchToForm(int nForm)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*)GetDlgItem(nForm);
if (pNewActiveView == NULL)
{
if (nForm == IDW_COURSE_FORM)
pNewActiveView = (CView*)new CCourseForm;
else if (nForm == IDW_STUDENT_FORM)
pNewActiveView = (CView*)new CStudentForm;
else if (nForm == IDW_INSTRUCTOR_FORM)
pNewActiveView = (CView*)new CStudentForm;
else
pNewActiveView = (CView*)new CSectionForm;
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,
this, nForm, &context);
pNewActiveView->OnInitialUpdate();
}
SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);
pOldActiveView->SetDlgCtrlID(m_CurrentViewID);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_CurrentViewID = nForm;
RecalcLayout();
}
-
June 15th, 2004, 05:41 AM
#9
ya, I think SDI with Multi-View is good, thanks for the help.
-
June 15th, 2004, 05:59 PM
#10
I have been doing a little reading on VISUAL BASIC, and basically that is how they (and C#) switch views/forms too. The activate on and HIDE the other.
-
June 22nd, 2004, 01:26 PM
#11
Could some body please tell where to find a tutorial about writing a MultiView SDI application, i couldn't find any, and I have faced some defeculties making that by myself.
thanxs in advance for any help.
-
June 23rd, 2004, 01:55 AM
#12
after a hard work last night, I could change from one form to another by menu commands, but what i need is to change from form to form by clicking a button on the form is currently displayed, the function that changes the forms is a member function in the CMainFrame, how can I call that function from the view class, it is a simple thing but I have problem to make that. I think I should get a pointer to the CMainFrame which I don't know how to do that.
any tips or help will be greatly Appreciated.
The function I used to change the view is like this:
void CMainFrame::OnChange()
{
CView* pOldView;
CView* pNewView;
CDocument* pDoc = GetActiveDocument();
pOldView = GetActiveView();
pNewView = new CForm_2;
pNewView->Create( NULL,
NULL,
AFX_WS_DEFAULT_VIEW,
rectDefault,
this,
AFX_IDW_PANE_FIRST + 1
,NULL);
pNewView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pNewView->ShowWindow(true);
pOldView->ShowWindow(false);
pDoc->AddView(pNewView);
SetActiveView(pNewView);
RecalcLayout();
}
the function that handles the button click event to change the view is:
void CAppNameView::OnChange()
{
CMainFrame::OnChange();
}
the compiler is giving this error message "Illigal call of a non-static member function".
what is rong?
Last edited by froten_140; June 23rd, 2004 at 02:08 AM.
-
June 23rd, 2004, 03:06 AM
#13
Try using
Code:
(CMainFarme*)AfxGetMainWnd()->OnChange()
As you said, a menu command works fine, you can also send that command message using
Code:
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_YOURMENUID)
-
June 23rd, 2004, 03:32 AM
#14
I just tried:
(CMainFrame*)AfxGetMainWnd()->OnChange();
but the compiler is giving me this erroer "OnChange is not a member of CWnd".
any more help please.
-
June 23rd, 2004, 04:01 AM
#15
Originally posted by froten_140
I just tried:
(CMainFrame*)AfxGetMainWnd()->OnChange();
but the compiler is giving me this erroer "OnChange is not a member of CWnd".
any more help please.
Of course it's not.
You forgot something:
Code:
((CMainFrame*)AfxGetMainWnd())->OnChange();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|