【发布时间】:2021-08-05 14:12:19
【问题描述】:
我已经创建了这个登录表单。它的工作原理是这样的:cMain 是您放置登录凭据的主要登录类,user_reg 是用户创建类。我想从 cMain 框架到 user_reg 框架并返回。到目前为止,我只是通过不关闭 cMain 框架来解决这个问题,但对我来说这不是解决方案。有什么办法可以让我去 cMain -> user_reg -> cMain 吗? 这是我尝试过的
//cMain.h
#pragma once
#include "wx/wx.h"
#include "wx/msgdlg.h"
#include "wx/font.h"
#include "user_reg.h"
#include "account.h"
#include "gui.h"
#include <fstream>
class cMain : public wxFrame
{
public:
cMain();
~cMain();
private:
gui* m_frame2 = nullptr;
user_reg* m_frame3 = nullptr; //Works fine
public:
//Ignore this
wxButton* m_btn1 = nullptr;
wxStaticText* m_text1 = nullptr;
wxStaticText* m_text2 = nullptr;
wxButton* m_btn2 = nullptr;
wxTextCtrl* m_txt1 = nullptr;
wxTextCtrl* m_txt2 = nullptr;
wxListBox* m_list1 = nullptr;
wxMessageDialog* m_msg1 = nullptr;
void OnLogin(wxCommandEvent& evt);
void OnRegister(wxCommandEvent& evt);
wxDECLARE_EVENT_TABLE();
};
//user_reg.h
#pragma once
#include <string>
#include "wx/wx.h"
#include "wx/msgdlg.h"
#include "account.h"
#include "encrypt.h"
#include "cMain.h"
class user_reg : public wxFrame
{
public:
user_reg();
~user_reg();
private:
cMain* m_frame1 = nullptr; //Does not work, error here
public:
//Ignore this
wxTextCtrl* m_txt1 = nullptr;
wxTextCtrl* m_txt2 = nullptr;
wxTextCtrl* m_txt3 = nullptr;
wxButton* m_btn1 = nullptr;
wxMessageDialog* m_msg1 = nullptr;
void onRegister(wxCommandEvent& evt);
wxDECLARE_EVENT_TABLE();
};
//cMain.cpp
...
m_frame3 = new user_reg(); //Works fine
m_frame3->Show(); //Works fine
Close(); //This should not be here, this represents the ideal use case
evt.Skip();
...
//user_reg.cpp
...
m_frame1 = new cMain(); //Does not work
m_frame1->Show(); //Does not work
Close();
evt.Skip();
...
非常感谢任何帮助或文档,在此先感谢。
【问题讨论】: