VS2017 Heap Corruption

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
semFiz
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Jul 08, 2019 6:10 pm

VS2017 Heap Corruption

Post by semFiz »

When I use SetMenuBar in this IDE, this error is popping up with heap corruption.

Code: Select all

IMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
	Program *param = new Program(_T("Trainer for AssaultCube"));
	param->Show(true);
	return true;
}
Program::Program(const wxString & title)
	:wxFrame(NULL,wxID_ANY,title,wxDefaultPosition,wxSize(400,100))
{
	panel->SetBackgroundColour(*wxBLACK);
	bar = new wxMenuBar;
	menu = new wxMenu;
	menus = new wxMenu;
	menu->Append(134, "edit");
	menu->Append(136, "copy");
	menus->Append(135, "EdiT");
	bar->Append(menu, "FILE");
	bar->Append(menus, "Theme");
	SetMenuBar(bar);
	Connect(134, wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Program::button3));
	Connect(135, wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Program::button3));
	Connect(136, wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Program::button3));
	Centre();
	wxFont *font = new wxFont(15, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
	wxFont *font2 = new wxFont(13, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
	wxStaticText *text = new wxStaticText(panel, wxID_ANY, "  Trainer version 1.0", wxPoint(80,0), wxSize(200, 20));
	text->SetFont(*font);
	text->SetBackgroundColour(*wxBLUE);
	but = new wxButton(panel, 5, "WEAPON unlimited", wxPoint(10,30), wxSize(170, 30));
	but->SetBackgroundColour(*wxGREEN);
	but->SetForegroundColour(*wxRED);
	but->SetFont(*font2);
	but2 = new wxButton(panel, 6, "HEALTH UNliMited", wxPoint(190, 30), wxSize(170, 30));
	but2->SetBackgroundColour(*wxGREEN);
	but2->SetForegroundColour(*wxRED);
	but2->SetFont(*font2);
	Connect(5, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Program::Button1));
	Connect(6, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Program::Button2));
}
if I register the SetMenuBar then everything works fine =D>
Last edited by catalin on Mon Jul 08, 2019 7:07 pm, edited 1 time in total.
Reason: code tags
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: VS2017 Heap Corruption

Post by catalin »

Was there a question too, that I'm missing? Or you just felt like sharing an incomplete piece of code?
Post Reply