]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/db/dbtest.cpp
Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
[wxWidgets.git] / samples / db / dbtest.cpp
index 466dfaf42822c0913c45052fd300b6af5e0a41b2..b5d0cbc3d236296876adac9f06a6f36cac6bb52a 100644 (file)
@@ -264,7 +264,7 @@ void DatabaseDemoFrame::OnCloseWindow(wxCloseEvent& event)
        // to close the program here that is not done elsewhere
 
     this->Destroy();
-}  // DatabaseDemoFrame::OnClose()
+}  // DatabaseDemoFrame::OnCloseWindow()
 
 
 void DatabaseDemoFrame::CreateDataTable()
@@ -619,7 +619,8 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
        // The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s" 
        // to achieve a single row (in this case the first name in alphabetical order).
        
-       Contact->whereStr.Printf("NAME = (SELECT MIN(NAME) FROM %s)",Contact->tableName);
+       // commented out because PostgreSQL can't do this
+       //Contact->whereStr.Printf("NAME = (SELECT MIN(NAME) FROM %s)",Contact->tableName);
        
        // NOTE: (const char*) returns a pointer which may not be valid later, so this is short term use only
        Contact->where = (char*) (const char*) Contact->whereStr;
@@ -651,21 +652,21 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
 }  // CeditorDlg constructor
 
 
-bool CeditorDlg::OnClose()
+void CeditorDlg::OnCloseWindow(wxCloseEvent& event)
 {
        // Clean up time
        if ((mode != mCreate) && (mode != mEdit))
        {
                if (Contact)
                        delete Contact;
-               return TRUE;
+               this->Destroy();
        }
        else
        {
                wxMessageBox("Must finish processing the current record being created/modified before exiting","Notice...",wxOK | wxICON_INFORMATION);
-               return FALSE;
+               event.Veto();
        }
-}  // CeditorDlg::OnClose()
+}  // CeditorDlg::OnCloseWindow()
 
 
 void CeditorDlg::OnButton( wxCommandEvent &event )
@@ -779,10 +780,13 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
                        }
                }
 
+           // commented out because PostgreSQL can't do this
+               
                // Previous record not available, retrieve first record in table
-               Contact->whereStr  = "NAME = (SELECT MIN(NAME) FROM ";
-               Contact->whereStr += Contact->tableName;
-               Contact->whereStr += ")";
+               //Contact->whereStr  = "NAME = (SELECT MIN(NAME) FROM ";
+               //Contact->whereStr += Contact->tableName;
+               //Contact->whereStr += ")";
+               
                Contact->where = (char*) (const char*) Contact->whereStr;
                if (!Contact->Query())
                {
@@ -832,9 +836,12 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
                // display it, if the query string has changed.
                if (strcmp(qryWhere, (const char*) Contact->qryWhereStr))
                {
-                       Contact->orderBy                = "NAME";
-                       Contact->whereStr               = "NAME = (SELECT MIN(NAME) FROM ";
-                       Contact->whereStr               += CONTACT_TABLE_NAME;
+                  // commented out because PostgreSQL can't do this
+                      Contact->whereStr = "";
+                       //Contact->orderBy              = "NAME";
+                       //Contact->whereStr             = "NAME = (SELECT MIN(NAME) FROM ";
+                       //Contact->whereStr             += CONTACT_TABLE_NAME;
                        
                        // Append the query where string (if there is one)
                        Contact->qryWhereStr    = qryWhere;
@@ -844,7 +851,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
                                Contact->whereStr               += Contact->qryWhereStr;
                        }
                        // Close the expression with a right paren
-                       Contact->whereStr += ")";
+                       // Contact->whereStr += ")";
                        // Requery the table
                        Contact->where = (char*) (const char*) Contact->whereStr;
                        if (!Contact->Query())
@@ -876,9 +883,10 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
                // Query the first record in the table
                Contact->orderBy                = "NAME";
 
-               Contact->whereStr               = "NAME = (SELECT MIN(NAME) FROM ";
-               Contact->whereStr               += CONTACT_TABLE_NAME;
-               Contact->whereStr               += ")";
+               // commented out because PostgreSQL can't do this
+               //Contact->whereStr             = "NAME = (SELECT MIN(NAME) FROM ";
+               //Contact->whereStr             += CONTACT_TABLE_NAME;
+               //Contact->whereStr             += ")";
 
                Contact->where                  = (char*) (const char*) Contact->whereStr;
                if (!Contact->Query())
@@ -1199,10 +1207,11 @@ bool CeditorDlg::GetNextRec()
 {
        wxString w;
 
-
-       w  = "NAME = (SELECT MIN(NAME) FROM ";
-       w += Contact->tableName;
-       w += " WHERE NAME > '";
+       // commented out because PostgreSQL can't do this
+       //w  = "NAME = (SELECT MIN(NAME) FROM ";
+       //w += Contact->tableName;
+       // w += " WHERE NAME > '";
+       w = "(NAME > '";
        w += Contact->Name;
        w += "'";
 
@@ -1229,9 +1238,11 @@ bool CeditorDlg::GetPrevRec()
 {
        wxString w;
 
-       w  = "NAME = (SELECT MAX(NAME) FROM ";
-       w +=    Contact->tableName;
-       w += " WHERE NAME < '";
+       // commented out because PostgreSQL can't do this
+       //w  = "NAME = (SELECT MAX(NAME) FROM ";
+       //w +=  Contact->tableName;
+       //w += " WHERE NAME < '";
+       w = "(NAME < '";
        w += Contact->Name;
        w += "'";
 
@@ -1283,6 +1294,11 @@ bool CeditorDlg::GetRec(char *whereStr)
 /*
  * CparameterDlg constructor
  */
+
+BEGIN_EVENT_TABLE(CparameterDlg, wxDialog)
+    EVT_CLOSE(CparameterDlg::OnCloseWindow)
+END_EVENT_TABLE()
+
 CparameterDlg::CparameterDlg(wxWindow *parent) : wxDialog (parent, PARAMETER_DIALOG, "ODBC parameter settings", wxPoint(-1, -1), wxSize(400, 275))
 {
        // Since the ::OnCommand() function is overridden, this prevents the widget
@@ -1315,7 +1331,7 @@ CparameterDlg::CparameterDlg(wxWindow *parent) : wxDialog (parent, PARAMETER_DIA
 }  // CparameterDlg constructor
 
 
-bool CparameterDlg::OnClose()
+void CparameterDlg::OnCloseWindow(wxCloseEvent& event)
 {
        // Put any additional checking necessary to make certain it is alright
        // to close the program here that is not done elsewhere
@@ -1324,15 +1340,19 @@ bool CparameterDlg::OnClose()
                bool Ok = (wxMessageBox("No changes have been saved.\n\nAre you sure you wish exit the parameter screen?","Confirm",wxYES_NO|wxICON_QUESTION) == wxYES);
 
                if (!Ok)
-                       return FALSE;
+        {
+            event.Veto();
+                       return;
+        }
 
                wxGetApp().params = savedParamSettings;
        }
 
        if (GetParent() != NULL)
                GetParent()->SetFocus();
-       return TRUE;
-}  // Cparameter::OnClose()
+       this->Destroy();
+
+}  // Cparameter::OnCloseWindow()
 
 
 void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
@@ -1471,6 +1491,7 @@ void CparameterDlg::FillDataSourceList()
 
 BEGIN_EVENT_TABLE(CqueryDlg, wxDialog)
     EVT_BUTTON(-1,  CqueryDlg::OnButton)
+    EVT_CLOSE(CqueryDlg::OnCloseWindow)
 END_EVENT_TABLE()
  
 // CqueryDlg() constructor
@@ -1800,7 +1821,7 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
 }  // CqueryDlg::OnCommand
 
 
-bool CqueryDlg::OnClose()
+void CqueryDlg::OnCloseWindow(wxCloseEvent& event)
 {
        // Clean up
        if (colInf)
@@ -1817,9 +1838,10 @@ bool CqueryDlg::OnClose()
 
        GetParent()->SetFocus();
        wxEndBusyCursor();
-       return TRUE;
 
-}  // CqueryDlg::OnClose()
+       this->Destroy();
+
+}  // CqueryDlg::OnCloseWindow()
 
 /*
 bool CqueryDlg::SetWidgetPtrs()