OSDN Git Service

2005-05-09 Perry
authorPerry Rapp <elsapo@users.sourceforge.net>
Mon, 9 May 2005 00:00:33 +0000 (00:00 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Mon, 9 May 2005 00:00:33 +0000 (00:00 +0000)
 PATCH: [ 1197727 ] New method ResMsgBox1 to simplify cookie-cutter code
 Src: MainFrm.cpp PatchDlg.cpp StdAfx.cpp StdAfx.h

Src/MainFrm.cpp
Src/PatchDlg.cpp
Src/StdAfx.cpp
Src/StdAfx.h
Src/readme.txt

index 9cf3ab9..fb76c9f 100644 (file)
@@ -2382,9 +2382,7 @@ BOOL CMainFrame::OpenFileToExternalEditor(CString file)
        {
                // Don't know how to invoke external editor (it doesn't end with
                // an obvious executable extension)
-               CString msg;
-               AfxFormatString1(msg, IDS_CANNOT_EXECUTE_FILE, sExtEditor);
-               AfxMessageBox(msg, MB_ICONSTOP);
+               ResMsgBox1(IDS_CANNOT_EXECUTE_FILE, sExtEditor, MB_ICONSTOP);
        }
        return TRUE;
 }
index 0056514..19e7b5f 100644 (file)
@@ -140,9 +140,7 @@ void CPatchDlg::OnOK()
                pathAbsolute = paths_IsPathAbsolute(m_fileResult);
                if (pathAbsolute == FALSE)
                {
-                       CString msg;
-                       AfxFormatString1(msg, IDS_PATH_NOT_ABSOLUTE, m_fileResult);
-                       AfxMessageBox(msg, MB_ICONSTOP);
+                       ResMsgBox1(IDS_PATH_NOT_ABSOLUTE, m_fileResult, MB_ICONSTOP);
                }
        }
        
index e2b615d..3141bef 100644 (file)
@@ -88,6 +88,16 @@ CString LoadResString(int id)
        return s;
 }
 
+// Combines AfxFormatString1 with AfxMessageBox
+int
+ResMsgBox1(int msgid, LPCTSTR arg, UINT nType, UINT nIDHelp)
+{
+       CString msg;
+       AfxFormatString1(msg, msgid, arg);
+       if (!nIDHelp) nIDHelp = msgid;
+       return AfxMessageBox(msg, nType, nIDHelp);
+}
+
 // Get user language description of error, if available
 CString GetSysError(int nerr)
 {
index c554d9a..6e15b32 100644 (file)
@@ -55,6 +55,9 @@ int xisspace (int c);
        /** @brief Load string from string resources; shortcut for CString::LoadString */
 CString LoadResString(int id);
 
+       /** @brief Format single-argument resource string and display via AfxMessageBox */
+int ResMsgBox1(int msgid, LPCTSTR arg, UINT nType = MB_OK, UINT nIDHelp = 0);
+
        /** @brief Retrieve error description from Windows; uses FormatMessage */
 CString GetSysError(int nerr);
 
index f5d0d52..569960e 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-09 Perry
+ PATCH: [ 1197727 ] New method ResMsgBox1 to simplify cookie-cutter code
+ Src: MainFrm.cpp PatchDlg.cpp StdAfx.cpp StdAfx.h
+
 2005-05-08 Kimmo
  PATCH: [ 1196889 ] Move options initializations to own file
   Src: MainFrm.cpp Merge.dsp