📄 propadd1page.cpp
字号:
//添加数据库中查询到的内容
m_ListControl.AddString("已存在的项目ID:");
m_RecordInfo->MoveFirst();
//多余5条记录,只列出5条记录
if (RecordCount>5)
{
for (int i=0;i<5;i++)
{
CString str=m_RecordInfo->GetCollect("ProjectID").bstrVal;
m_ListControl.AddString(str);
m_RecordInfo->MoveNext();
}
}
else
{
while (!m_RecordInfo->adEOF)
{
CString str=m_RecordInfo->GetCollect("ProjectID").bstrVal;
m_ListControl.AddString(str);
m_RecordInfo->MoveNext();
}
}
}
else
{
if (m_ListControl.m_hWnd!=NULL)
{
m_ListControl.DestroyWindow();
}
}
}
}
void CPropAdd1Page::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//当鼠标点击时销毁列表框
if (m_ListControl.m_hWnd!=NULL)
{
m_ListControl.DestroyWindow();
}
if (m_ListDir.m_hWnd!=NULL)
{
m_ListDir.DestroyWindow();
}
CPropertyPage::OnLButtonDown(nFlags, point);
}
void CPropAdd1Page::SetStaticIconText(CWnd *Control, CString str, HICON &Icon,CStatic &StaticIcon,CStatic &StaticText)
{
CRect rectControl,rectIcon,rectText;
Control->GetWindowRect(&rectControl);
rectIcon.top=rectControl.top;
rectIcon.bottom=rectControl.bottom;
rectIcon.left=rectControl.right;
rectIcon.right=rectIcon.left+20;
rectText.top=rectIcon.top;
rectText.bottom=rectIcon.bottom;
rectText.left=rectIcon.right;
rectText.right=rectText.left+120;
ScreenToClient(&rectIcon);
ScreenToClient(&rectText);
//设置静态控件为图标格式
if (StaticIcon.m_hWnd!=NULL)
{
StaticIcon.DestroyWindow();
StaticIcon.Create(" ",WS_VISIBLE | WS_CHILD |SS_ICON |SS_CENTERIMAGE ,rectIcon,this);
StaticIcon.SetIcon(Icon);
}
else
{
StaticIcon.Create(" ",WS_VISIBLE | WS_CHILD |SS_ICON |SS_CENTERIMAGE ,rectIcon,this);
StaticIcon.SetIcon(Icon);
}
//动态生成文本静态控件
if (m_IDText.m_hWnd!=NULL)
{
StaticText.DestroyWindow();
StaticText.Create(str,WS_VISIBLE | WS_CHILD | SS_CENTERIMAGE ,rectText,this);
StaticText.SetFont(&m_font,TRUE);
}
else
{
StaticText.Create(str,WS_VISIBLE | WS_CHILD | SS_CENTERIMAGE ,rectText,this);
StaticText.SetFont(&m_font,TRUE);
}
}
//当目录编辑框改变时,动态生成列表框显示此目录中的文件
void CPropAdd1Page::OnChangeEditProloc()
{
// 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_PROLOC),m_ListDir);
}
void CPropAdd1Page::CreateDirList(CWnd *pWnd, CListCtrl &m_ListDir)
{
if (!m_ProLoc.IsEmpty())
{
CFileFind fileFind;
CString ProLoc=m_ProLoc+"\\*.*";
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,1);
}
else
{
m_ListDir.Create(WS_CHILD | WS_VISIBLE |LVS_SMALLICON ,rectList,this,1);
}
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();
}
}
}
void CPropAdd1Page::CreateProList(CWnd *pWnd, CListBox &IDList)
{
//得到列表框的生成位置
CRect rectEdit,rectList;
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);
}
//添加数据库中查询到的内容
}
//改变工程名字时,动态添加已经存在的名字
void CPropAdd1Page::OnChangeEditProname()
{
// 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);
if (m_ProID.IsEmpty())
{
if (m_ListControl.m_hWnd!=NULL)
{
m_ListControl.DestroyWindow();
}
}
else
{
CString sql="select ProjectName From ProjectInfo Where ProjectName Like '"+m_ProName+"%' Order By ProjectTime";
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)
{
//创建列表框
CreateProList(GetDlgItem(IDC_EDIT_PRONAME),m_ListControl);
//添加数据库中查询到的内容
m_ListControl.AddString("已存在的项目名称:");
m_RecordInfo->MoveFirst();
//多余5条记录,只列出5条记录
if (RecordCount>5)
{
for (int i=0;i<5;i++)
{
CString str=m_RecordInfo->GetCollect("ProjectName").bstrVal;
m_ListControl.AddString(str);
m_RecordInfo->MoveNext();
}
}
else
{
while (!m_RecordInfo->adEOF)
{
CString str=m_RecordInfo->GetCollect("ProjectName").bstrVal;
m_ListControl.AddString(str);
m_RecordInfo->MoveNext();
}
}
}
else
{
if (m_ListControl.m_hWnd!=NULL)
{
m_ListControl.DestroyWindow();
}
}
}
}
BOOL CPropAdd1Page::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
m_LocTipCtrl.RelayEvent(pMsg);
return CPropertyPage::PreTranslateMessage(pMsg);
}
BOOL CPropAdd1Page::SetTipText(UINT id, NMHDR *pTTTStruct, LRESULT *pResult)
{
UpdateData(TRUE);
TOOLTIPTEXT * pTTT=(TOOLTIPTEXT *)pTTTStruct;
// StrCpyN(pTTT->lpszText,m_ProLoc.GetBuffer(m_ProLoc.GetLength()),m_ProLoc.GetLength()+1);
LPTSTR stri=m_ProLoc.GetBuffer(m_ProLoc.GetLength());
strcpy(pTTT->lpszText,stri);
m_ProLoc.ReleaseBuffer();
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -