Hi all,
Is it possible to make an application written by VC++/MFC looks exactly like VBasic forms.
Thanx in advance for any help.
Printable 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.
The answer is yes, since it is all Windows, but you'll need to be more specific than that to get any real help.
Everything is possible, but who needs it?Quote:
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.
VB forms looks better? I don't think so.
Anyhow, you can use your time and energy for a better ideal.
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.
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
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.Quote:
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.
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.
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();
}
ya, I think SDI with Multi-View is good, thanks for the help.
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.
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.
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?
Try usingAs you said, a menu command works fine, you can also send that command message usingCode:(CMainFarme*)AfxGetMainWnd()->OnChange()
Code:AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_YOURMENUID)
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.Quote:
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.
You forgot something:
Code:((CMainFrame*)AfxGetMainWnd())->OnChange();
yes, thats right, its ok now, thank you very much.