Main frame collecting Dialog info?
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Code: Select all
class ContactManagerFrm:public wxFrame
{
...
private:
wxListCtrl *ContactList;
...
}
Code: Select all
void ContactManagerFrm::CreateGUIControls()
{
...
ContactList = new wxListCtrl(ContactListPanel, ID_CONTACTLISTCTRL, wxDefaultPosition, wxSize(200,400), wxLC_LIST | wxLC_SINGLE_SEL);
...
}
Code: Select all
void ContactManagerFrm::dialogClosed()
{
ContactList.DeleteAllItems();
}
FlyingIsFun1217
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Ok, got the
working as I just posted, but now I have:
within the dialog. Guess I'm just getting lost here in my mess of code
Thanks again
FlyingIsFun1217
Code: Select all
void ContactManagerFrm::dialogClosed()
{
ContactList->DeleteAllItems();
}
onerror: expected primary-expression before '->' token.
Code: Select all
ContactManagerFrm->dialogClosed();
Thanks again
FlyingIsFun1217
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Code: Select all
//---------------------------------------------------------------------------
//
// Name: NewContact.cpp
// Author: Tanner Ruschman
// Created: 2/7/2007 8:22:38 PM
// Description: NewContact class implementation
//
//---------------------------------------------------------------------------
#include "ContactManagerFrm.h"
#include "NewContact.h"
////Event Table Start
BEGIN_EVENT_TABLE(NewContact,wxDialog)
EVT_CLOSE(NewContact::OnClose)
EVT_BUTTON(ID_CONTACTCANCELBUTTON, NewContact::CancelButtonClick)
EVT_BUTTON(ID_CONTACTADDBUTTON, NewContact::AddButtonClick)
END_EVENT_TABLE()
////Event Table End
NewContact::NewContact(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
CreateGUIControls();
}
NewContact::~NewContact()
{
}
void NewContact::CreateGUIControls()
{
// GUI Creation Start
wxPanel *BaseNewContactPanel = new wxPanel(this, ID_WXPANEL, wxPoint(0,0), wxDefaultSize);
wxStaticBox *ContactDetailsBox = new wxStaticBox(this, wxID_ANY, wxT("Contact's Details"), wxPoint(10,10), wxSize(375,273));
wxButton *ContactCancelButton = new wxButton(this, ID_CONTACTCANCELBUTTON, wxT("Cancel"), wxPoint(324, 290), wxSize(60,25));
wxButton *ContactAddButton = new wxButton(this, ID_CONTACTADDBUTTON, wxT("Save"), wxPoint(260,290), wxSize(60,25));
wxStaticText *ContactNameLabel = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Name:"), wxPoint(10,20), wxDefaultSize, 0, wxT("ContactName"));
ContactNameLabel->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactNameEntry = new wxTextCtrl(ContactDetailsBox, ID_CONTACTNAMEENTRY, wxT(""), wxPoint(185,20), wxSize(170,20), 0, wxDefaultValidator, wxT("ContactDetailsBox"));
wxStaticLine *NewContactSeparator = new wxStaticLine(ContactDetailsBox, wxID_ANY, wxPoint(20,48), wxSize(335,2), wxLI_HORIZONTAL);
/*-----------------------EMAIL INFO-----------------------*/
wxStaticText *ContactEmailLabel1 = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Email (1):"), wxPoint(10,57), wxDefaultSize, 0, wxT("ContactEmailLabel1"));
ContactEmailLabel1->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactEmailEntry1 = new wxTextCtrl(ContactDetailsBox, ID_CONTACTEMAILENTRY1, wxT(""), wxPoint(185,57), wxSize(170,20));
wxStaticText *ContactEmailLabel2 = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Email (2):"), wxPoint(10,82), wxDefaultSize, 0, wxT("ContactEmailLabel2"));
ContactEmailLabel2->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactEmailEntry2 = new wxTextCtrl(ContactDetailsBox, ID_CONTACTEMAILENTRY2, wxT(""), wxPoint(185,82), wxSize(170,20));
wxStaticLine *NewContactSeparator2 = new wxStaticLine(ContactDetailsBox, wxID_ANY, wxPoint(20,112), wxSize(335,2), wxLI_HORIZONTAL);
/*----------------------PHONE INFO------------------------*/
wxStaticText *ContactPhoneNumber = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Phone #:"), wxPoint(10,122), wxDefaultSize, 0, wxT("ContactPhoneNumber"));
ContactPhoneNumber->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactPhoneEntry = new wxTextCtrl(ContactDetailsBox, ID_CONTACTPHONEENTRY, wxT(""), wxPoint(185,122), wxSize(170,20));
wxStaticText *ContactCellNumber = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Cell #"), wxPoint(10,147), wxDefaultSize, 0, wxT("ContactCellNumber"));
ContactCellNumber->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactCellEntry = new wxTextCtrl(ContactDetailsBox, ID_CONTACTCELLENTRY, wxT(""), wxPoint(185,147), wxSize(170,20));
wxStaticLine *NewContactSeparator3 = new wxStaticLine(ContactDetailsBox, wxID_ANY, wxPoint(20,177), wxSize(335,2), wxLI_HORIZONTAL);
/*----------------------ADDRESS INFO----------------------*/
wxStaticText *ContactAddress = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Address:"), wxPoint(10,187), wxDefaultSize, 0, wxT("ContactAddress"));
ContactAddress->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactAddressEntry = new wxTextCtrl(ContactDetailsBox, ID_CONTACTADDRESSENTRY, wxT(""), wxPoint(185,187), wxSize(170,20));
wxStaticText *ContactTown = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's Town:"), wxPoint(10,212), wxDefaultSize, 0, wxT("ContactTown"));
ContactTown->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactTownEntry = new wxTextCtrl(ContactDetailsBox, ID_CONTACTTOWNENTRY, wxT(""), wxPoint(185,212), wxSize(170,20));
wxStaticText *ContactState = new wxStaticText(ContactDetailsBox, wxID_ANY, wxT("Contact's State/Providence:"), wxPoint(10,237), wxDefaultSize, 0, wxT("ContactState"));
ContactState->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE, wxT("Times New Roman")));
ContactStateEntry = new wxTextCtrl(ContactDetailsBox, ID_CONTACTSTATEENTRY, wxT(""), wxPoint(185,237), wxSize(170,20));
SetTitle(wxT("Add a Contact"));
SetIcon(wxNullIcon);
SetSize(8,8,400,355);
Center();
// GUI Creation End
}
void NewContact::OnClose(wxCloseEvent& event)
{
Destroy();
}
void NewContact::AddButtonClick(wxCommandEvent& event)
{
wxString ContactNameString = ContactNameEntry->GetValue();
wxString ContactEmail1String = ContactEmailEntry1->GetValue();
wxString ContactEmail2String = ContactEmailEntry2->GetValue();
wxString ContactPhoneString = ContactPhoneEntry->GetValue();
wxString ContactCellString = ContactCellEntry->GetValue();
wxString ContactAddressString = ContactAddressEntry->GetValue();
wxString ContactTownString = ContactTownEntry->GetValue();
wxString ContactStateString = ContactStateEntry->GetValue();
wxSQLite3Database cmdb;
cmdb.Open(wxT("CMDB.cmdb"));
if(!cmdb.TableExists("Contacts"))
{
cmdb.ExecuteUpdate("CREATE TABLE Contacts"
"(NAME varchar(10), EMAIL1 varchar(10), EMAIL2 varchar(10), PHONE varchar(10), CELL varchar(10), ADDRESS varchar(10), TOWN varchar(10), STATE varchar(10));");
}
wxSQLite3Statement addcontact = cmdb.PrepareStatement("INSERT INTO Contacts("
"NAME, EMAIL1, EMAIL2, PHONE, CELL, ADDRESS, TOWN, STATE) values (:1, :2, :3, :4, :5, :6, :7, :8)");
addcontact.Bind(1, ContactNameString);
addcontact.Bind(2, ContactEmail1String);
addcontact.Bind(3, ContactEmail2String);
addcontact.Bind(4, ContactPhoneString);
addcontact.Bind(5, ContactCellString);
addcontact.Bind(6, ContactAddressString);
addcontact.Bind(7, ContactTownString);
addcontact.Bind(8, ContactStateString);
addcontact.ExecuteUpdate();
cmdb.Close();
ContactManagerFrm->dialogClosed();
Destroy();
}
void NewContact::CancelButtonClick(wxCommandEvent& event)
{
Destroy();
}
I think its expecting... Well, not quite sure how to word it, I'll see if you say what I'm thinking
Thanks again! You deserve more wxAwards than I can give out
FlyingIsFun1217
ContactManagerFrm is a class name, you can't call methods on a class name. You will need a pointer to an ContactManagerFrm instance.
Now remember that because all your errors are about that!
You cannot call methods on a pointer name stored in a string.
You cannot call a method an an ID.
You cannot call a [non-static] method on a class name.
You can only (and only) call a method on an instance with . or on a pointer to an instance using ->
Hope it clarifies things a bit.
And please look again at the sample i provided you at the first page before asking 'how do i get a pointer to ContactManagerFrm?'
Now remember that because all your errors are about that!
You cannot call methods on a pointer name stored in a string.
You cannot call a method an an ID.
You cannot call a [non-static] method on a class name.
You can only (and only) call a method on an instance with . or on a pointer to an instance using ->
Hope it clarifies things a bit.
And please look again at the sample i provided you at the first page before asking 'how do i get a pointer to ContactManagerFrm?'
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Ok, I finished it per your example, but all I get is a program crash when trying to add a contact!
It may be that it's been a while since I've looked at it, but I just can't seem to figure out why it crashes. It might be helpful in noting that even if I'm not just updating the listctrl, it always crashes.
Here are the files if anybody could look at them.
Thanks!
FlyingIsFun1217
It may be that it's been a while since I've looked at it, but I just can't seem to figure out why it crashes. It might be helpful in noting that even if I'm not just updating the listctrl, it always crashes.
Here are the files if anybody could look at them.
Thanks!
FlyingIsFun1217
- Attachments
-
- Contacts Manager.zip
- All sources
- (86.48 KiB) Downloaded 65 times
If you use a debugger, where does it crash?
And perhaps you could give at least an hint of what parts of these several files are concerned by this issue... help others help you, dropping a big bunch of code and saying 'please debug this' is not a good way to get answers
FYI - you call a method on 'MainProgramFrame' but you never seem to give a value to it... check my sample again and learn C++... using a pointer without giving a value to it first is plain stupid error, you didn't do the tests i asked you to do... damn, help yourself!
And perhaps you could give at least an hint of what parts of these several files are concerned by this issue... help others help you, dropping a big bunch of code and saying 'please debug this' is not a good way to get answers
FYI - you call a method on 'MainProgramFrame' but you never seem to give a value to it... check my sample again and learn C++... using a pointer without giving a value to it first is plain stupid error, you didn't do the tests i asked you to do... damn, help yourself!