ExportDlg.cpp
资源名称:ISQL_src.zip [点击查看]
上传用户:jsxglz
上传日期:2007-01-03
资源大小:117k
文件大小:3k
源码类别:
SQL Server
开发平台:
Visual C++
- // ExportDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "interactivesql.h"
- #include "ExportDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- const char* g_szExportOptions = "ExportOptions";
- const char* g_szFormat = "Format";
- const char* g_szCoumnNames = "ColumnNames";
- /////////////////////////////////////////////////////////////////////////////
- // CExportDlg
- IMPLEMENT_DYNAMIC(CExportDlg, CFileDialog)
- CExportDlg::CExportDlg(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
- CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
- {
- m_ofn.Flags |= OFN_ENABLETEMPLATE;
- m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORT_DIALOG);
- m_bColumnNames = TRUE;
- m_strDelimiter = "Comma Seperated";
- m_bSaveSelection = false;
- }
- BEGIN_MESSAGE_MAP(CExportDlg, CFileDialog)
- //{{AFX_MSG_MAP(CExportDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- BOOL CExportDlg::OnInitDialog()
- {
- BOOL bRet = CFileDialog::OnInitDialog();
- if(bRet)
- {
- CComboBox* pCB = (CComboBox*)GetDlgItem(IDC_DELIMITER);
- pCB->AddString("Comma Seperated");
- pCB->AddString("Tab Delimited");
- pCB->AddString("Pipe Seperated");
- pCB->AddString("<None>");
- CWinApp* pApp = AfxGetApp();
- m_strDelimiter = pApp->GetProfileString(g_szExportOptions, g_szFormat);
- m_strDelimiter.TrimRight();
- m_strDelimiter.TrimLeft();
- if(m_strDelimiter.IsEmpty())
- m_strDelimiter = "Comma Seperated";
- pCB->SelectString(-1, m_strDelimiter);
- CButton* pB = (CButton*)GetDlgItem(IDC_COLUMNS);
- pB->SetCheck(pApp->GetProfileInt(g_szExportOptions, g_szCoumnNames, 1));
- pB->EnableWindow(m_bSaveSelection ? FALSE : TRUE);
- }
- return bRet; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- BOOL CExportDlg::OnFileNameOK()
- {
- BOOL bRet = CFileDialog::OnFileNameOK();
- if(!bRet)
- {
- CString sBuff;
- GetDlgItem(IDC_DELIMITER)->GetWindowText(sBuff);
- if(sBuff.Find("Comma") != -1)
- m_strDelimiter = _T(",");
- if(sBuff.Find("Tab") != -1)
- m_strDelimiter = _T("t");
- if(sBuff.Find("Pipe") != -1)
- m_strDelimiter = _T("|");
- if(sBuff.Find("<None>") != -1)
- m_strDelimiter = _T("");
- CWinApp* pApp = AfxGetApp();
- pApp->WriteProfileString(g_szExportOptions, g_szFormat, sBuff);
- CButton* pB = (CButton*)GetDlgItem(IDC_COLUMNS);
- m_bColumnNames = pB->GetCheck();
- pApp->WriteProfileInt(g_szExportOptions, g_szCoumnNames, m_bColumnNames);
- }
- return bRet;
- }