cdbexpview.cpp
来自「本人买的<<VC++项目开发实例>>源代码配套光盘.」· C++ 代码 · 共 191 行
CPP
191 行
// Copyright (C) 1991 - 1999 Rational Software Corporation
#include "stdafx.h"
#include "CDBExpView.h"
#include "resource.h"
#include "..\OBSCRIPT\FetchScript.h"
#include "..\DLLs\ViewFunc\viewparamdef.h"
#include "CDBExpDatabase.h"
#include "DLLFuncs.h"
//##ModelId=3CDCDCD7009D
CDBExpView::CDBExpView(const CString &strName)
{
m_strViewName = strName;
}
//##ModelId=3CDCDCD7009B
CDBExpView::~CDBExpView()
{
}
//##ModelId=3CDCDCD700A6
BOOL CDBExpView::ExpandItem(HTREEITEM hItem, UINT state)
{
return TRUE;
}
//##ModelId=3CDCDCD70087
BOOL CDBExpView::OpenRelatedView(LPARAM lParam)
{
// ToDo: Add your specialized code here
// AfxMessageBox("Nothing");
return static_cast<BOOL>(0);
}
//##ModelId=3CDCDCD70074
void CDBExpView::BuildTVITEM(HTREEITEM hParentItem)
{
// ToDo: Add your specialized code here or after the call to base class
CDBTreeNode::BuildTVITEM(hParentItem);
this->m_tvInsertStruct.item.cChildren = 0;
this->m_tvInsertStruct.item.iImage =
this->m_tvInsertStruct.item.iSelectedImage = 5;
}
//##ModelId=3CDCDCD7007D
BOOL CDBExpView::PopupContextMenu(DBTREE_NODE_CONTEXT& context)
{
// ToDo: Add your specialized code here or after the call to base class
return CDBTreeNode::PopupContextMenu(context);
}
//##ModelId=3CDCDCD70042
void CDBExpView::OnMenuItemClick(UINT nCmd)
{
// ToDo: Add your specialized code here or after the call to base class
CDBExpDatabase *pDatabase = this->GetDatabase();
PARAM_VIEW paramView;
memset(¶mView, 0, sizeof(paramView));
strcpy(paramView.szViewName, (const char *)this->GetTreeNodeCaption());
strcpy(paramView.szConnectionString, (const char *)this->GetDatabase()->m_strCnn);
LPARAM lParam = (LPARAM)¶mView;
HWND hWnd = AfxGetMainWnd()->m_hWnd;
CString strSQL = "";
CFetchScript fs(pDatabase->m_ptrConnection);
fs.SetServerType(pDatabase->GetDatabaseType());
switch(nCmd)
{
case ID_MENU_EXP_TAB_RECCOUNT:
strcpy(paramView.szCmd, "RecordCount");
this->View_RecCount(hWnd, lParam);
break;
case ID_MENU_TABLE_OPEN:
strcpy(paramView.szCmd, "TableOpen");
this->View_GetRecordSet(hWnd, lParam);
break;
case ID_MENU_EXP_SCRIPT:
fs.SetObjectName(this->m_strViewName);
strSQL = fs.GetScript();
strcpy(paramView.szSQLInString, (const char *)strSQL);
this->View_GenerateScript(hWnd, lParam);
break;
case ID_MENU_PROP:
strcpy(paramView.szCmd, "Property");
this->View_Property(hWnd, lParam);
break;
case ID_MENU_VIEW_DEF:
fs.SetObjectName(this->m_strViewName);
strSQL = fs.GetScript();
strcpy(paramView.szSQLInString, (const char *)strSQL);
this->View_Definition(hWnd, lParam);
break;
default:
CDBTreeNode::OnMenuItemClick(nCmd);
break;
}
}
//##ModelId=3CDCDCD7004D
const char* CDBExpView::GetTreeNodeCaption()
{
// ToDo: Add your specialized code here or after the call to base class
return (const char *)m_strViewName;
}
//##ModelId=3CDCDCD70056
void CDBExpView::BuildContextMenu(DBTREE_NODE_CONTEXT& context)
{
// ToDo: Add your specialized code here or after the call to base class
m_pContextMenu->LoadMenu(IDR_MENU_VIEW);
}
//##ModelId=3CDCDCD7006B
int CDBExpView::View_RecCount(HWND hWnd, LPARAM lParam)
{
int ret = CDLLFuncs::View_RecCount(hWnd, lParam);
if(FALSE == ret )
return FALSE;
CString strPrompt;
strPrompt.Format("%s%d", "记录数是:", ret);
AfxMessageBox(strPrompt);
return TRUE;
}
//##ModelId=3CDCDCD700CF
int CDBExpView::View_GetRecordSet(HWND hParentWnd, LPARAM lParam)
{
int ret = CDLLFuncs::View_GetRecordSet(hParentWnd, lParam);
if(FALSE == ret )
return FALSE;
return 1;
}
//##ModelId=3CDCDCD700C5
int CDBExpView::View_Definition(HWND hParentWnd, LPARAM lParam)
{
int ret = CDLLFuncs::View_Definition(hParentWnd, lParam);
if(FALSE == ret )
return FALSE;
return 1;
}
//##ModelId=3CDCDCD700BC
int CDBExpView::View_Property(HWND hParentWnd, LPARAM lParam)
{
int ret = CDLLFuncs::View_Property(hParentWnd, lParam);
if(FALSE == ret )
return FALSE;
return 1;
}
//##ModelId=3CDCDCD700B9
int CDBExpView::View_GenerateScript(HWND hParentWnd, LPARAM lParam)
{
int ret = CDLLFuncs::View_GenerateScript(hParentWnd, lParam);
if(FALSE == ret )
return FALSE;
return 1;
}
//##ModelId=3CDCDCD70061
void CDBExpView::BuildLVITEM(int& nIndex)
{
// ToDo: Add your specialized code here or after the call to base class
CDBTreeNode::BuildLVITEM(nIndex);
m_lvInsertStruct.iImage = 2;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?