⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 speedcddlg.cpp

📁 虚拟光驱程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// DialogDemoDlg.cpp : implementation file
//

#include "stdafx.h"
//#include <winsvc.h>
#include <winioctl.h>
#include <ntddcdrm.h>
#include <winsvc.h>

#include "Speedcd.h"
#include "SpeedcdDlg.h"
#include "resource.h"
#include "speedcd_mfc.h"

#include "DialogBIN2ISO.h"
#include "DialogCreateISO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//treelist
//         m_hi:  itemdata=0
//         m_hi1: itemdata=1 NO CDISO file
//                itemdata=3 have CDISO file
//         m_hi2: itemdata=2


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{		

public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
    CString	m_edit1;
	CString	m_edit2;
	//}}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 void OnContextMenu(CWnd*, CPoint point);
	//{{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)
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	DDX_Text(pDX, IDC_EDIT2, m_edit2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CString GetErrorMessage()
{
    CString s;
    LPVOID lpMsgBuf;
    FormatMessage( 
        FORMAT_MESSAGE_ALLOCATE_BUFFER | 
        FORMAT_MESSAGE_FROM_SYSTEM | 
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        GetLastError(),
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
        (LPTSTR) &lpMsgBuf,
        0,
        NULL 
    );
    // Free the buffer.
    s = (char *)lpMsgBuf;
    LocalFree( lpMsgBuf );

    return s;
}

/////////////////////////////////////////////////////////////////////////////
// CDialogDemoDlg dialog

CDialogDemoDlg::CDialogDemoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogDemoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogDemoDlg)
		// 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);
	//device_Num=0;
}

void CDialogDemoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogDemoDlg)
		DDX_Control(pDX, IDC_LIST1, m_ctlList1);
    	DDX_Control(pDX, IDC_TREE1, m_ctlTree1);
		//DDX_Control(pDX, IDC_TOOLBARHOT, m_hotToolBar);
	  
      // NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDialogDemoDlg, CDialog)
	ON_WM_CONTEXTMENU()
	//{{AFX_MSG_MAP(CDialogDemoDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_COMMAND(IDM_LOADSKIN, OnLoadskin)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_TOOLS_CREATEISO, OnToolsCreateiso)
	ON_COMMAND(ID_TOOLS_BIN2ISO, OnToolsBin2iso)
	ON_COMMAND(ID_FILE_Add_Virtual, OnFILEAddVirtual)
	ON_COMMAND(ID_FILE_UNMOUNT, OnFileUnmount)
	ON_NOTIFY(NM_RCLICK, IDC_TREE1, OnRclickTree1)
	ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
	ON_COMMAND(IDM_ADD_ISOFILE, OnAddIsofile)
	ON_COMMAND(IDM_REMOVE_ISOFILE, OnRemoveIsofile)
	ON_WM_SIZE()
	ON_NOTIFY_EX(TTN_NEEDTEXTA, 0, OnToolTipText)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//	ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipText )


/////////////////////////////////////////////////////////////////////////////
// CDialogDemoDlg message handlers

BOOL CDialogDemoDlg::OnInitDialog()
{
	 CString szPath;
	 CDialog::OnInitDialog();
	//DWORD dwStyles = m_tbar2.GetTBar().GetStyle(); 
	//SetWindowLong(m_tbar2.GetTBar().m_hWnd,GWL_STYLE,dwStyles|0x800);
	 m_ctlList1.SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP );
	 char szsysPath[MAX_PATH];
     GetWindowsDirectory( szsysPath, MAX_PATH );
	 inifile.SetPath(CString(szsysPath)+"\\"+"SpeedCD.INI");
     // Now fill the list control	
     LV_COLUMN lvc;
     lvc.mask     = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
     lvc.fmt=LVCFMT_CENTER;
	 lvc.pszText  = "ISO文件";
     lvc.iSubItem = 0;         
     lvc.cx       = 300;
     m_ctlList1.InsertColumn( 0, &lvc );

//add isofile to list
	if (inifile.ReadFile())
	{
		 int iCNT=inifile.GetNumValues("ISOFILE");
		 for (int i=0;i<iCNT;i++)
		 {
		   szPath="";
		   CString s; 
		   s.Format("%ld", i); 
		   szPath=inifile.GetValue("ISOFILE",s);
		   m_ctlList1.InsertItem(i,szPath);
		 }
	}
 
  	// 
    m_imgList.Create( IDB_BITMAP1, 16, 1, RGB( 0, 128, 128 ) );

    m_ctlTree1.SetImageList( &m_imgList, TVSIL_NORMAL );
    m_hi = m_ctlTree1.InsertItem( _T( "大易极速光驱" ), 0, 0 );
	m_ctlTree1.SetItemData(m_hi,0);
	
	if (inifile.ReadFile())
	{ 
		//int keyCNT=inifile.GetNumKeys();
        //GetNumValues("ISOST_FILE");
		char szDrive[10] = "::";
		for (char iCD='A';iCD<='Z';iCD++)
		{	
		  szPath="";
		  szPath=inifile.GetValue("ISOCD",CString(iCD)); 
		  if ((szPath!=""))
		  {
			szDrive[0] =iCD;
			UINT type = GetDriveType(szDrive);
			if ( type==DRIVE_CDROM )// is CD DRIVER
			{
			  hi1 = m_ctlTree1.InsertItem( CString(iCD)+":", 1, 2, m_hi );  
			  m_ctlTree1.SetItemData(hi1,1); //No CD ISO FILE
			  if  (szPath!="NOCD") //insert iso file
			  {
				 hi2 = m_ctlTree1.InsertItem( szPath, 3, 3, hi1 );
				 m_ctlTree1.SetItemData(hi1,3); //have CD ISO FILE
				 m_ctlTree1.SetItemData(hi2,2);
			  }
			}
		
		  }
		}//for
	}
    m_ctlTree1.Expand( m_hi, TVE_EXPAND ); 

    CenterWindow();
	// 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
	m_Menu.LoadMenu(IDR_MAINFRAME);
	SetMenu( &m_Menu );

	
   
	if (!m_hotToolBar.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_LIST, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_hotToolBar.LoadToolBar(IDC_TOOLBARHOT))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
 	CImageList	imageList;
	CBitmap		bitmap;

	// Create and set the normal toolbar image list.
	bitmap.LoadBitmap(IDB_TOOLBARCOOL);
	imageList.Create(32, 32, ILC_COLORDDB|ILC_MASK, 22, 1);
	imageList.Add(&bitmap, RGB(255,0,255));
	m_hotToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
	imageList.Detach();
	bitmap.Detach();

    bitmap.LoadBitmap(IDB_TOOLBARHOT);
	imageList.Create(32, 32, ILC_COLORDDB|ILC_MASK, 22, 1);
	imageList.Add(&bitmap, RGB(255,0,255));
	m_hotToolBar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
	imageList.Detach();
	bitmap.Detach();

    m_hotToolBar.ShowWindow(SW_SHOW);
	RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
	SetWindowSkin( m_hWnd , "Dialog" );
    SetDialogSkin("Dialog");
	AfxGetApp()->GetMainWnd()->SetWindowText("大易极速光驱SpeedCD V1.0(全部源代码出售:http://www.nuskinbj.com)");


    //SetSingleDialogSkin(m_hWnd,"Dialog");
	//SetWindowTitle("文档标题");
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDialogDemoDlg::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 CDialogDemoDlg::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
	{
	    		//获得对话框的尺寸
		RECT Rect;
		GetWindowRect(&Rect);
		//修改对话框的尺寸
		GetWindowRect(&Rect);
		//修改对话框的尺寸
		if (Rect.bottom-Rect.top>465)
		   SetWindowPos(NULL,Rect.left,Rect.right,Rect.right-Rect.left,465,SWP_NOMOVE);

		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDialogDemoDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CDialogDemoDlg::OnAppAbout() 
{
	// TODO: Add your command handler code here
		CAboutDlg dlgAbout;
		dlgAbout.m_edit1.Format("本软件源代码出售:\n"
			                    "        源代码包括上层应用程序和虚拟光驱驱动程序两\n"
								"部分,全部为C++/C代码。\n"
								"        应用程序代码包括驱动程序的接口使用方法,\n"
								);
		dlgAbout.m_edit2.Format("ISO文件创建算法,BIN文件转ISO文件算法代码等。\n"
								"        驱动程序由DDK编写而成,包括把ISO文件虚拟\n"
								"为光驱和光驱控制方法等代码。\n"
								"        任何问题请洽:dayeesoft@nuskinbj.com");
		dlgAbout.DoModal();
}

BOOL CDialogDemoDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
//	 if(m_tbar2.m_hWnd)
//	 	m_tbar2.PreTranslate(pMsg);
	return CDialog::PreTranslateMessage(pMsg);
}


void CDialogDemoDlg::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component	/*{		if (point.x == -1 && point.y == -1){			//keystroke invocation			CRect rect;			GetClientRect(rect);			ClientToScreen(rect);			point = rect.TopLeft();			point.Offset(5, 5);		}		CMenu menu;		VERIFY(menu.LoadMenu(IDR_POPUPMENU));		CMenu* pPopup = menu.GetSubMenu(0);		ASSERT(pPopup != NULL);		CWnd* pWndPopupOwner = this;		while (pWndPopupOwner->GetStyle() & WS_CHILD)			pWndPopupOwner = pWndPopupOwner->GetParent();		TrackSkinPopupMenu( pPopup->m_hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,			pWndPopupOwner->m_hWnd );	}
	*/
}

void CDialogDemoDlg::OnLoadskin() 
{
	char strExt[]= "SpeedCD Skin Files(*.spd)|*.spd||";
	CFileDialog dlg( TRUE, "*.spd", "*.spd" , OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strExt ,  this );

	if( dlg.DoModal() == IDOK  )
	{
		LoadSkinFile( (char*)(LPCSTR)(dlg.GetPathName()) );
	}	
}

void CDialogDemoDlg::OnToolsBin2iso() 
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -