📄 osdgeneratedlg.cpp
字号:
// OsdGenerateDlg.cpp : implementation file
//
#include "stdafx.h"
#include "OsdGenerate.h"
#include "OsdGenerateDlg.h"
#include "FileOperate.h"
#include "Shlwapi.h"
#pragma comment(lib,"Shlwapi.lib")
#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()
/////////////////////////////////////////////////////////////////////////////
// COsdGenerateDlg dialog
COsdGenerateDlg::COsdGenerateDlg(CWnd* pParent /*=NULL*/)
: CDialog(COsdGenerateDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COsdGenerateDlg)
m_SetSave = -1;
m_SourceDir = _T("");
m_OsdName = _T("");
m_OsdSize = _T("");
m_ResName = _T("");
m_ResSize = _T("");
m_Set = FALSE;
m_OsdSave = _T("");
m_ResSave = _T("");
m_Information = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void COsdGenerateDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COsdGenerateDlg)
DDX_Text(pDX, IDC_EDIT1, m_SourceDir);
DDX_Text(pDX, IDC_EDIT3, m_OsdName);
DDX_Text(pDX, IDC_EDIT4, m_OsdSize);
DDX_Text(pDX, IDC_EDIT5, m_ResName);
DDX_Text(pDX, IDC_EDIT6, m_ResSize);
//DDX_Check(pDX, IDC_SET_SAVE, m_Set);
DDX_Text(pDX, IDC_EDIT2, m_OsdSave);
DDX_Text(pDX, IDC_EDIT7, m_ResSave);
DDX_Text(pDX, IDC_INFORMATION, m_Information);
//}}AFX_DATA_MAP
}
#define UPDATE_MESSAGE (WM_USER+100)
BEGIN_MESSAGE_MAP(COsdGenerateDlg, CDialog)
//{{AFX_MSG_MAP(COsdGenerateDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_GENERATE, OnGenerate)
ON_BN_CLICKED(IDC_BROWSE_SOURCE, OnBrowseSource)
ON_BN_CLICKED(IDC_BROWSE_RES, OnBrowseRes)
ON_BN_CLICKED(IDC_BROWSE_OSD, OnBrowseOsd)
ON_MESSAGE(UPDATE_MESSAGE, OnUserMessage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COsdGenerateDlg message handlers
CString m_udatatmp;
int COsdGenerateDlg::ReadContent(void)//1--OK, 2--Space key, 3--too huge
{
int i,j;
char pCtmp[2];
CFile fileEditText;
char m_currentdir[MAX_PATH];
GetCurrentDirectory(MAX_PATH,m_currentdir);
m_udatatmp=m_currentdir;
m_udatatmp+="\\udata.dat";
//strcat(m_currentdir,"\\udata.dat");
if(fileEditText.Open(m_udatatmp,CFile::modeRead))
{
if(!fileEditText.GetLength())
return 5;
for(j=0;j<=6;j++)
{
for(i=0;i<100;i++)
{
fileEditText.Read(pCtmp,1);
if(*pCtmp!='\n')
{
if(*pCtmp==' ')
{
fileEditText.Close();
return 2;//error do not need space key
}
switch(j)
{
case 0:
m_SourceDir+=*pCtmp;
break;
case 1:
m_OsdSave+=*pCtmp;
break;
case 2:
m_ResSave+=*pCtmp;
break;
case 3:
m_OsdName+=*pCtmp;
break;
case 4:
m_OsdSize+=*pCtmp;
break;
case 5:
m_ResName+=*pCtmp;
break;
case 6:
m_ResSize+=*pCtmp;
break;
}
}
else
break;
}
}
}
else
return 4;//can't open
fileEditText.Close();
return 3;
}
BOOL COsdGenerateDlg::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
//GetDlgItem(IDC_SAVE_DIR)->EnableWindow(0);
//GetDlgItem(IDC_EDIT2)->EnableWindow(0);
//GetDlgItem(IDC_BROWSE_OUT)->EnableWindow(0);
//GetDlgItem(IDC_BROWSE_SOURCE)->EnableWindow(0);
ReadContent();
/*
if(m_Set)
{
GetDlgItem(IDC_SAVE_DIR)->EnableWindow(1);
GetDlgItem(IDC_EDIT2)->EnableWindow(1);
GetDlgItem(IDC_BROWSE_OUT)->EnableWindow(1);
GetDlgItem(IDC_BROWSE_SOURCE)->EnableWindow(1);
}
*/
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
}
void COsdGenerateDlg::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 COsdGenerateDlg::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 COsdGenerateDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void COsdGenerateDlg::OnSetSave()
{
/*
// TODO: Add your control notification handler code here
if(((CButton*)GetDlgItem(IDC_SET_SAVE))->GetCheck())
{
GetDlgItem(IDC_SAVE_DIR)->EnableWindow(1);
GetDlgItem(IDC_EDIT2)->EnableWindow(1);
//GetDlgItem(IDC_BROWSE_OUT)->EnableWindow(1);
}
else
{
GetDlgItem(IDC_SAVE_DIR)->EnableWindow(0);
GetDlgItem(IDC_EDIT2)->EnableWindow(0);
//GetDlgItem(IDC_BROWSE_OUT)->EnableWindow(0);
}
*/
}
#define PartTemp 250
int COsdGenerateDlg::CustomFileCreate(char kind)
{
unsigned char pChar[PartTemp],pTmp[2]={NULL,NULL};
unsigned long int i,k,j,m;
CFile fileSource,fileDest;
CString csTmp,csTmp2,ctemp,SourceTmp,OutTmp,CommonName,CommonSize;
if(!kind)//osd
{
SourceTmp=m_SourceDir;
SourceTmp.Delete(SourceTmp.GetLength()-3,4);
SourceTmp+=".osd";
OutTmp=m_OsdSave;
CommonName=m_OsdName;
CommonSize=m_OsdSize;
}
else//res
{
SourceTmp=m_SourceDir;
SourceTmp.Delete(SourceTmp.GetLength()-3,4);
SourceTmp+=".res";
OutTmp=m_ResSave;
CommonName=m_ResName;
CommonSize=m_ResSize;
}
if (fileSource.Open(SourceTmp,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -