- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
ConfigDlg.cpp
资源名称:ebd_src.zip [点击查看]
上传用户:kelijie
上传日期:2007-01-01
资源大小:123k
文件大小:6k
源码类别:
图形图象
开发平台:
Visual C++
- // ConfigDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <io.h>
- #include <time.h>
- #include "Config.h"
- #include "ConfigDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CConfigDlg dialog
- CConfigDlg::CConfigDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CConfigDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CConfigDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CConfigDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CConfigDlg)
- DDX_Control(pDX, IDC_PLUGINLIST, m_PluginList);
- DDX_Control(pDX, IDC_EXISTLIST, m_ExistList);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CConfigDlg, CDialog)
- //{{AFX_MSG_MAP(CConfigDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_ADD, OnAdd)
- ON_BN_CLICKED(IDC_ROMOVE, OnRomove)
- ON_LBN_DBLCLK(IDC_EXISTLIST, OnDblclkExistlist)
- ON_LBN_DBLCLK(IDC_PLUGINLIST, OnDblclkPluginlist)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CConfigDlg message handlers
- BOOL CConfigDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- //Add existing module to list view
- struct _finddata_t dll_file;
- long hFile;
- if((hFile = _findfirst( "e*.dll", &dll_file )) != -1L)
- {
- if(m_ExistList.AddString(dll_file.name) != LB_ERRSPACE)
- {
- while( _findnext( hFile, &dll_file ) == 0 )
- {
- m_ExistList.AddString(dll_file.name);
- }
- _findclose( hFile );
- }
- }
- //Add plug-in module to list view
- CFile file;
- char f_name[20];
- int inum;
- if(file.Open("plugin.sys", CFile::modeRead))
- {
- file.Read(&inum, sizeof(int));
- for(int i = 0; i < inum; i++)
- {
- file.Read(&f_name, 20*sizeof(char));
- m_PluginList.AddString(f_name);
- }
- file.Close();
- }
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CConfigDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CConfigDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CConfigDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CConfigDlg::OnAdd()
- {
- // TODO: Add your control notification handler code here
- int lsel = m_ExistList.GetCurSel( );
- if(lsel != LB_ERR)
- {
- char f_name[20];
- m_ExistList.GetText(lsel, f_name);
- if(m_PluginList.FindString(0, f_name) == LB_ERR)
- {
- m_PluginList.AddString(f_name);
- }
- }
- }
- void CConfigDlg::OnRomove()
- {
- // TODO: Add your control notification handler code here
- int lsel = m_PluginList.GetCurSel();
- if(lsel != LB_ERR)
- {
- m_PluginList.DeleteString(lsel);
- }
- }
- void CConfigDlg::OnOK()
- {
- // TODO: Add extra validation here
- int count = m_PluginList.GetCount();
- if(count != LB_ERR)
- {
- CFile file;
- char f_name[20];
- if(file.Open("plugin.sys", CFile::modeCreate|CFile::modeWrite))
- {
- file.Write(&count, sizeof(int));
- for(int i = 0; i < count; i++)
- {
- m_PluginList.GetText(i, f_name);
- file.Write(&f_name, 20*sizeof(char));
- }
- file.Close();
- }
- }
- CDialog::OnOK();
- }
- void CConfigDlg::OnDblclkExistlist()
- {
- // TODO: Add your control notification handler code here
- OnAdd();
- }
- void CConfigDlg::OnDblclkPluginlist()
- {
- // TODO: Add your control notification handler code here
- OnRomove();
- }