?? pkgadmindlg.cpp
字號:
//####COPYRIGHTBEGIN####// // ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or (at your option) // any later version.// // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details.// // You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// ----------------------------------------------------------------------------// //####COPYRIGHTEND####// PkgAdminDlg.cpp : implementation file//#include "stdafx.h"#include "PkgAdmin.h"#include "PkgAdminDlg.h"#include "PkgAdminLicenseDlg.h"#include "PkgAdminTclWaitDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CPkgadminAboutDlg dialog used for App Aboutclass CPkgadminAboutDlg : public CDialog{public: CPkgadminAboutDlg();// Dialog Data //{{AFX_DATA(CPkgadminAboutDlg) enum { IDD = IDD_PKGADMIN_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CPkgadminAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL// Implementationprotected: //{{AFX_MSG(CPkgadminAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP()};CPkgadminAboutDlg::CPkgadminAboutDlg() : CDialog(CPkgadminAboutDlg::IDD){ //{{AFX_DATA_INIT(CPkgadminAboutDlg) //}}AFX_DATA_INIT}void CPkgadminAboutDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPkgadminAboutDlg) //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CPkgadminAboutDlg, CDialog) //{{AFX_MSG_MAP(CPkgadminAboutDlg) // No message handlers //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CPkgAdminDlg dialogCPkgAdminDlg::CPkgAdminDlg(LPCTSTR pszRepository,LPCTSTR pszUserTools) : CeCosDialog(CPkgAdminDlg::IDD, NULL){ //{{AFX_DATA_INIT(CPkgAdminDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 if(pszRepository){ m_strRepository=pszRepository; } if(pszUserTools){ m_strUserTools=pszUserTools; } m_CdlPkgData = NULL;}void CPkgAdminDlg::DoDataExchange(CDataExchange* pDX){ CeCosDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPkgAdminDlg) DDX_Control(pDX, IDC_PKGADMIN_REMOVE, m_btnRemove); DDX_Control(pDX, IDC_PKGADMIN_TREE, m_ctrlPackageTree); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CPkgAdminDlg, CeCosDialog) //{{AFX_MSG_MAP(CPkgAdminDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_PKGADMIN_REMOVE, OnPkgadminRemove) ON_WM_DESTROY() ON_BN_CLICKED(IDC_PKGADMIN_ADD, OnPkgadminAdd) ON_BN_CLICKED(IDCLOSE, OnClose) ON_BN_CLICKED(IDC_PKGADMIN_REPOSITORY, OnPkgadminRepository) ON_NOTIFY(TVN_SELCHANGED, IDC_PKGADMIN_TREE, OnSelchangedPkgadminTree) //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CPkgAdminDlg message handlersBOOL CPkgAdminDlg::OnInitDialog(){ CeCosDialog::OnInitDialog(); if(this==AfxGetApp()->m_pMainWnd){ // only if the dialog is the application // 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 // The following AppWizard-generated call was causing the 32x32 icon to // be resized for use as a 16x16 icon. Removing the call causes the // correct 16x16 icon to be displayed.// SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here // setup the repsoitory location if (m_strRepository.IsEmpty()) // if the repository cannot be located { OnPkgadminRepository (); // prompt the user for the repository location if (m_strRepository.IsEmpty ()) { PostMessage (WM_COMMAND,IDCANCEL); return TRUE; } } } else { GetDlgItem(IDC_PKGADMIN_REPOSITORY)->ShowWindow(SW_HIDE); } // setup the path to the user tools (tar and gunzip) if ((! m_strUserTools.IsEmpty()) || FindUserToolsPath ()) // if the user tools can be located { // add the user tools to the PATH environment variable const DWORD nLength = GetEnvironmentVariable (_T("PATH"), NULL, 0) + 1; TCHAR * pszOldPath = new TCHAR [nLength]; GetEnvironmentVariable (_T("PATH"), pszOldPath, nLength); SetEnvironmentVariable (_T("PATH"), CString (pszOldPath) + _T(";") + m_strUserTools); delete [] pszOldPath; } // setup the package tree image list m_ilTreeIcons.Create (IDB_PKGADMIN_TREEICONS, 16, 1, RGB (0,128,128)); m_ctrlPackageTree.SetImageList (&m_ilTreeIcons, TVSIL_NORMAL); // populate the package tree while (! PopulatePackageTree (m_strRepository)) { m_strRepository = _T(""); OnPkgadminRepository (); // prompt the user for the repository location if (m_strRepository.IsEmpty ()) // if dialog was cancelled { PostQuitMessage (1); return TRUE; } } return TRUE; // return TRUE unless you set the focus to a control}void CPkgAdminDlg::OnSysCommand(UINT nID, LPARAM lParam){ if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CPkgadminAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CeCosDialog::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 CPkgAdminDlg::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 { CeCosDialog::OnPaint(); }}// The system calls this to obtain the cursor to display while the user drags// the minimized window.HCURSOR CPkgAdminDlg::OnQueryDragIcon(){ return (HCURSOR) m_hIcon;}// Trivial handlers; otherwise CdlPackagesDatabaseBody::make asserts.void CdlErrorHandler (std::string message){};void CdlWarningHandler (std::string message){};bool CPkgAdminDlg::PopulatePackageTree(LPCTSTR pszPackagesPath){ // delete any existing CDL database if (m_CdlPkgData) { delete m_CdlPkgData; m_CdlPkgData = NULL; } // load the package database try { // Cdl asserts unless the handlers are present.#if 1 m_CdlPkgData = CdlPackagesDatabaseBody::make (UnicodeToStdStr (pszPackagesPath), &CdlErrorHandler, &CdlWarningHandler);#else m_CdlPkgData = CdlPackagesDatabaseBody::make (UnicodeToStdStr (pszPackagesPath));#endif } catch (CdlStringException exception) { CString strMessage; strMessage.Format (_T("Error loading database:\n\n%s"), CString (exception.get_message ().c_str ())); AfxMessageBox (strMessage); return false; } catch (...) { AfxMessageBox (_T("Error loading database")); return false; } // clear the old package tree ClearPackageTree (); // populate the new package tree
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -