calling new form
-
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.
-
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.
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_»
-
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_»
-
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.
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...
-
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...
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 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.. :(
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...
-
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...
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 } _____________________________________________________________________
-
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 } _____________________________________________________________________
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...