Author: wyoung
Date: Wed Mar 28 17:13:37 2007
New Revision: 1469

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1469&view=rev
Log:
Small polishings and simplifications in MFC example

Modified:
    trunk/examples/vstudio/mfc/mfc.cpp
    trunk/examples/vstudio/mfc/mfc.h
    trunk/examples/vstudio/mfc/mfc_dlg.cpp
    trunk/examples/vstudio/mfc/mfc_dlg.h

Modified: trunk/examples/vstudio/mfc/mfc.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/vstudio/mfc/mfc.cpp?rev=1469&r1=1468&r2=1469&view=diff
==============================================================================
--- trunk/examples/vstudio/mfc/mfc.cpp (original)
+++ trunk/examples/vstudio/mfc/mfc.cpp Wed Mar 28 17:13:37 2007
@@ -28,14 +28,6 @@
 #include "mfc.h"
 #include "mfc_dlg.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-BEGIN_MESSAGE_MAP(CApp, CWinApp)
-       ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
-END_MESSAGE_MAP()
-
 CApp gApplication;
 
 BOOL CApp::InitInstance()
@@ -48,15 +40,15 @@
 
        CWinApp::InitInstance();
 
-       // Initialize Winsock, which we need to use when connecting to MySQL
-       if (!AfxSocketInit()) {
+       // Initialize Winsock for MySQL communication, start GUI
+       if (AfxSocketInit()) {
+               CExampleDlg dlg;
+               m_pMainWnd = &dlg;
+               dlg.DoModal();
+       }
+       else {
                AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
-               return FALSE;
        }
 
-       // Run the application dialog
-       CExampleDlg dlg;
-       m_pMainWnd = &dlg;
-       dlg.DoModal();
        return FALSE;
 }

Modified: trunk/examples/vstudio/mfc/mfc.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/vstudio/mfc/mfc.h?rev=1469&r1=1468&r2=1469&view=diff
==============================================================================
--- trunk/examples/vstudio/mfc/mfc.h (original)
+++ trunk/examples/vstudio/mfc/mfc.h Wed Mar 28 17:13:37 2007
@@ -30,14 +30,9 @@
        #error "include 'stdafx.h' before including this file for PCH"
 #endif
 
-#include "resource.h"
-
 class CApp : public CWinApp
 {
 public:
        CApp() { }
        virtual BOOL InitInstance();
-       DECLARE_MESSAGE_MAP()
 };
-
-extern CApp gApplication;

Modified: trunk/examples/vstudio/mfc/mfc_dlg.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/vstudio/mfc/mfc_dlg.cpp?rev=1469&r1=1468&r2=1469&view=diff
==============================================================================
--- trunk/examples/vstudio/mfc/mfc_dlg.cpp (original)
+++ trunk/examples/vstudio/mfc/mfc_dlg.cpp Wed Mar 28 17:13:37 2007
@@ -25,21 +25,13 @@
 ***********************************************************************/
 
 #include "stdafx.h"
-#include "mfc.h"
+
 #include "mfc_dlg.h"
 #include "util.h"
 
 #include <mysql++.h>
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-#define NELEMS(s) (sizeof(s) / sizeof(s[0]))
-
 BEGIN_MESSAGE_MAP(CExampleDlg, CDialog)
-       ON_WM_QUERYDRAGICON()
-       //}}AFX_MSG_MAP
        ON_BN_CLICKED(IDC_CONNECT_BUTTON, 
&CExampleDlg::OnBnClickedConnectButton)
 END_MESSAGE_MAP()
 
@@ -47,17 +39,18 @@
 //// ctor //////////////////////////////////////////////////////////////
 
 CExampleDlg::CExampleDlg(CWnd* pParent) :
-CDialog(CExampleDlg::IDD, pParent)
+CDialog(CExampleDlg::IDD, pParent),
+hIcon_(AfxGetApp()->LoadIcon(IDR_MAINFRAME))
 {
        // Load default input values from registry, if we can
        HKEY key = OpenSettingsRegistryKey();
        if (key) {
                // There are pre-existing defaults we can use, so copy them in
-               TCHAR acBuffer[100];
-               LoadSetting(key, _T("user"), acBuffer, sizeof(acBuffer));
-               sUserName = acBuffer;
-               LoadSetting(key, _T("server"), acBuffer, sizeof(acBuffer));
-               sServerAddress = acBuffer;
+               TCHAR acSetting[100];
+               LoadSetting(key, _T("user"), acSetting, sizeof(acSetting));
+               sUserName = acSetting;
+               LoadSetting(key, _T("server"), acSetting, sizeof(acSetting));
+               sServerAddress = acSetting;
                RegCloseKey(key);
        }
        if ((sUserName.GetLength() == 0) || 
@@ -65,15 +58,12 @@
                // Didn't find anything we can use, so have to make something
                // plausible up instead.
                sServerAddress = _T("localhost");
-
                TCHAR acUserName[100];
                DWORD nBufferSize = sizeof(acUserName);
                if (GetUserName(acUserName, &nBufferSize)) {
                        sUserName = acUserName;
                }
        }
-
-       hIcon_ = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 }
 
 
@@ -108,7 +98,7 @@
 CExampleDlg::OnBnClickedConnectButton()
 {
        WCHAR awcTempBuf[100];
-       const int kTempBufSize = NELEMS(awcTempBuf);
+       const int kTempBufSize = sizeof(awcTempBuf) / sizeof(awcTempBuf[0]);
 
        // Pull user input into our member variables, then save that to the
        // registry for future use.
@@ -175,4 +165,3 @@
 
        return TRUE;
 }
-

Modified: trunk/examples/vstudio/mfc/mfc_dlg.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/vstudio/mfc/mfc_dlg.h?rev=1469&r1=1468&r2=1469&view=diff
==============================================================================
--- trunk/examples/vstudio/mfc/mfc_dlg.h (original)
+++ trunk/examples/vstudio/mfc/mfc_dlg.h Wed Mar 28 17:13:37 2007
@@ -25,6 +25,7 @@
 
 #pragma once
 #include "afxwin.h"
+#include "resource.h"
 
 class CExampleDlg : public CDialog
 {
@@ -44,16 +45,13 @@
 
 protected:
        //// Internal support functions
-       // DDX support
        virtual void DoDataExchange(CDataExchange* pDX);
+       virtual BOOL OnInitDialog();
+       void AddMessage(LPCTSTR pcMessage);
 
-       // Generated message map functions
-       virtual BOOL OnInitDialog();
+       //// Message map
        afx_msg void OnBnClickedConnectButton();
        DECLARE_MESSAGE_MAP()
-
-       // Misc
-       void AddMessage(LPCTSTR pcMessage);
 
 private:
        //// Internal data


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to