CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Form view

  1. #1
    Join Date
    Jun 2004
    Posts
    22

    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.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635
    The answer is yes, since it is all Windows, but you'll need to be more specific than that to get any real help.

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Jun 2004
    Posts
    22
    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.

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234
    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

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635
    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.

  7. #7
    Join Date
    Jun 2004
    Posts
    22
    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.

  8. #8
    Join Date
    Jun 2004
    Posts
    1,352
    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();
    }

  9. #9
    Join Date
    Jun 2004
    Posts
    22
    ya, I think SDI with Multi-View is good, thanks for the help.

  10. #10
    Join Date
    Jun 2004
    Posts
    1,352
    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.

  11. #11
    Join Date
    Jun 2004
    Posts
    22
    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.

  12. #12
    Join Date
    Jun 2004
    Posts
    22
    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.

  13. #13
    Join Date
    Jan 2004
    Location
    Punjab, India
    Posts
    113
    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)

  14. #14
    Join Date
    Jun 2004
    Posts
    22
    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.

  15. #15
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234
    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();
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured