wxFileDialog was not declared in this scope error Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

wxFileDialog was not declared in this scope error

Post by Hossein » Tue Feb 10, 2009 6:21 pm

hello all, sth stranged happened to me , i wrote an event handler , it was working , now its not , and it kept giving me an stupid errors!

Code: Select all

void _2Frame::OpenFile(wxCommandEvent& WXUNUSED(event))
{
	wxFileDialog *OpenDialog = new wxFileDialog(this, _("Choose a file to open"), wxEmptyString, wxEmptyString,_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp, *.cxx)|*.cpp;*.cxx|C Source files (*.c)|*.c|C header files (*.h)|*.h"),	wxFD_OPEN, wxDefaultPosition);

	// Creates a "open file" dialog with 4 file types
	if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
	{
		CurrentDocPath = OpenDialog->GetPath();

		// Sets our current document to the file the user selected
		TextCtrl1->LoadFile(CurrentDocPath); //Opens that file
		// Set the Title to reflect the  file open
		 OpenDialog->GetFilename();
		 //SetTitle(wxString(("Edit - "))<<
	}
}
the irony is that i have two copies from the project! one of them compiles well! but another one doesnt! why! they are all the same , just the same!!
what is the cause?

error

Code: Select all

H:\SML\_2Main.cpp|408|error: `wxFileDialog' was not declared in this scope|
H:\SML\_2Main.cpp|408|error: `OpenDialog' was not declared in this scope|
H:\SML\_2Main.cpp|408|error: `wxFileDialog' is not a type|
H:\SML\_2Main.cpp|408|error: `wxFD_OPEN' was not declared in this scope|
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/

User avatar
Disch
Experienced Solver
Experienced Solver
Posts: 99
Joined: Wed Oct 17, 2007 2:01 am

Post by Disch » Tue Feb 10, 2009 6:56 pm

are you including <wx/filedlg.h> with all of your other #includes?

Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

Post by Hossein » Wed Feb 11, 2009 2:25 am

no! is it the cause?
because if it is , why the other instance of the project compiles!?that is the same as this one that gives error!
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Wed Feb 11, 2009 2:47 am

Whenever you use a class, import its header. It's possible in some cases you don't need to because another header you included included it, so it was included indirectly and implicitely. It's best to not rely on that and include everything you need explicitely (except for some base classes e.g. wxString which are included by wx/wx.h on all platforms)

Post Reply