📄 propadd2.cpp
字号:
//DEL m_eFileLevel=pFileHeader->eFileLevel;
//DEL m_eFileOwner=pFileHeader->eFileOwner;
//DEL m_eFileLoc=pFileHeader->eFileLoc;
//DEL UpdateData(FALSE);
//DEL *pResult = 0;
//DEL }
void CPropAdd2::CreateIDList(CWnd *pWnd, CListBox &IDList)
{
//得到列表框的生成位置
static CRect rectEdit,rectList;
if (rectEdit.IsRectNull())
{
pWnd->GetWindowRect(&rectEdit);
rectList.left=rectEdit.left;
rectList.right=rectEdit.right;
rectList.top=rectEdit.bottom;
rectList.bottom=rectList.top+rectEdit.Height()*5;
ScreenToClient(&rectList);
}
//创建列表框
if (IDList.m_hWnd!=NULL)
{
IDList.DestroyWindow();
IDList.Create(WS_CHILD | WS_VISIBLE | LBS_STANDARD & ~LBS_SORT,rectList,this,0);
}
else
{
IDList.Create(WS_CHILD | WS_VISIBLE | LBS_STANDARD & ~LBS_SORT,rectList,this,0);
}
//添加数据库中查询到的内容
IDList.AddString("已存在的文件ID:");
}
void CPropAdd2::OnChangeEditEfileid()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_IDEditControl.GetWindowText(m_eFileID);
//如果更改为空,删除列表框
if (m_eFileID.IsEmpty())
{
if (m_IDList.m_hWnd!=NULL)
{
m_IDList.DestroyWindow();
}
}
else
{
CString sql="select FileID From FileElectron Where FileID Like '"+m_eFileID+"%' Order By FileID DESC";
m_RecordInfo.CreateInstance("ADODB.Recordset");
m_RecordInfo->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),
adOpenDynamic,adLockOptimistic,adCmdText);
long RecordCount=m_RecordInfo->GetRecordCount();
if (RecordCount!=0)
{
//创建列表框
CreateIDList(GetDlgItem(IDC_EDIT_EFILEID),m_IDList);
//添加数据库中查询到的内容
m_RecordInfo->MoveFirst();
//多余5条记录,只列出5条记录
if (RecordCount>5)
{
for (int i=0;i<5;i++)
{
CString str1=m_RecordInfo->GetCollect("FileID").bstrVal;
m_IDList.AddString(str1);
m_RecordInfo->MoveNext();
}
}
else
{
while (!m_RecordInfo->adEOF)
{
CString str1=m_RecordInfo->GetCollect("FileID").bstrVal;
m_IDList.AddString(str1);
m_RecordInfo->MoveNext();
}
}
}
else
{
if (m_IDList.m_hWnd!=NULL)
{
m_IDList.DestroyWindow();
}
}
}
}
void CPropAdd2::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_IDList.m_hWnd!=NULL)
{
m_IDList.DestroyWindow();
}
if (m_DirList.m_hWnd!=NULL)
{
m_DirList.DestroyWindow();
}
CPropertyPage::OnLButtonDown(nFlags, point);
}
//检查是否存在此目录
void CPropAdd2::OnKillfocusEditEfileloc()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CFileFind filedir;
if (!m_eFileLoc.IsEmpty())
{
if (!filedir.FindFile(m_eFileLoc))
{
MessageBox("目录不存在");
m_Loctrue=FALSE;
}
else
{
m_Loctrue=TRUE;
}
}
else
{
m_Loctrue=FALSE;
}
}
void CPropAdd2::OnChangeEditEfileloc()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CreateDirList(GetDlgItem(IDC_EDIT_EFILELOC),m_DirList);
}
void CPropAdd2::CreateDirList(CWnd *pWnd, CListCtrl &m_ListDir)
{
if (!m_eFileLoc.IsEmpty())
{
CFileFind fileFind;
CString ProLoc=m_eFileLoc+"\\*.*";
BOOL bWorking=fileFind.FindFile(ProLoc);
if (bWorking)
{
static CRect rectEdit,rectList;
if(rectEdit.IsRectNull())
{
pWnd->GetWindowRect(&rectEdit);
rectList.top=rectEdit.bottom;
rectList.bottom=rectList.top+rectEdit.Height()*5;
rectList.left=rectEdit.left;
rectList.right=rectEdit.right;
ScreenToClient(&rectList);
}
if (m_ListDir.m_hWnd!=NULL)
{
m_ListDir.DestroyWindow();
m_ListDir.Create(WS_CHILD | WS_VISIBLE |LVS_SMALLICON ,rectList,this,IDC_LIST_DIRCONTENT);
}
else
{
m_ListDir.Create(WS_CHILD | WS_VISIBLE |LVS_SMALLICON ,rectList,this,IDC_LIST_DIRCONTENT);
}
if (m_ImageList.m_hImageList==NULL)
{
// m_ImageList.DeleteImageList();
m_ImageList.Create(16,16,ILC_COLORDDB|ILC_MASK,2,1);
//获得文件夹句柄图像
HICON iconDir=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_DIR),
IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
//获得文件夹句柄图像
HICON iconFile=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_FILE),
IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
m_ImageList.Add(iconDir);
m_ImageList.Add(iconFile);
}
m_ListDir.SetImageList(&m_ImageList,LVSIL_SMALL);
int index=0;
while (bWorking)
{
bWorking=fileFind.FindNextFile();
CString str=fileFind.GetFileName();
if (fileFind.IsDirectory())
{
m_ListDir.InsertItem(index,str,0);
}
else
{
m_ListDir.InsertItem(index,str,1);
}
index++;
}
}
else
{
if (m_ListDir.m_hWnd!=NULL)
{
m_ListDir.DestroyWindow();
}
}
}
else
{
if (m_ListDir.m_hWnd!=NULL)
{
m_ListDir.DestroyWindow();
}
}
}
//查看数据库中是否已经存在此ID
void CPropAdd2::OnKillfocusEditEfileid()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_IDEditControl.GetWindowText(m_eFileID);
if (!m_eFileID.IsEmpty())
{
CString sql="select FileID From FileElectron Where FileID = '"+m_eFileID+"' Order By FileID DESC";
m_RecordInfo.CreateInstance("ADODB.Recordset");
m_RecordInfo->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),
adOpenDynamic,adLockOptimistic,adCmdText);
long RecordCount=m_RecordInfo->GetRecordCount();
if (RecordCount!=0)
{
m_IDtrue=FALSE;
}
else
{
m_IDtrue=TRUE;
}
}
else
{
m_IDtrue=FALSE;
}
}
LRESULT CPropAdd2::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
if (m_IDList.m_hWnd!=NULL)
{
m_IDList.DestroyWindow();
}
if (m_DirList.m_hWnd!=NULL)
{
m_DirList.DestroyWindow();
}
return CPropertyPage::OnWizardNext();
}
void CPropAdd2::OnBtnOpenefile()
{
// TODO: Add your control notification handler code here
//建立打开文件对话框
CFileDialog filedlg(TRUE);
filedlg.m_ofn.lStructSize=sizeof(OPENFILENAME);
filedlg.m_ofn.lpstrFilter="All Files\0*.*\0\0";
filedlg.m_ofn.nFilterIndex=1;
// filedlg.m_ofn.lpstrInitialDir="D:\\DBbackup";
filedlg.m_ofn.lpstrTitle="选择电子文件";
if (filedlg.DoModal()==IDOK)
{
m_cEFilePath=filedlg.GetPathName();
//更新页面上的其他编辑框
int loc=m_cEFilePath.ReverseFind('\\');
m_eFileLoc=m_cEFilePath.Left(loc);
m_eFileName=m_cEFilePath.Right(m_cEFilePath.GetLength()-loc-1);
UpdateData(FALSE);
m_Loctrue=TRUE;
}
}
void CPropAdd2::OnClickListDir(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
if (m_DirList.m_hWnd!=NULL)
{
NM_LISTVIEW * pList=(NM_LISTVIEW *)pNMHDR;
int iItem=pList->iItem;
int iSubItem=pList->iSubItem;
m_eFileName=m_DirList.GetItemText(iItem,iSubItem);
UpdateData(FALSE);
if (m_DirList.m_hWnd!=NULL)
{
m_DirList.DestroyWindow();
}
}
*pResult = 0;
}
void CPropAdd2::OnSetfocusEditEfilename()
{
// TODO: Add your control notification handler code here
CreateDirList(GetDlgItem(IDC_EDIT_EFILENAME),m_DirList);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -