Fixed the GUI so it will now work correctly when widgets are clicked/used. This demo program was not really even usable, although the database portions worked correctly.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3864 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
George Tasker
1999-10-07 11:04:06 +00:00
parent d604ea3355
commit 65d7ddc4eb
5 changed files with 208 additions and 61 deletions

View File

@@ -56,6 +56,8 @@
#include <wx/dbtable.h>
extern DbList* WXDLLEXPORT PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */
#include "listdb.h"
// Global structure for holding ODBC connection information
@@ -78,8 +80,65 @@ char ListDB_Selection2[LOOKUP_COL_LEN+1];
const int LISTDB_NO_SPACES_BETWEEN_COLS = 3;
/*
* This function will return the exact string(s) from the database engine
* indicating all error conditions which have just occured during the
* last call to the database engine.
*
* This demo uses the returned string by displaying it in a wxMessageBox. The
* formatting therefore is not the greatest, but this is just a demo, not a
* finished product. :-) gt
*
* NOTE: The value returned by this function is for temporary use only and
* should be copied for long term use
*/
char *GetExtendedDBErrorMsg2(char *ErrFile, int ErrLine)
{
static wxString msg;
wxString tStr;
if (ErrFile || ErrLine)
{
msg += "File: ";
msg += ErrFile;
msg += " Line: ";
tStr.Printf("%d",ErrLine);
msg += tStr.GetData();
msg += "\n";
}
msg.Append ("\nODBC errors:\n");
msg += "\n";
/* Scan through each database connection displaying
* any ODBC errors that have occured. */
for (DbList *pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext)
{
// Skip over any free connections
if (pDbList->Free)
continue;
// Display errors for this connection
for (int i = 0; i < DB_MAX_ERROR_HISTORY; i++)
{
if (pDbList->PtrDb->errorList[i])
{
msg.Append(pDbList->PtrDb->errorList[i]);
if (strcmp(pDbList->PtrDb->errorList[i],"") != 0)
msg.Append("\n");
}
}
}
msg += "\n";
return (char*) (const char*) msg;
} // GetExtendedDBErrorMsg
// Clookup constructor
Clookup::Clookup(char *tblName, char *colName) : wxTable(READONLY_DB, tblName, 1)
Clookup::Clookup(char *tblName, char *colName) : wxTable(READONLY_DB, tblName, 1, NULL, !QUERY_ONLY, DbConnectInf.defaultDir)
{
SetColDefs (0, colName, DB_DATA_TYPE_VARCHAR, lookupCol, SQL_C_CHAR, LOOKUP_COL_LEN+1, FALSE, FALSE);
@@ -89,7 +148,7 @@ Clookup::Clookup(char *tblName, char *colName) : wxTable(READONLY_DB, tblName, 1
// Clookup2 constructor
Clookup2::Clookup2(char *tblName, char *colName1, char *colName2, wxDB *pDb)
: wxTable(pDb, tblName, (1 + (strlen(colName2) > 0)))
: wxTable(pDb, tblName, (1 + (strlen(colName2) > 0)), NULL, !QUERY_ONLY, DbConnectInf.defaultDir)
{
int i = 0;
@@ -101,6 +160,13 @@ Clookup2::Clookup2(char *tblName, char *colName1, char *colName2, wxDB *pDb)
} // Clookup2()
BEGIN_EVENT_TABLE(ClookUpDlg, wxDialog)
// EVT_LISTBOX(LOOKUP_DIALOG_SELECT, ClookUpDlg::SelectCallback)
EVT_BUTTON(LOOKUP_DIALOG_OK, ClookUpDlg::OnButton)
EVT_BUTTON(LOOKUP_DIALOG_CANCEL, ClookUpDlg::OnButton)
EVT_CLOSE(ClookUpDlg::OnClose)
END_EVENT_TABLE()
// This is a generic lookup constructor that will work with any table and any column
ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, char *colName,
char *where, char *orderBy) : wxDialog (parent, LOOKUP_DIALOG, "Select...", wxPoint(-1, -1), wxSize(400, 290))
@@ -234,6 +300,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
{
wxString tStr;
tStr.Printf("Unable to open the table '%s'.",tableName);
tStr += GetExtendedDBErrorMsg2(__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...");
Close();
return;
@@ -329,7 +396,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
} // Generic lookup constructor 2
bool ClookUpDlg::OnClose(void)
void ClookUpDlg::OnClose(wxCloseEvent& event)
{
widgetPtrsSet = FALSE;
GetParent()->Enable(TRUE);
@@ -340,11 +407,20 @@ bool ClookUpDlg::OnClose(void)
delete lookup2;
wxEndBusyCursor();
return TRUE;
event.Skip();
// return TRUE;
} // ClookUpDlg::OnClose
void ClookUpDlg::OnButton( wxCommandEvent &event )
{
wxWindow *win = (wxWindow*) event.GetEventObject();
OnCommand( *win, event );
}
void ClookUpDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString widgetName = win.GetName();