Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. calling new form

calling new form

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thilek
    wrote on last edited by
    #1

    hi guys, i am developing a simple worm scanner using VC++ 2008 pro. when the user click on scanning type ( Lets say Auto Scan ) from the main form, the program need to open the auto scan form. My question will be how can i close the main form and open the auto scan form. i added the button to be click but i dont know the command to close current form and open the autoscan form. i try to use system::windowsform::autoscan; but its showing system is not declared and i added using namespace System to the .h file. yet its showing systme does not exist in namespace. Kindly help me please.

    _ I 2 Replies Last reply
    0
    • T Thilek

      hi guys, i am developing a simple worm scanner using VC++ 2008 pro. when the user click on scanning type ( Lets say Auto Scan ) from the main form, the program need to open the auto scan form. My question will be how can i close the main form and open the auto scan form. i added the button to be click but i dont know the command to close current form and open the autoscan form. i try to use system::windowsform::autoscan; but its showing system is not declared and i added using namespace System to the .h file. yet its showing systme does not exist in namespace. Kindly help me please.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Closing the main form ends the process. So I would recommend hiding the main form and then showing the sub form. After the sub form is closed you can either show the main form or close it.

      «_Superman_»

      T 1 Reply Last reply
      0
      • _ _Superman_

        Closing the main form ends the process. So I would recommend hiding the main form and then showing the sub form. After the sub form is closed you can either show the main form or close it.

        «_Superman_»

        T Offline
        T Offline
        Thilek
        wrote on last edited by
        #3

        but how to call the sub form.. i having problem with calling the sub form. Thank you.

        1 Reply Last reply
        0
        • T Thilek

          hi guys, i am developing a simple worm scanner using VC++ 2008 pro. when the user click on scanning type ( Lets say Auto Scan ) from the main form, the program need to open the auto scan form. My question will be how can i close the main form and open the auto scan form. i added the button to be click but i dont know the command to close current form and open the autoscan form. i try to use system::windowsform::autoscan; but its showing system is not declared and i added using namespace System to the .h file. yet its showing systme does not exist in namespace. Kindly help me please.

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          Have look at the following discussion from a few days ago: http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2898321[^] The actual question took a little decoding, but hopefully the answers will help you a bit! They're based on MFC's CDialog, but hopefully the approach will help you. Iain.

          Codeproject MVP for C++, I can't believe it's for my lounge posts...

          T 1 Reply Last reply
          0
          • I Iain Clarke Warrior Programmer

            Have look at the following discussion from a few days ago: http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2898321[^] The actual question took a little decoding, but hopefully the answers will help you a bit! They're based on MFC's CDialog, but hopefully the approach will help you. Iain.

            Codeproject MVP for C++, I can't believe it's for my lounge posts...

            T Offline
            T Offline
            Thilek
            wrote on last edited by
            #5

            i am facing a new problem now... void Spartamenu::OnBnClickedCancel() { // TODO: Add your control notification handler code here //OnCancel(); } even after i disable the onCancel and run it. when i click on the button its still closing the application. ________________________________________________________________________ void Spartamenu::OnBnClickedButton1() { // TODO: Add your control notification handler code here CDialog::SetTimer(IDD_AUTO,1,NULL); } for open a subform i use this command but when i click on it nuthing happen... i am so confused.. kidly help me plz ya.. :(

            I 1 Reply Last reply
            0
            • T Thilek

              i am facing a new problem now... void Spartamenu::OnBnClickedCancel() { // TODO: Add your control notification handler code here //OnCancel(); } even after i disable the onCancel and run it. when i click on the button its still closing the application. ________________________________________________________________________ void Spartamenu::OnBnClickedButton1() { // TODO: Add your control notification handler code here CDialog::SetTimer(IDD_AUTO,1,NULL); } for open a subform i use this command but when i click on it nuthing happen... i am so confused.. kidly help me plz ya.. :(

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #6

              OnCancel and OnOK are slightly special - other commands need to be in the message map, but not for IDOK / IDCANCEL. If you look in the documentation for CDialog::OnCancel, you'll see that it is a virtual method. So, override OnCancel, and make it do nothing. ie:

              void SpartaMenu::OnCancel ()
              {
              }

              I do this for my modeless dialogs - in fact I have an overriden base class for them all (CModelessDialog) that does this, so I don't have to remember each time. Iain.

              Codeproject MVP for C++, I can't believe it's for my lounge posts...

              T 1 Reply Last reply
              0
              • I Iain Clarke Warrior Programmer

                OnCancel and OnOK are slightly special - other commands need to be in the message map, but not for IDOK / IDCANCEL. If you look in the documentation for CDialog::OnCancel, you'll see that it is a virtual method. So, override OnCancel, and make it do nothing. ie:

                void SpartaMenu::OnCancel ()
                {
                }

                I do this for my modeless dialogs - in fact I have an overriden base class for them all (CModelessDialog) that does this, so I don't have to remember each time. Iain.

                Codeproject MVP for C++, I can't believe it's for my lounge posts...

                T Offline
                T Offline
                Thilek
                wrote on last edited by
                #7

                ok.. so hows i should call the other form.. Below is the coding for the first form and second form.. i need to call the form 2 from this form when i click Button1. help me plz... ______________________________________________________________________ Form 1 // Spartamenu.cpp : implementation file // #include "stdafx.h" #include "Sparta.h" #include "Spartamenu.h" IMPLEMENT_DYNAMIC(Spartamenu, CDialog) Spartamenu::Spartamenu(CWnd* pParent /*=NULL*/) : CDialog(Spartamenu::IDD, pParent) { } Spartamenu::~Spartamenu() { } void Spartamenu::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(Spartamenu, CDialog) ON_BN_CLICKED(IDCANCEL, &Spartamenu::OnBnClickedCancel) ON_BN_CLICKED(IDC_BUTTON1, &Spartamenu::OnBnClickedButton1) END_MESSAGE_MAP() void Spartamenu::OnBnClickedCancel() { // TODO: Add your control notification handler code here OnCancel(); } void Spartamenu::OnBnClickedButton1() { // TODO: Add your control notification handler code here CDialog::SetTimer(IDD_AUTO,1,NULL); DestroyWindow(); } ____________________________________________________________________ Form2 // Auto.cpp : implementation file // #include "stdafx.h" #include "Sparta.h" #include "Auto.h" // Auto dialog IMPLEMENT_DYNAMIC(Auto, CDialog) Auto::Auto(CWnd* pParent /*=NULL*/) : CDialog(Auto::IDD, pParent) { } Auto::~Auto() { } void Auto::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(Auto, CDialog) ON_BN_CLICKED(IDCANCEL, &Auto::OnBnClickedCancel) ON_BN_CLICKED(IDOK, &Auto::OnBnClickedOk) ON_LBN_SELCHANGE(IDC_LIST1, &Auto::OnLbnSelchangeList1) END_MESSAGE_MAP() // Auto message handlers int Auto::DoModal() { } void Auto::OnBnClickedCancel() { // TODO: Add your control notification handler code here OnCancel(); } void Auto::OnBnClickedOk() { // TODO: Add your control notification handler code here OnOK(); } void Auto::OnLbnSelchangeList1() { // TODO: Add your control notification handler code here } _____________________________________________________________________

                I 1 Reply Last reply
                0
                • T Thilek

                  ok.. so hows i should call the other form.. Below is the coding for the first form and second form.. i need to call the form 2 from this form when i click Button1. help me plz... ______________________________________________________________________ Form 1 // Spartamenu.cpp : implementation file // #include "stdafx.h" #include "Sparta.h" #include "Spartamenu.h" IMPLEMENT_DYNAMIC(Spartamenu, CDialog) Spartamenu::Spartamenu(CWnd* pParent /*=NULL*/) : CDialog(Spartamenu::IDD, pParent) { } Spartamenu::~Spartamenu() { } void Spartamenu::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(Spartamenu, CDialog) ON_BN_CLICKED(IDCANCEL, &Spartamenu::OnBnClickedCancel) ON_BN_CLICKED(IDC_BUTTON1, &Spartamenu::OnBnClickedButton1) END_MESSAGE_MAP() void Spartamenu::OnBnClickedCancel() { // TODO: Add your control notification handler code here OnCancel(); } void Spartamenu::OnBnClickedButton1() { // TODO: Add your control notification handler code here CDialog::SetTimer(IDD_AUTO,1,NULL); DestroyWindow(); } ____________________________________________________________________ Form2 // Auto.cpp : implementation file // #include "stdafx.h" #include "Sparta.h" #include "Auto.h" // Auto dialog IMPLEMENT_DYNAMIC(Auto, CDialog) Auto::Auto(CWnd* pParent /*=NULL*/) : CDialog(Auto::IDD, pParent) { } Auto::~Auto() { } void Auto::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(Auto, CDialog) ON_BN_CLICKED(IDCANCEL, &Auto::OnBnClickedCancel) ON_BN_CLICKED(IDOK, &Auto::OnBnClickedOk) ON_LBN_SELCHANGE(IDC_LIST1, &Auto::OnLbnSelchangeList1) END_MESSAGE_MAP() // Auto message handlers int Auto::DoModal() { } void Auto::OnBnClickedCancel() { // TODO: Add your control notification handler code here OnCancel(); } void Auto::OnBnClickedOk() { // TODO: Add your control notification handler code here OnOK(); } void Auto::OnLbnSelchangeList1() { // TODO: Add your control notification handler code here } _____________________________________________________________________

                  I Offline
                  I Offline
                  Iain Clarke Warrior Programmer
                  wrote on last edited by
                  #8

                  Please read the other Q&A session I linked you to. I gave the answer to an identical question there. And it's too long to type again. Iain.

                  Codeproject MVP for C++, I can't believe it's for my lounge posts...

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups