3761 lines
91 KiB
C++
3761 lines
91 KiB
C++
// OptionSheet.cpp : 实现文件
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "OptionSheet.h"
|
||
#include "fontpropertypage.h"
|
||
#include "afxtempl.h"
|
||
#include "TArchSettingEditTools.h"
|
||
#include "htmlhelp.h"
|
||
#include "TgAs.h"
|
||
|
||
///////////////////////////////////////////////////////////
|
||
extern TARCH_IMPEXP BOOL g_bLimitHeight;//外部限高
|
||
extern TARCH_IMPEXP BOOL g_bDefaultOpenFirst;//默认打开新一个
|
||
extern TARCH_IMPEXP BOOL g_bScrollBar;//是否需要右滚动条
|
||
extern int TARCH_IMPEXP g_nRunMode;
|
||
extern int TARCH_IMPEXP g_iMenuType;
|
||
extern TARCH_IMPEXP BOOL g_bEnableShortCut;
|
||
|
||
extern TARCH_IMPEXP int g_nProductId;
|
||
extern TARCH_IMPEXP double g_nVersion;
|
||
|
||
//extern void HideTabBar(BOOL bTrue);
|
||
extern TARCH_IMPEXP BOOL g_bDwgTabBar,g_bZoomKey,g_nRBtnMenuTime,g_nSpeedMenu;
|
||
extern TARCH_IMPEXP void SaveGlobalToReg();
|
||
|
||
//add by xlc on 090804
|
||
BOOL g_bScreenMenu = TRUE; //记录当前屏幕菜单状态
|
||
BOOL g_bCancel = FALSE; //记录当前是否cancel操作
|
||
|
||
void IsAppandAlias(DList<CBlockStruct> &lstAll, CBlockStruct *pItem);
|
||
|
||
//add by xlc on 071015
|
||
typedef struct {
|
||
LVITEM* plvi;
|
||
CString sCol2;
|
||
} lvItem, *plvItem;
|
||
|
||
//add by fxj 080925
|
||
//extern BOOL IsScreenMenuVisible();
|
||
//extern int ShowScreenMenu(BOOL bTrue);
|
||
///////////////////////////////////////////////////////////////
|
||
// command:TCustomize
|
||
void Customize()
|
||
{
|
||
CAcModuleResourceOverride vTemp;
|
||
COptionSheet sheet(acedGetAcadFrame());
|
||
if (sheet.DoModal() == IDOK)
|
||
{
|
||
//LH 2013-3-25 根据2014年加密需要水关键字8--14 暖6--15 电3--16
|
||
//if (g_nProductId!=2&&g_nProductId!=3&&g_nProductId!=8&&g_nProductId!=6)
|
||
if (g_nProductId!=kTASD && g_nProductId!=kTELEC && g_nProductId!=kTWT && g_nProductId!=kTHVAC)
|
||
{
|
||
sheet.m_pageToolBar.CreateToolbars();
|
||
sheet.m_pageShortCutKey.WriteShortCutKey();
|
||
sheet.m_pageShortCutKey.WritePgp();
|
||
}
|
||
sheet.m_pageScreenMenu.LoadMenu();
|
||
g_colorInPlaceText = sheet.m_FontDlgPage.m_cEdit.m_colorInPlaceText;
|
||
g_colorInPlaceGround = sheet.m_FontDlgPage.m_cEdit.m_colorInPlaceGround;
|
||
g_iInPlaceFontHeight = sheet.m_FontDlgPage.m_cEdit.m_iInPlaceFontHeight;
|
||
if (g_bDwgTabBar!=sheet.m_FontDlgPage.m_bDwgTabBar)
|
||
{
|
||
g_bDwgTabBar=sheet.m_FontDlgPage.m_bDwgTabBar;
|
||
//HideTabBar(!g_bDwgTabBar);
|
||
}
|
||
sheet.m_pageUserOperator.UpdateGlobalData();
|
||
//ShowScreenMenu(sheet.m_pageScreenMenu.m_bScreenMenu);//add by fxj 080925
|
||
acedCommand(RTSTR, _T("REGEN"), NULL);
|
||
}
|
||
else
|
||
{
|
||
if (sheet.m_pageScreenMenu.m_bPreview)
|
||
{
|
||
g_menuColors[0] = sheet.m_pageScreenMenu.m_nMenuBKColor1;
|
||
g_menuColors[1] = sheet.m_pageScreenMenu.m_nMenuBKColor2;
|
||
g_menuColors[2] = sheet.m_pageScreenMenu.m_nMenuBKColor3;
|
||
g_menuColors[3] = sheet.m_pageScreenMenu.m_nMenuBKColor4;
|
||
|
||
acedGetAcadFrame()->RedrawWindow(NULL,NULL,RDW_ALLCHILDREN|RDW_INVALIDATE);
|
||
}
|
||
}
|
||
}
|
||
|
||
IMPLEMENT_DYNAMIC(CScreenMenuPage, CAcUiTabChildDialog)
|
||
CScreenMenuPage::CScreenMenuPage(CWnd* pParent):CAcUiTabChildDialog(pParent)
|
||
{
|
||
m_bLimitHeight=g_bLimitHeight;
|
||
m_bScrollBar=g_bScrollBar;
|
||
m_bAutoOpenFirst=g_bDefaultOpenFirst;
|
||
m_bChecked = FALSE;
|
||
m_iMenuType=g_iMenuType;
|
||
|
||
m_nMenuBKColor1 = g_menuColors[0];
|
||
m_nMenuBKColor2 = g_menuColors[1];
|
||
m_nMenuBKColor3 = g_menuColors[2];
|
||
m_nMenuBKColor4 = g_menuColors[3];
|
||
|
||
m_bModified = FALSE;
|
||
m_bPreview = FALSE;
|
||
|
||
//add by fxj 080925
|
||
m_bScreenMenu = FALSE;
|
||
//m_bScreenMenu = IsScreenMenuVisible();
|
||
//g_bScreenMenu = IsScreenMenuVisible();
|
||
}
|
||
void CScreenMenuPage::DoDataExchange(CDataExchange*pDX)
|
||
{
|
||
CAcUiTabChildDialog::DoDataExchange(pDX);
|
||
DDX_CBIndex(pDX,IDC_MENU_FILE,m_iMenuType);
|
||
DDX_Radio(pDX,IDC_RADIO1,m_bLimitHeight);
|
||
DDX_Check(pDX,IDC_SCROLL_BAR,m_bScrollBar);
|
||
DDX_Check(pDX,IDC_OPEN_FIRST,m_bAutoOpenFirst);
|
||
|
||
//add by xlc on 071019
|
||
DDX_Control(pDX, IDC_EDIT_BK1, m_cBkCol1);
|
||
DDX_Control(pDX, IDC_EDIT_BK2, m_cBkCol2);
|
||
DDX_Control(pDX, IDC_EDIT_BK3, m_cBkCol3);
|
||
DDX_Control(pDX, IDC_EDIT_BK4, m_cBkCol4);
|
||
|
||
DDX_Check(pDX, IDC_SCREEN_MENU, m_bScreenMenu);//add by fxj 080925
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CScreenMenuPage, CAcUiTabChildDialog)
|
||
//{{AFX_MSG_MAP(CScreenMenuPage)
|
||
|
||
ON_BN_CLICKED(IDC_BUTTON_BK1, OnBkColor1)
|
||
ON_BN_CLICKED(IDC_BUTTON_BK2, OnBkColor2)
|
||
ON_BN_CLICKED(IDC_BUTTON_BK3, OnBkColor3)
|
||
ON_BN_CLICKED(IDC_BUTTON_BK4, OnBkColor4)
|
||
ON_BN_CLICKED(IDC_BUTTON_PREVIEW, OnButtonPreview)
|
||
ON_BN_CLICKED(IDC_BUTTON_DEFAULT, OnButtonDefault)
|
||
ON_BN_CLICKED(IDC_SCREEN_MENU, OnStnClickedMenu)
|
||
ON_MESSAGE(TARCH_SETTING_MSG_UPDATA,OnReUpdataDlg)
|
||
//}}AFX_MSG_MAP
|
||
ON_BN_CLICKED(IDC_RADIO1,OnBnClickedRadio1)
|
||
ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
|
||
ON_BN_CLICKED(IDC_SCROLL_BAR, OnBnClickedScrollBar)
|
||
ON_BN_CLICKED(IDC_OPEN_FIRST, OnBnClickedOpenFirst)
|
||
END_MESSAGE_MAP()
|
||
|
||
void CScreenMenuPage::OnStnClickedMenu()
|
||
{
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
void CScreenMenuPage::OnBnClickedRadio1()
|
||
{
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
|
||
void CScreenMenuPage::OnBnClickedRadio2()
|
||
{
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
|
||
void CScreenMenuPage::OnBnClickedScrollBar()
|
||
{
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
|
||
void CScreenMenuPage::OnBnClickedOpenFirst()
|
||
{
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
LRESULT CScreenMenuPage::OnReUpdataDlg(WPARAM w,LPARAM l)
|
||
{
|
||
SetDataToWin();
|
||
UpdateData(FALSE);
|
||
return 0;
|
||
}
|
||
|
||
BOOL CScreenMenuPage::OnInitDialog()
|
||
{
|
||
BOOL bRet=CAcUiTabChildDialog::OnInitDialog();
|
||
|
||
//只有TArch7有多个菜单系统
|
||
if (!(g_nProductId==kTARCH &&g_nVersion>6.9))
|
||
{
|
||
GetDlgItem(IDC_MENU_FILE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_STATIC_MENU)->ShowWindow(SW_HIDE);
|
||
}
|
||
|
||
return bRet;
|
||
}
|
||
void CScreenMenuPage::SetDataToWin()
|
||
{
|
||
if (g_bScreenMenu != m_bScreenMenu)
|
||
{
|
||
m_bScreenMenu = g_bScreenMenu;
|
||
}
|
||
|
||
if (g_bLimitHeight != m_bLimitHeight)
|
||
{
|
||
m_bLimitHeight = g_bLimitHeight;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_bScrollBar != m_bScrollBar)
|
||
{
|
||
m_bScrollBar = g_bScrollBar;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_bDefaultOpenFirst != m_bAutoOpenFirst)
|
||
{
|
||
m_bAutoOpenFirst = g_bDefaultOpenFirst;
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
if (g_iMenuType != m_iMenuType)
|
||
{
|
||
m_bModified = TRUE;
|
||
m_iMenuType = g_iMenuType;
|
||
}
|
||
|
||
if (g_menuColors[0] != m_cBkCol1.m_nMenuBKColor1)
|
||
{
|
||
m_cBkCol1.m_nMenuBKColor1 = g_menuColors[0];
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_menuColors[1] != m_cBkCol2.m_nMenuBKColor2)
|
||
{
|
||
m_cBkCol2.m_nMenuBKColor2 = g_menuColors[1];
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_menuColors[2] != m_cBkCol3.m_nMenuBKColor3)
|
||
{
|
||
m_cBkCol3.m_nMenuBKColor3 = g_menuColors[2];
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_menuColors[3] != m_cBkCol4.m_nMenuBKColor4)
|
||
{
|
||
|
||
m_cBkCol4.m_nMenuBKColor4 = g_menuColors[4];
|
||
m_bModified = TRUE;
|
||
}
|
||
int nTest = g_menuColors[2];
|
||
if (!m_bModified)
|
||
return;
|
||
|
||
if (g_nProductId==kTARCH && g_nVersion>6.9)
|
||
acedPostCommand(_T("tmnload\n"));
|
||
else
|
||
acedPostCommand(_T("tmnload1\n"));
|
||
}
|
||
void CScreenMenuPage::LoadMenu()
|
||
{
|
||
if (g_bScreenMenu != m_bScreenMenu)
|
||
{
|
||
g_bScreenMenu = m_bScreenMenu;
|
||
}
|
||
if (g_bLimitHeight != m_bLimitHeight)
|
||
{
|
||
g_bLimitHeight = m_bLimitHeight;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_bScrollBar != m_bScrollBar)
|
||
{
|
||
g_bScrollBar = m_bScrollBar;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_bDefaultOpenFirst != m_bAutoOpenFirst)
|
||
{
|
||
g_bDefaultOpenFirst = m_bAutoOpenFirst;
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
if (g_iMenuType != m_iMenuType)
|
||
{
|
||
m_bModified = TRUE;
|
||
g_iMenuType = m_iMenuType;
|
||
if (m_iMenuType == 2)
|
||
g_nRunMode = 1;
|
||
else
|
||
g_nRunMode = 0;
|
||
}
|
||
|
||
if (g_menuColors[0] != m_cBkCol1.m_nMenuBKColor1)
|
||
{
|
||
g_menuColors[0] = m_cBkCol1.m_nMenuBKColor1;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_menuColors[1] != m_cBkCol2.m_nMenuBKColor2)
|
||
{
|
||
g_menuColors[1] = m_cBkCol2.m_nMenuBKColor2;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_menuColors[2] != m_cBkCol3.m_nMenuBKColor3)
|
||
{
|
||
g_menuColors[2] = m_cBkCol3.m_nMenuBKColor3;
|
||
m_bModified = TRUE;
|
||
}
|
||
if (g_menuColors[3] != m_cBkCol4.m_nMenuBKColor4)
|
||
{
|
||
g_menuColors[4] = m_cBkCol4.m_nMenuBKColor4;
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
if (!m_bModified)
|
||
return;
|
||
|
||
if (g_nProductId==kTARCH && g_nVersion>6.9)
|
||
acedPostCommand(_T("tmnload\n"));
|
||
else
|
||
acedPostCommand(_T("tmnload1\n"));
|
||
}
|
||
//add by xlc on 071217
|
||
//恢复默认颜色
|
||
void CScreenMenuPage::OnButtonDefault()
|
||
{
|
||
m_bPreview = TRUE;
|
||
m_cBkCol1.m_nMenuBKColor1=14215660;
|
||
m_cBkCol2.m_nMenuBKColor2=15527919;
|
||
m_cBkCol3.m_nMenuBKColor3=16711418;
|
||
m_cBkCol4.m_nMenuBKColor4=16580607;
|
||
m_cBkCol1.Invalidate();
|
||
m_cBkCol2.Invalidate();
|
||
m_cBkCol3.Invalidate();
|
||
m_cBkCol4.Invalidate();
|
||
|
||
g_menuColors[0] = m_cBkCol1.m_nMenuBKColor1;
|
||
g_menuColors[1] = m_cBkCol2.m_nMenuBKColor2;
|
||
g_menuColors[2] = m_cBkCol3.m_nMenuBKColor3;
|
||
g_menuColors[4] = m_cBkCol4.m_nMenuBKColor4;
|
||
|
||
acedGetAcadFrame()->RedrawWindow(NULL,NULL,RDW_ALLCHILDREN|RDW_INVALIDATE);
|
||
}
|
||
|
||
void CScreenMenuPage::OnButtonPreview()
|
||
{
|
||
m_bPreview = TRUE;
|
||
g_menuColors[0] = m_cBkCol1.m_nMenuBKColor1;
|
||
g_menuColors[1] = m_cBkCol2.m_nMenuBKColor2;
|
||
g_menuColors[2] = m_cBkCol3.m_nMenuBKColor3;
|
||
g_menuColors[4] = m_cBkCol4.m_nMenuBKColor4;
|
||
|
||
acedGetAcadFrame()->RedrawWindow(NULL,NULL,RDW_ALLCHILDREN|RDW_INVALIDATE);
|
||
}
|
||
|
||
void CScreenMenuPage::OnBkColor1()
|
||
{
|
||
CColorDialog m_Dlg;
|
||
if (m_Dlg.DoModal() == IDOK)
|
||
{
|
||
m_cBkCol1.m_nMenuBKColor1 = m_Dlg.GetColor();
|
||
m_cBkCol1.SetWindowText(_T(""));
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
}
|
||
|
||
void CScreenMenuPage::OnBkColor2()
|
||
{
|
||
CColorDialog m_Dlg;
|
||
if (m_Dlg.DoModal() == IDOK)
|
||
{
|
||
m_cBkCol2.m_nMenuBKColor2 = m_Dlg.GetColor();
|
||
m_cBkCol2.SetWindowText(_T(""));
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
}
|
||
void CScreenMenuPage::OnBkColor3()
|
||
{
|
||
CColorDialog m_Dlg;
|
||
if (m_Dlg.DoModal() == IDOK)
|
||
{
|
||
m_cBkCol3.m_nMenuBKColor3 = m_Dlg.GetColor();
|
||
m_cBkCol3.SetWindowText(_T(""));
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
}
|
||
void CScreenMenuPage::OnBkColor4()
|
||
{
|
||
CColorDialog m_Dlg;
|
||
if (m_Dlg.DoModal() == IDOK)
|
||
{
|
||
m_cBkCol4.m_nMenuBKColor4 = m_Dlg.GetColor();
|
||
m_cBkCol4.SetWindowText(_T(""));
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
}
|
||
|
||
|
||
/////////////////////////////////////////////////
|
||
extern TKeyMapTable g_KeyMapTable;
|
||
// 把字符中间的空格处理成替换字符
|
||
CString ReplaceBlank(CString strItem);
|
||
|
||
// 把字符中间的替换字符处理成空格
|
||
CString ReplaceBlankBack(CString strItem);
|
||
|
||
BOOL TKeyMapTable::Key2Command(CString&sCommand)const
|
||
{
|
||
for(const TKeyMap* p=GetFirst();p!=NULL;p=GetNext(p))
|
||
if (p->sKey.CompareNoCase(sCommand)==0)
|
||
{
|
||
sCommand=p->sCommand;
|
||
return true;
|
||
}
|
||
return FALSE;
|
||
}
|
||
BOOL TKeyMapTable::ReadShortCutKey()
|
||
{
|
||
Clear();
|
||
XString fullFile;
|
||
if (!FindFile(_T("KeyMap.txt"), fullFile))
|
||
return FALSE;
|
||
|
||
CStdioFile file;
|
||
if (!file.Open(fullFile, CFile::modeRead))
|
||
return FALSE;
|
||
|
||
CString rString;
|
||
while(file.ReadString(rString))
|
||
{
|
||
TCHAR sKey[256] = _T("");
|
||
TCHAR sCommand[256] = _T("");
|
||
TCHAR sNote[256]= _T("");
|
||
CT_strnth(rString, 1, sKey);
|
||
CT_strnth(rString, 2, sCommand);
|
||
CT_strnth(rString, 3, sNote);
|
||
TKeyMap *pMap = new TKeyMap;
|
||
// pMap->sKey = sKey;
|
||
pMap->sKey = ReplaceBlankBack(sKey); // modify by lgh. 替换空格字符
|
||
pMap->sKey.MakeLower();
|
||
pMap->sKey = pMap->sKey.Left(1);
|
||
// pMap->sCommand = sCommand;
|
||
// pMap->sNote = sNote;
|
||
pMap->sCommand = ReplaceBlankBack(sCommand);
|
||
pMap->sNote = ReplaceBlankBack(sNote); // modify by lgh. 替换空格字符。
|
||
AddTail(*pMap);
|
||
}
|
||
file.Close();
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL TKeyMapTable::WriteShortCutKey()
|
||
{
|
||
XString fullFile;
|
||
if (!FindFile(_T("KeyMap.txt"), fullFile))
|
||
return FALSE;
|
||
|
||
CStdioFile file;
|
||
if (!file.Open(fullFile, CFile::modeWrite))
|
||
return FALSE;
|
||
file.SetLength(0);
|
||
file.Flush();
|
||
CString rString;
|
||
for(MoveToFirst(); !IsOut(); MoveToNext())
|
||
{
|
||
CString sKey = GetCurData().sKey;
|
||
CString sCommand = GetCurData().sCommand;
|
||
CString sNote = GetCurData().sNote;
|
||
|
||
rString.Format(_T("%s %s %s\n"),ReplaceBlank(sKey), ReplaceBlank(sCommand),ReplaceBlank(sNote));
|
||
file.WriteString(rString);
|
||
}
|
||
file.Close();
|
||
return TRUE;
|
||
}
|
||
|
||
//add by xlc on 071010
|
||
WDGridPgp::WDGridPgp():WDGrid(true)
|
||
{
|
||
|
||
}
|
||
#define ID_MENU_ADD_TREE 101
|
||
BEGIN_MESSAGE_MAP(WDGridPgp,WDGrid)
|
||
|
||
ON_COMMAND(ID_MENU_ADD_TREE, OnAddTree)
|
||
|
||
END_MESSAGE_MAP()
|
||
void WDGridPgp::OnAddTree()
|
||
{
|
||
WDGridTreeRow* curTree = CurTreeRow();
|
||
if (curTree == NULL)
|
||
{
|
||
if (!IsEditing())
|
||
DoAppendTree();
|
||
}
|
||
else
|
||
{
|
||
DoInsertTreeAfter();
|
||
}
|
||
|
||
}
|
||
bool WDGridPgp::OnBeforeInsertChild(WDGridTreeRow&row,long iChild,WDGridTreeRow*&pChild)
|
||
{
|
||
if (row.IsChildRow()||(pChild != NULL && pChild->IsParentRow()))
|
||
{
|
||
AfxMessageBox(_T("不允许在子行插入类别!"));
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
bool WDGridPgp::OnBeforeInsertRow(long i,WDGridRow*&pNewRow)
|
||
{
|
||
if (!(pNewRow != NULL && pNewRow->IsParentRow()))
|
||
{
|
||
AfxMessageBox(_T("不允许插入行!"));
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
void WDGridPgp::OnEndDeleteRow()
|
||
{
|
||
for(MoveToFirst(); !IsOut(); MoveToNext())
|
||
{
|
||
WDGridTreeRow* pRow = CurTreeRow();
|
||
|
||
bool bChild =pRow->IsChildRow();
|
||
bool bParent=pRow->IsParentRow();
|
||
|
||
if (!pRow->IsParentRow() && !bChild)
|
||
{
|
||
DelRow(pRow->GetIndex());
|
||
}
|
||
}
|
||
}
|
||
bool WDGridPgp::OnModified(WDGridCell&cell,CString &text)
|
||
{
|
||
if (cell.GetColIndex()!=0)
|
||
return true;
|
||
|
||
for(MoveToFirst(); !IsOut(); MoveToNext())
|
||
{
|
||
WDGridTreeRow* pRow = CurTreeRow();
|
||
|
||
if (pRow->IsParentRow())
|
||
{
|
||
CString strType = (*pRow)[0].GetText();
|
||
for(pRow->MoveToFirst(); !pRow->IsOut(); pRow->MoveToNext())
|
||
{
|
||
WDGridTreeRow *pChild = pRow->CurChild();
|
||
if (pChild->IsChildRow())
|
||
{
|
||
CString strKey = (*pChild)[0].GetText();
|
||
CString strName= (*pChild)[1].GetText();
|
||
|
||
if (strKey.CompareNoCase(text) == 0)
|
||
{
|
||
CString msg;
|
||
msg.Format(_T("与目录%s下的%s命令冲突,是否设置?"),strType,strName);
|
||
if (AfxMessageBox(msg,MB_OKCANCEL)!= IDOK)
|
||
{
|
||
text.Empty();
|
||
AutoEditCell();
|
||
}
|
||
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
bool WDGridPgp::OnBeforeEdit(WDGridCell&cell,bool &bModified)
|
||
{
|
||
WDGridRow &row = cell.GetRow();
|
||
if (row.IsParentRow())
|
||
{
|
||
int indexCol = cell.GetColIndex();
|
||
if (indexCol == 1)
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
bool WDGridPgp::OnCellButtonDown(WDGridCell&cell,CString&res)
|
||
{
|
||
if (cell.GetColIndex() == 1)
|
||
{
|
||
CString strItem=cell.GetText();
|
||
CAcModuleResourceOverride vTemp;
|
||
CCommandDlg dlg;
|
||
dlg.m_strCnName=strItem;
|
||
if (dlg.DoModal() == IDOK)
|
||
{
|
||
res = dlg.m_csCmd;
|
||
|
||
if (res.IsEmpty())
|
||
return false;
|
||
|
||
WDGridRow &row=cell.GetRow();
|
||
row[cell.GetColIndex()+1].SetText(dlg.m_strCnName);
|
||
row[cell.GetColIndex()+1].Refresh();
|
||
|
||
OnDataChanged();
|
||
AutoCloseCell(1);
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
|
||
}
|
||
void WDGridPgp::OnRClickRow(WDGridRow&row,CPoint point)
|
||
{
|
||
if (IsNoDefaultMenu()||IsReadOnly()||IsRowFixLength())
|
||
return;
|
||
|
||
CMenu popup;
|
||
popup.CreatePopupMenu();
|
||
|
||
if (GetRowSelNum() > 1 && IsRowSelected(row.GetIndex()))
|
||
{
|
||
popup.AppendMenu(MF_STRING, ID_WDGRID_DEL_ROW, _T("删除(Del)"));
|
||
}
|
||
else
|
||
{
|
||
UnSelect();
|
||
SelectRow(row.GetIndex(), true);
|
||
if (row.IsParentRow())
|
||
popup.AppendMenu(MF_STRING, ID_MENU_ADD_TREE, _T("插入类别"));
|
||
else
|
||
popup.AppendMenu(MF_STRING, ID_WDGRID_INS_ROW, _T("插入行(Ins)"));
|
||
|
||
popup.AppendMenu(MF_STRING, ID_WDGRID_DEL_ROW, _T("删除行(Del)"));
|
||
}
|
||
|
||
popup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
|
||
}
|
||
|
||
|
||
/////////////////////////////////////////////////
|
||
//CShortCutKeyPage 对话框
|
||
|
||
IMPLEMENT_DYNAMIC(CShortCutKeyPage, CAcUiTabChildDialog)
|
||
CShortCutKeyPage::CShortCutKeyPage(CWnd* pParent)
|
||
: CAcUiTabChildDialog(pParent)
|
||
{
|
||
m_bEnable=g_bEnableShortCut;
|
||
m_bChecked = FALSE;
|
||
m_nRaidoTg = 0;
|
||
|
||
CodeBase db;
|
||
XString xsDbfFile;
|
||
if (!FindFile(_T("tchdata.dbf"), xsDbfFile))
|
||
{
|
||
MessageBox(_T("对不起,没有发现tchdata.dbf文件!"));
|
||
return;
|
||
}
|
||
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
int iHit;
|
||
XDbfTable *pTable = db.Open(xsDbfFile);
|
||
if (pTable)
|
||
{
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF())
|
||
{
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
GET_FIELD(pTable, _T("engcmd"), csCmd);
|
||
GET_FIELD(pTable, _T("explain"), csDescribe);
|
||
GET_FIELD(pTable, _T("icon"), csIcon);
|
||
GET_FIELD(pTable, _T("flag"), iHit);
|
||
GET_FIELD(pTable, _T("type"), csType);
|
||
m_lstToolbarData.Append(new CToolbarData(csType, csCmd, csName, csDescribe, csIcon, iHit));
|
||
pTable->MoveNext();
|
||
}
|
||
pTable->Close();
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
void CShortCutKeyPage::DoDataExchange(CDataExchange*pDX)
|
||
{
|
||
CAcUiTabChildDialog::DoDataExchange(pDX);
|
||
DDX_Check(pDX,IDC_ENABLE,m_bEnable);
|
||
DDX_Radio(pDX, IDC_RADIO_TG, m_nRaidoTg);
|
||
}
|
||
|
||
BEGIN_MESSAGE_MAP(CShortCutKeyPage, CAcUiTabChildDialog)
|
||
//{{AFX_MSG_MAP(CShortCutKeyPage)
|
||
ON_BN_CLICKED(IDC_RADIO_TG, OnRadioTG)
|
||
ON_BN_CLICKED(IDC_RADIO_ACAD, OnRadioACAD)
|
||
ON_BN_CLICKED(IDC_BUTTON_TREE, OnButtonTree)
|
||
ON_BN_CLICKED(IDC_BUTTON_ROW, OnButtonRow)
|
||
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
|
||
ON_MESSAGE(TARCH_SETTING_MSG_UPDATA,OnReUpdataDlg)
|
||
ON_MESSAGE(TARCH_SETTING_MSG_BUTTONSTATION,OnUpdataApplyButton)
|
||
//}}AFX_MSG_MAP
|
||
ON_BN_CLICKED(IDC_ENABLE, CShortCutKeyPage::OnBnClickedEnable)
|
||
END_MESSAGE_MAP()
|
||
//
|
||
LRESULT CShortCutKeyPage::OnUpdataApplyButton(WPARAM w,LPARAM l)
|
||
{
|
||
m_bChecked = TRUE;
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
return 0;
|
||
}
|
||
// CShortCutKeyPage 消息处理程序
|
||
LRESULT CShortCutKeyPage::OnReUpdataDlg(WPARAM w,LPARAM l)
|
||
{
|
||
|
||
//InitGrid();
|
||
m_grid.Clear();
|
||
//m_grid.AppendCol(_T("快捷键"),60);
|
||
//m_grid.AppendCol(_T("命令名"), 120);
|
||
//m_grid.AppendCol(_T("备注"));
|
||
m_grid.SetColPosFix();
|
||
m_grid.SetColFixLength();
|
||
m_grid.SetNoPaste();
|
||
//m_grid.Create(this, IDC_LIST);
|
||
m_grid.FitLastCol();
|
||
m_grid.GetCol(1).SetRightButton();
|
||
long i = 0;
|
||
for(g_KeyMapTable.MoveToFirst(); !g_KeyMapTable.IsOut(); g_KeyMapTable.MoveToNext())
|
||
{
|
||
TKeyMap *pMap = &g_KeyMapTable.GetCurData();
|
||
m_grid.AppendRow();
|
||
m_grid.GetCell(i, 0).SetText(pMap->sKey);
|
||
m_grid.GetCell(i, 1).SetText(pMap->sCommand);
|
||
m_grid.GetCell(i, 2).SetText(pMap->sNote);
|
||
i++;
|
||
}
|
||
m_bEnable = g_bEnableShortCut;
|
||
if (m_nRaidoTg == 0)
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_HIDE);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_SHOW);
|
||
}
|
||
//add by xlc on 070924
|
||
//InitGridTree();
|
||
m_treePgp.Clear();
|
||
m_treePgp.GetCol(1).SetRightButton();
|
||
m_treePgp.GetCol(2).SetReadOnly(TRUE);
|
||
m_treePgp.SetColPosFix();
|
||
m_treePgp.SetColFixLength();
|
||
m_treePgp.SetNoPaste(); //禁止粘贴操作
|
||
m_treePgp.SetNoAppendButton(); //没有append button
|
||
//m_treePgp.Create(this, IDC_LIST_PGP);
|
||
m_treePgp.FitLastCol();
|
||
ReadPgp();
|
||
UpdateData(FALSE);
|
||
return 0;
|
||
}
|
||
BOOL CShortCutKeyPage::OnInitDialog()
|
||
{
|
||
CAcUiTabChildDialog::OnInitDialog();
|
||
InitGrid();
|
||
|
||
//add by xlc on 070924
|
||
InitGridTree();
|
||
if (m_nRaidoTg == 0)
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_HIDE);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_SHOW);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
//add by xlc on 070924
|
||
void CShortCutKeyPage::InitGridTree()
|
||
{
|
||
m_treePgp.Clear();
|
||
m_treePgp.AppendCol(_T("快捷键"),160);
|
||
m_treePgp.AppendCol(_T("命令名"), 160);
|
||
m_treePgp.AppendCol(_T("备注"), 160);
|
||
m_treePgp.GetCol(1).SetRightButton();
|
||
m_treePgp.GetCol(2).SetReadOnly(TRUE);
|
||
m_treePgp.SetColPosFix();
|
||
m_treePgp.SetColFixLength();
|
||
m_treePgp.SetNoPaste(); //禁止粘贴操作
|
||
m_treePgp.SetNoAppendButton(); //没有append button
|
||
m_treePgp.Create(this, IDC_LIST_PGP);
|
||
m_treePgp.FitLastCol();
|
||
|
||
ReadPgp();
|
||
}
|
||
|
||
void CShortCutKeyPage::InitGrid()
|
||
{
|
||
m_grid.Clear();
|
||
m_grid.AppendCol(_T("快捷键"),60);
|
||
m_grid.AppendCol(_T("命令名"), 120);
|
||
m_grid.AppendCol(_T("备注"));
|
||
m_grid.SetColPosFix();
|
||
m_grid.SetColFixLength();
|
||
m_grid.SetNoPaste();
|
||
m_grid.Create(this, IDC_LIST);
|
||
m_grid.FitLastCol();
|
||
|
||
//add by xlc on 070924
|
||
m_grid.GetCol(1).SetRightButton();
|
||
|
||
long i = 0;
|
||
for(g_KeyMapTable.MoveToFirst(); !g_KeyMapTable.IsOut(); g_KeyMapTable.MoveToNext())
|
||
{
|
||
TKeyMap *pMap = &g_KeyMapTable.GetCurData();
|
||
m_grid.AppendRow();
|
||
m_grid.GetCell(i, 0).SetText(pMap->sKey);
|
||
m_grid.GetCell(i, 1).SetText(pMap->sCommand);
|
||
m_grid.GetCell(i, 2).SetText(pMap->sNote);
|
||
i++;
|
||
}
|
||
if (m_nRaidoTg == 0)
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_HIDE);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_SHOW);
|
||
}
|
||
}
|
||
//void CShortCutKeyPage::UpdateGrid(const CXMLNodeInfoEx &nodeInfo)
|
||
//{
|
||
// m_grid.Clear();
|
||
// /*m_grid.AppendCol(_T("快捷键"),60);
|
||
// m_grid.AppendCol(_T("命令名"), 120);
|
||
// m_grid.AppendCol(_T("备注"));
|
||
// m_grid.SetColPosFix();
|
||
// m_grid.SetColFixLength();
|
||
// m_grid.SetNoPaste();
|
||
// m_grid.Create(this, IDC_LIST);
|
||
// m_grid.FitLastCol();
|
||
// m_grid.GetCol(1).SetRightButton();*/
|
||
// //m_grid.SetModify(true);
|
||
// CStringArray aryStrCmd,aryStrComment,aryStrValue;
|
||
// if (nodeInfo.m_aryNodeAttribute.GetLength()>=3)
|
||
// {
|
||
// DevideStr(nodeInfo.m_aryNodeAttribute.GetAt(1).second,aryStrCmd);
|
||
// DevideStr(nodeInfo.m_aryNodeAttribute.GetAt(2).second,aryStrComment);
|
||
// DevideStr(nodeInfo.m_strNodeValue,aryStrValue);
|
||
// int nLen = aryStrCmd.GetSize();
|
||
// int i=0;
|
||
// for (i=0;i<nLen;i++)
|
||
// {
|
||
// m_grid.AppendRow();
|
||
// m_grid.GetCell(i, 0).SetText(aryStrValue.GetAt(i));
|
||
// m_grid.GetCell(i, 1).SetText(aryStrCmd.GetAt(i));
|
||
// m_grid.GetCell(i, 2).SetText(aryStrComment.GetAt(i));
|
||
// }
|
||
// }
|
||
// if (m_nRaidoTg == 0)
|
||
// {
|
||
// GetDlgItem(IDC_ENABLE)->ShowWindow(SW_SHOW);
|
||
// GetDlgItem(IDC_LIST)->ShowWindow(SW_SHOW);
|
||
// GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_HIDE);
|
||
// GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_HIDE);
|
||
// GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_HIDE);
|
||
// GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_HIDE);
|
||
// }
|
||
// else
|
||
// {
|
||
// GetDlgItem(IDC_ENABLE)->ShowWindow(SW_HIDE);
|
||
// GetDlgItem(IDC_LIST)->ShowWindow(SW_HIDE);
|
||
// GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_SHOW);
|
||
// GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_SHOW);
|
||
// GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_SHOW);
|
||
// GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_SHOW);
|
||
// }
|
||
//}
|
||
//void CShortCutKeyPage::DevideStr(const CString &str,CStringArray &aryStr)
|
||
//{
|
||
// CString strTem;
|
||
// int nPos = str.Find(_T(" "),0);
|
||
// int nStart = 0;
|
||
// while (nPos!=-1)
|
||
// {
|
||
// int nNum = nPos-nStart;
|
||
// strTem = str.Mid(nStart,nNum);
|
||
// aryStr.Add(strTem);
|
||
// nStart = nPos+1;
|
||
// nPos = str.Find(_T(" "),nPos+1);
|
||
// }
|
||
// int nSize = str.GetLength();
|
||
// if (nStart-1<nSize-1)
|
||
// {
|
||
// strTem = str.Mid(nStart,nSize-nStart);
|
||
// aryStr.Add(strTem);
|
||
// }
|
||
//}
|
||
void CShortCutKeyPage::ApplyShortCutKey()
|
||
{
|
||
UpdateData(TRUE);
|
||
g_bEnableShortCut=m_bEnable;
|
||
if (!m_grid.IsModified())
|
||
return;
|
||
|
||
g_KeyMapTable.Clear();
|
||
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext())
|
||
{
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
TKeyMap *pMap = new TKeyMap;
|
||
pMap->sKey = (*pRow)[0];
|
||
pMap->sCommand = (*pRow)[1];
|
||
pMap->sNote =(*pRow)[2];
|
||
g_KeyMapTable.AddTail(*pMap);
|
||
delete pMap;//zzg
|
||
}
|
||
g_KeyMapTable.WriteShortCutKey();
|
||
}
|
||
void CShortCutKeyPage::WriteShortCutKey()
|
||
{
|
||
g_bEnableShortCut=m_bEnable;
|
||
|
||
//modified by xlc on 071011
|
||
if (!m_grid.IsModified())
|
||
return;
|
||
|
||
g_KeyMapTable.Clear();
|
||
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext())
|
||
{
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
TKeyMap *pMap = new TKeyMap;
|
||
pMap->sKey = (*pRow)[0];
|
||
pMap->sCommand = (*pRow)[1];
|
||
pMap->sNote =(*pRow)[2];
|
||
g_KeyMapTable.AddTail(*pMap);
|
||
delete pMap;//zzg
|
||
}
|
||
g_KeyMapTable.WriteShortCutKey();
|
||
}
|
||
|
||
//add by xlc on 070926
|
||
void CShortCutKeyPage::OnRadioTG()
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_HIDE);
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
|
||
//add by xlc on 070926
|
||
void CShortCutKeyPage::OnRadioACAD()
|
||
{
|
||
GetDlgItem(IDC_ENABLE)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_LIST_PGP)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_TREE)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_ROW)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_BUTTON_DEL)->ShowWindow(SW_SHOW);
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
void CShortCutKeyPage::OnBnClickedEnable()
|
||
{
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
//add by xlc on 071010
|
||
void CShortCutKeyPage::OnButtonTree()
|
||
{
|
||
WDGridTreeRow* curTree = m_treePgp.CurTreeRow();
|
||
if (curTree == NULL)
|
||
{
|
||
if (!m_treePgp.IsEditing())
|
||
m_treePgp.DoAppendTree();
|
||
}
|
||
else
|
||
{
|
||
m_treePgp.DoInsertTreeAfter();
|
||
}
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
|
||
//add by xlc on 071010
|
||
void CShortCutKeyPage::OnButtonRow()
|
||
{
|
||
WDGridTreeRow* curTree = m_treePgp.CurTreeRow();
|
||
if (curTree == NULL)
|
||
{
|
||
if (!m_treePgp.IsEditing())
|
||
m_treePgp.DoAppendChild();
|
||
else
|
||
{
|
||
AfxMessageBox(_T("没有指定插入位置!"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (curTree->IsChildRow())
|
||
{
|
||
m_treePgp.DoInsertRowAfter();
|
||
}
|
||
else if (curTree->IsParentRow())
|
||
{
|
||
m_treePgp.DoAppendChild();
|
||
}
|
||
}
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
//add by xlc on 071010
|
||
void CShortCutKeyPage::OnButtonDel()
|
||
{
|
||
m_treePgp.DoDelete();
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
}
|
||
void CShortCutKeyPage::UpdateShortCutKeyPage()
|
||
{
|
||
UpdateData(FALSE);
|
||
}
|
||
|
||
//add by xlc on 071008
|
||
void CShortCutKeyPage::ReadPgp()
|
||
{
|
||
if (!FindFile(_T("acad.pgp"), m_xsAcadPgp))
|
||
{
|
||
MessageBox(_T("对不起,没有发现acad.pgp文件!"));
|
||
return;
|
||
}
|
||
CStdioFile file;
|
||
if (!file.Open(m_xsAcadPgp, CFile::modeRead))
|
||
{
|
||
AfxMessageBox(CString(_T("打开文件 \"")) + m_xsAcadPgp + _T("\" 失败"));
|
||
return ;
|
||
}
|
||
|
||
m_strNoteArray.RemoveAll();
|
||
CString sString;
|
||
BOOL bFirst = TRUE;
|
||
while(file.ReadString(sString))
|
||
{
|
||
TCHAR sKey[256] = _T("");
|
||
TCHAR sName[256] = _T("");
|
||
|
||
if (sString[0])
|
||
{
|
||
if (sString[0] == _T(';') && sString[1] == _T(';'))
|
||
{
|
||
WDGridTreeRow *pRow = new WDGridTreeRow(m_treePgp);
|
||
(*pRow)[0].SetText(sString.Right(sString.GetLength()-2));
|
||
m_treePgp.AppendRow(pRow);
|
||
|
||
bFirst = FALSE;
|
||
}
|
||
else if (sString[0] != _T(';'))
|
||
{
|
||
if (sString.Find(_T("*")) == -1 ||sString.Find(_T(":")) != -1)
|
||
{
|
||
m_strNoteArray.Add(sString);
|
||
continue;
|
||
}
|
||
|
||
//add by xlc on 071105 如果没有类别时添加缺省类别
|
||
if (bFirst)
|
||
{
|
||
WDGridTreeRow *pRow = new WDGridTreeRow(m_treePgp);
|
||
(*pRow)[0].SetText(_T("ACAD"));
|
||
m_treePgp.AppendRow(pRow);
|
||
|
||
bFirst = FALSE;
|
||
}
|
||
|
||
CString str = sString,strType,strCmd,strNote;
|
||
strType = sString.Left(sString.Find(_T(",")));
|
||
|
||
//add by xlc on 090921 解决pgp文件中有中文逗号退出的问题
|
||
if (strType.IsEmpty())
|
||
{
|
||
strType = sString.Left(sString.Find(_T(",")));
|
||
}
|
||
|
||
strCmd = str.Right(str.GetLength()-str.Find(_T("*"))-1);
|
||
|
||
for(int i = 0; i < m_lstToolbarData.Length(); i++)
|
||
{
|
||
if (strCmd.CompareNoCase(m_lstToolbarData[i]->m_csCmd)==0)
|
||
{
|
||
strNote = m_lstToolbarData[i]->m_csName;
|
||
break;
|
||
}
|
||
}
|
||
|
||
WDGridTreeRow *pRow = new WDGridTreeRow(m_treePgp);
|
||
WDGridTreeRow *pTreeRow = m_treePgp.CurTreeRow();
|
||
if (!(strCmd.IsEmpty()||strType.IsEmpty()))
|
||
{
|
||
(*pRow)[0].SetText(strType);
|
||
(*pRow)[1].SetText(strCmd);
|
||
(*pRow)[2].SetText(strNote);
|
||
|
||
if (pTreeRow)
|
||
{
|
||
pTreeRow->AppendChild(pRow);
|
||
}
|
||
else
|
||
{
|
||
m_treePgp.AppendRow(pRow);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_strNoteArray.Add(sString);
|
||
}
|
||
|
||
}
|
||
}
|
||
file.Close();
|
||
}
|
||
void CShortCutKeyPage::OnOK()
|
||
{
|
||
//WriteShortCutKey();
|
||
//WritePgp();
|
||
}
|
||
//add by xlc on 071008
|
||
void CShortCutKeyPage::WritePgp()
|
||
{
|
||
if (!m_treePgp.IsModified())
|
||
return;
|
||
|
||
FILE *fp2 = _tfopen(m_xsAcadPgp, _T("w"));
|
||
if (!fp2)
|
||
return;
|
||
|
||
//输出注释
|
||
for(int i = 0; i < m_strNoteArray.GetSize(); i++)
|
||
{
|
||
_fputts(_T("\n"), fp2);
|
||
_fputts(m_strNoteArray[i], fp2);
|
||
}
|
||
|
||
//输出类别和命令
|
||
for(m_treePgp.MoveToFirst(); !m_treePgp.IsOut(); m_treePgp.MoveToNext())
|
||
{
|
||
WDGridTreeRow* pRow = m_treePgp.CurTreeRow();
|
||
if (pRow->IsParentRow())
|
||
{
|
||
CString strTmp = _T("\n\n;;");
|
||
strTmp += (*pRow)[0].GetText();
|
||
_fputts(strTmp, fp2);
|
||
|
||
for(pRow->MoveToFirst(); !pRow->IsOut(); pRow->MoveToNext())
|
||
{
|
||
WDGridTreeRow *pChild = pRow->CurChild();
|
||
if (pChild->IsChildRow())
|
||
{
|
||
CString strKey = (*pChild)[0].GetText();
|
||
CString strName= (*pChild)[1].GetText();
|
||
CString csTmp = _T("\n")+strKey+_T(", *")+strName;
|
||
|
||
if (!(strKey.IsEmpty() || strName.IsEmpty()))
|
||
_fputts(csTmp, fp2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
fclose(fp2);
|
||
|
||
AfxMessageBox(CString(_T("文件 \"")) + m_xsAcadPgp + _T("\" 已修改,必须重新启动上华软件或\n在命令行输入reinit重新初始化PGP改动才能生效!"));
|
||
}
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CSetToolbarPage PropertyPage
|
||
|
||
IMPLEMENT_DYNAMIC(CSetToolbarPage, CAcUiTabChildDialog)
|
||
CSetToolbarPage::CSetToolbarPage(CWnd* pParent)
|
||
: CAcUiTabChildDialog(pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(CSetToolbarPage)
|
||
m_bChecked = FALSE;
|
||
m_iType = -1;
|
||
m_csAlias = _T("");
|
||
m_csCmd = _T("");
|
||
//}}AFX_DATA_INIT
|
||
m_bInit = FALSE;
|
||
m_bModifyAlias = FALSE;
|
||
m_bDragging = FALSE;
|
||
m_bModified = FALSE;
|
||
CodeBase db;
|
||
|
||
if (!FindFile(_T("tchdata.dbf"), m_xsDbfFile)) {
|
||
MessageBox(_T("对不起,没有发现tchdata.dbf文件!"));
|
||
return;
|
||
}
|
||
if (!FindFile(_T("TCH.DLL"), m_xsDllFile)) {
|
||
MessageBox(_T("对不起,没有发现TCH.DLL文件!"));
|
||
return;
|
||
}
|
||
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
int iHit;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable) {
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
GET_FIELD(pTable, _T("engcmd"), csCmd);
|
||
GET_FIELD(pTable, _T("explain"), csDescribe);
|
||
GET_FIELD(pTable, _T("icon"), csIcon);
|
||
GET_FIELD(pTable, _T("flag"), iHit);
|
||
GET_FIELD(pTable, _T("type"), csType);
|
||
m_lstToolbarData.Append(new CToolbarData(csType, csCmd, csName, csDescribe, csIcon, iHit));
|
||
if (m_lstType.Index(csType) < 0)
|
||
m_lstType.Append(tstrnew(csType));
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else{
|
||
return;
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
m_bInit = TRUE;
|
||
|
||
//zzg
|
||
}
|
||
|
||
|
||
|
||
void CSetToolbarPage::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CAcUiTabChildDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CSetToolbarPage)
|
||
DDX_Control(pDX, IDC_BUTTON_HELP, m_butHelp);
|
||
DDX_Control(pDX, IDC_LIST_TOOLBAR, m_listToolbar);
|
||
DDX_Control(pDX, IDC_LIST_MENU, m_listMenu);
|
||
DDX_Control(pDX, IDC_COMBO_MENUTYPE, m_comboType);
|
||
DDX_CBIndex(pDX, IDC_COMBO_MENUTYPE, m_iType);
|
||
DDX_Text(pDX, IDC_EDIT_ALIAS, m_csAlias);
|
||
DDX_Text(pDX, IDC_EDIT_CMD, m_csCmd);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CSetToolbarPage, CAcUiTabChildDialog)
|
||
//{{AFX_MSG_MAP(CSetToolbarPage)
|
||
ON_BN_CLICKED(IDC_BUT_ADD, OnButAdd)
|
||
ON_BN_CLICKED(IDC_BUT_REMOVE, OnButRemove)
|
||
ON_CBN_SELCHANGE(IDC_COMBO_MENUTYPE, OnSelchangeComboType)
|
||
ON_NOTIFY(NM_DBLCLK, IDC_LIST_MENU, OnDblclkListMenu)
|
||
ON_NOTIFY(NM_DBLCLK, IDC_LIST_TOOLBAR, OnDblclkListToolbar)
|
||
ON_BN_CLICKED(IDC_BUTTON_UP, OnButtonUp)
|
||
ON_BN_CLICKED(IDC_BUTTON_DOWN, OnButtonDown)
|
||
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_MENU, OnItemchangedListMenu)
|
||
ON_BN_CLICKED(IDC_BUT_MODIFY, OnButModify)
|
||
ON_WM_CLOSE()
|
||
ON_WM_DESTROY()
|
||
//add by xlc on 071015
|
||
ON_WM_QUERYDRAGICON()
|
||
ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST_TOOLBAR, OnBegindragList)
|
||
ON_WM_LBUTTONUP()
|
||
ON_WM_MOUSEMOVE()
|
||
ON_MESSAGE(TARCH_SETTING_MSG_UPDATA,OnReUpdataDlg)
|
||
ON_MESSAGE(TARCH_SETTING_MSG_BUTTONOK,OnReOK)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
void CSetToolbarPage::OnDestroy()
|
||
{
|
||
//add by xlc on 090804 cancel时不保存数据
|
||
if (g_bCancel)
|
||
{
|
||
CAcUiTabChildDialog::OnNcDestroy();
|
||
return;
|
||
}
|
||
|
||
CodeBase db;
|
||
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable) {
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
int len = m_listToolbar.GetItemCount();
|
||
int iHit(0);
|
||
for(int i=0;i<len;i++){
|
||
CString csSel = m_listToolbar.GetItemText(i, 0);
|
||
if (csName.CompareNoCase(csSel)==0){
|
||
iHit = i+2;
|
||
break;
|
||
}
|
||
}
|
||
SET_FIELD(pTable, _T("flag"), iHit);
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else
|
||
MessageBox(_T("未能成功写入tchdata.dbf文件!"));
|
||
CAcUiTabChildDialog::OnNcDestroy();
|
||
}
|
||
LRESULT CSetToolbarPage::OnReOK(WPARAM w,LPARAM l)
|
||
{
|
||
//OnOK();
|
||
return 0;
|
||
}
|
||
// CSetToolbarPage message handlers
|
||
LRESULT CSetToolbarPage::OnReUpdataDlg(WPARAM w,LPARAM l)
|
||
{
|
||
CodeBase db;
|
||
m_lstToolbarData.Reset();
|
||
//m_lstType.Reset();
|
||
if (!FindFile(_T("tchdata.dbf"), m_xsDbfFile)) {
|
||
MessageBox(_T("对不起,没有发现tchdata.dbf文件!"));
|
||
return 0;
|
||
}
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
int iHit;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable) {
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
GET_FIELD(pTable, _T("engcmd"), csCmd);
|
||
GET_FIELD(pTable, _T("explain"), csDescribe);
|
||
GET_FIELD(pTable, _T("icon"), csIcon);
|
||
GET_FIELD(pTable, _T("flag"), iHit);
|
||
GET_FIELD(pTable, _T("type"), csType);
|
||
m_lstToolbarData.Append(new CToolbarData(csType, csCmd, csName, csDescribe, csIcon, iHit));
|
||
//if (m_lstType.Index(csType) < 0)
|
||
// m_lstType.Append(tstrnew(csType));
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else{
|
||
return 0;
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
m_bInit = TRUE;
|
||
ResetListToolbar();
|
||
UpdateData(FALSE);
|
||
return 0;
|
||
}
|
||
BOOL CSetToolbarPage::OnInitDialog()
|
||
{
|
||
CAcUiTabChildDialog::OnInitDialog();
|
||
//m_butHelp.SetIcon(IDI_HELP);
|
||
m_butHelp.SetHelpKey(_T("工具条"));
|
||
int len = m_lstType.Length();
|
||
for(int i=0;i<len;i++)
|
||
m_comboType.AddString(m_lstType[i]);
|
||
|
||
// sg modify 101101,解决了类似结构专业等,不需要工具条,tchdata.dbf文件中无内容,而产生的崩溃问题
|
||
// m_iType = 0;
|
||
if (len > 0)
|
||
{
|
||
m_iType = 0;
|
||
}
|
||
|
||
ReReadFile();
|
||
ResetListMenu();
|
||
ResetListToolbar();
|
||
UpdateData(FALSE);
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
void CSetToolbarPage::OnButAdd()
|
||
{
|
||
UpdateData(TRUE);
|
||
int nSel = m_listMenu.GetSelectionMark();
|
||
if (nSel < 0)
|
||
return;
|
||
CString csSel = m_listMenu.GetItemText(nSel, 0);
|
||
TCHAR szSel[32];
|
||
CT_strnth(csSel, 1, szSel);
|
||
csSel = szSel;
|
||
int len = m_listToolbar.GetItemCount();
|
||
for(int i=0;i<len;i++){
|
||
CString csTmp = m_listToolbar.GetItemText(i, 0);
|
||
if (csTmp.CompareNoCase(csSel)==0)
|
||
{
|
||
// MessageBox(_T("列表中已存在!"));
|
||
return;
|
||
}
|
||
}
|
||
if (len == 0)
|
||
len = 1;
|
||
HINSTANCE hInstance = LoadLibrary(m_xsDllFile);
|
||
int count = m_lstToolbarData.Length();
|
||
CString csImage;
|
||
HBITMAP hBitmap = NULL;
|
||
for(int j=0;j<count;j++){
|
||
if (csSel.CompareNoCase(m_lstToolbarData[j]->m_csName)==0)
|
||
{
|
||
csImage = m_lstToolbarData[j]->m_csIcon;
|
||
hBitmap = LoadBitmap(hInstance, csImage);
|
||
m_lstToolbarData[j]->m_iHit = len+2;
|
||
if (hBitmap){
|
||
CBitmap bitmap;
|
||
bitmap.Attach(hBitmap);
|
||
m_imageToolbar.Add(&bitmap, RGB(192, 192, 192));
|
||
}
|
||
}
|
||
}
|
||
|
||
TCHAR strText[64];
|
||
_tcscpy(strText, csSel);
|
||
LV_ITEM listItem;
|
||
listItem.mask = LVIF_TEXT | LVIF_IMAGE;
|
||
listItem.iSubItem = 0;
|
||
listItem.iItem = len;
|
||
listItem.pszText = strText;
|
||
listItem.iImage = m_imageToolbar.GetImageCount()-1;
|
||
m_listToolbar.InsertItem( &listItem );
|
||
|
||
//add by xlc on 071016
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
m_bModified = TRUE;
|
||
}
|
||
void CSetToolbarPage::RemoveIten(int nIndex)
|
||
{
|
||
if (nIndex < 0)
|
||
return;
|
||
CString csSel = m_listToolbar.GetItemText(nIndex, 0);
|
||
m_listToolbar.DeleteItem(nIndex);
|
||
int len = m_lstToolbarData.Length();
|
||
for(int j=0;j<len;j++)
|
||
{
|
||
if (csSel.CompareNoCase( m_lstToolbarData[j]->m_csName)==0)
|
||
{
|
||
m_lstToolbarData[j]->m_iHit = 0;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
void CSetToolbarPage::OnButRemove()
|
||
{
|
||
UpdateData(TRUE);
|
||
POSITION pos = m_listToolbar.GetFirstSelectedItemPosition();
|
||
Array<int> aryInDex;
|
||
while (pos)
|
||
{
|
||
int nIndex = m_listToolbar.GetNextSelectedItem(pos);
|
||
aryInDex.AddTail(nIndex);
|
||
//RemoveIten(nIndex);
|
||
}
|
||
aryInDex.Reverse();
|
||
int i=0;
|
||
for (i=0;i<aryInDex.GetLength();i++)
|
||
{
|
||
int nIndex = aryInDex.GetAt(i);
|
||
RemoveIten(nIndex);
|
||
}
|
||
int nSel = m_listToolbar.GetSelectionMark();
|
||
/*if (nSel < 0)
|
||
return;
|
||
CString csSel = m_listToolbar.GetItemText(nSel, 0);
|
||
m_listToolbar.DeleteItem(nSel);
|
||
int len = m_lstToolbarData.Length();
|
||
for(int j=0;j<len;j++){
|
||
if (csSel == m_lstToolbarData[j]->m_csName){
|
||
m_lstToolbarData[j]->m_iHit = 0;
|
||
break;
|
||
}
|
||
}*/
|
||
|
||
//modify by xlc on 080310
|
||
int len = m_lstToolbarData.Length();
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
ResetListToolbar();
|
||
int index=0;
|
||
if (nSel < len-1)
|
||
{
|
||
index = nSel;
|
||
}
|
||
else if (nSel = len-1)
|
||
{
|
||
index = nSel-1;
|
||
}
|
||
m_listToolbar.SetItemState(index, LVIS_SELECTED, LVIS_SELECTED);
|
||
m_listToolbar.SetSelectionMark(index);
|
||
m_listToolbar.EnsureVisible(index, TRUE);
|
||
m_listToolbar.SetFocus();
|
||
|
||
//add by xlc on 071016
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
void CSetToolbarPage::ReReadFile()
|
||
{
|
||
m_lstToolbarData.Reset();
|
||
CodeBase db;
|
||
XString fullFile;
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
BOOL bIsHit;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable) {
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
GET_FIELD(pTable, _T("engcmd"), csCmd);
|
||
GET_FIELD(pTable, _T("explain"), csDescribe);
|
||
GET_FIELD(pTable, _T("icon"), csIcon);
|
||
GET_FIELD(pTable, _T("flag"), bIsHit);
|
||
GET_FIELD(pTable, _T("type"), csType);
|
||
m_lstToolbarData.Append(new CToolbarData(csType, csCmd, csName, csDescribe, csIcon, bIsHit));
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else{
|
||
return;
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
}
|
||
void CSetToolbarPage::UpdateListTooBar(const CStringArray& aryStrName)
|
||
{
|
||
int nLen = m_lstToolbarData.Length();
|
||
int i=0;
|
||
for (i=0;i<nLen;i++)
|
||
{
|
||
CToolbarData *pData = m_lstToolbarData[i];
|
||
pData->m_iHit = 0;
|
||
}
|
||
// Zyu modify on 100722,支持64位
|
||
//int nNum = aryStrName.GetSize();
|
||
INT_PTR nNum = aryStrName.GetSize();
|
||
int j=0;
|
||
for (j=0;j<nNum;j++)
|
||
{
|
||
CString strTem = aryStrName.GetAt(j);
|
||
int nLen = m_lstToolbarData.Length();
|
||
int i=0;
|
||
for (i=0;i<nLen;i++)
|
||
{
|
||
CToolbarData *pData = m_lstToolbarData[i];
|
||
CString strName = pData->m_csName;
|
||
if (strName.CompareNoCase(strTem)==0)
|
||
{
|
||
pData->m_iHit = j+2;
|
||
}
|
||
}
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
ResetListToolbar();
|
||
}
|
||
void CSetToolbarPage::OnSelchangeComboType()
|
||
{
|
||
UpdateData(TRUE);
|
||
m_csCmd = _T("");
|
||
m_csAlias = _T("");
|
||
UpdateData(FALSE);
|
||
|
||
ResetListMenu();
|
||
}
|
||
|
||
void CSetToolbarPage::ResetListToolbar()
|
||
{
|
||
m_listToolbar.DeleteAllItems();
|
||
m_imageToolbar.DeleteImageList();
|
||
|
||
m_imageToolbar.Create(16, 16, ILC_COLOR|ILC_MASK, 0, 100);
|
||
HINSTANCE hInstance = LoadLibrary(m_xsDllFile);
|
||
|
||
m_listToolbar.SetImageList(&m_imageToolbar, LVSIL_SMALL);
|
||
int len = m_lstToolbarData.Length();
|
||
int n=0;
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
|
||
CString csChaName, csIcon;
|
||
HBITMAP hBitmap = NULL;
|
||
if (m_lstToolbarData[i]->m_iHit > 0)
|
||
{
|
||
csChaName = m_lstToolbarData[i]->m_csName;
|
||
csIcon = m_lstToolbarData[i]->m_csIcon;
|
||
hBitmap = LoadBitmap(hInstance, csIcon);
|
||
if (hBitmap)
|
||
{
|
||
CBitmap bitmap;
|
||
bitmap.Attach(hBitmap);
|
||
m_imageToolbar.Add(&bitmap, RGB(192, 192, 192));
|
||
}
|
||
else
|
||
MessageBox(csIcon);
|
||
TCHAR strText[64];
|
||
_tcscpy(strText, csChaName);
|
||
LV_ITEM listItem;
|
||
listItem.mask = LVIF_TEXT | LVIF_IMAGE;
|
||
listItem.iSubItem = 0;
|
||
listItem.iItem = n;
|
||
listItem.pszText = strText;
|
||
listItem.iImage = n;
|
||
m_listToolbar.InsertItem( &listItem );
|
||
n++;
|
||
}
|
||
}
|
||
|
||
FreeLibrary(hInstance);
|
||
// int n = m_listToolbar.GetItemCount();
|
||
}
|
||
|
||
const TCHAR* CSetToolbarPage::GetAlias(const TCHAR* szCmd)
|
||
{
|
||
int len = m_lstAlias.Length();
|
||
for(int i=0;i<len;i++){
|
||
CString csCmd = m_lstAlias[i]->m_csDesName;
|
||
if (_tcsicmp(csCmd, szCmd) == 0){
|
||
return (const TCHAR*)m_lstAlias[i]->m_csRecord;
|
||
}
|
||
}
|
||
return _T("");
|
||
}
|
||
|
||
void CSetToolbarPage::ResetListMenu()
|
||
{
|
||
m_listMenu.DeleteAllItems();
|
||
m_imageMenu.DeleteImageList();
|
||
|
||
CString csType;
|
||
m_imageMenu.Create(16, 16, ILC_COLOR|ILC_MASK, 0, 32);
|
||
HINSTANCE hInstance = LoadLibrary(m_xsDllFile);
|
||
if (m_iType>=0)
|
||
m_comboType.GetLBText(m_iType, csType);
|
||
m_listMenu.SetImageList(&m_imageMenu, LVSIL_SMALL);
|
||
int len = m_lstToolbarData.Length();
|
||
int n=0;
|
||
for(int i=0;i<len;i++){
|
||
|
||
CString csChaName, csIcon, csCmdName, csAlias;
|
||
HBITMAP hBitmap;
|
||
if (m_lstToolbarData[i]->m_csType.CompareNoCase(csType)==0)
|
||
{
|
||
csChaName = m_lstToolbarData[i]->m_csName;
|
||
csCmdName = m_lstToolbarData[i]->m_csCmd;
|
||
if (csChaName == _T("") || csCmdName == _T(""))
|
||
continue;
|
||
csAlias = GetAlias(csCmdName);
|
||
if (csAlias != _T("")){
|
||
int n = csChaName.GetLength();
|
||
XString xsTmp;
|
||
xsTmp << (const TCHAR*)csChaName;
|
||
for(int j=0;j<10-n;j++){
|
||
xsTmp << _T(" ");
|
||
}
|
||
xsTmp << (const TCHAR*)csAlias;
|
||
csChaName = (const TCHAR*)xsTmp;
|
||
}
|
||
csIcon = m_lstToolbarData[i]->m_csIcon;
|
||
hBitmap = LoadBitmap(hInstance, csIcon);
|
||
CBitmap bitmap;
|
||
bitmap.Attach(hBitmap);
|
||
m_imageMenu.Add(&bitmap, RGB(192, 192, 192));
|
||
TCHAR strText[64];
|
||
_tcscpy(strText, csChaName);
|
||
LV_ITEM listItem;
|
||
listItem.mask = LVIF_TEXT | LVIF_IMAGE;
|
||
listItem.iSubItem = 0;
|
||
listItem.iItem = n;
|
||
listItem.pszText = strText;
|
||
listItem.iImage = n;
|
||
m_listMenu.InsertItem( &listItem );
|
||
n++;
|
||
}
|
||
}
|
||
|
||
FreeLibrary(hInstance);
|
||
}
|
||
void CSetToolbarPage::ApplySetToolBar()
|
||
{
|
||
CodeBase db;
|
||
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable) {
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
int len = m_listToolbar.GetItemCount();
|
||
int iHit(0);
|
||
for(int i=0;i<len;i++){
|
||
CString csSel = m_listToolbar.GetItemText(i, 0);
|
||
if (csName.CompareNoCase(csSel)==0)
|
||
{
|
||
iHit = i+2;
|
||
break;
|
||
}
|
||
}
|
||
SET_FIELD(pTable, _T("flag"), iHit);
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else
|
||
MessageBox(_T("未能成功写入tchdata.dbf文件!"));
|
||
}
|
||
void CSetToolbarPage::OnOK()
|
||
{
|
||
CodeBase db;
|
||
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable) {
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
int len = m_listToolbar.GetItemCount();
|
||
int iHit(0);
|
||
for(int i=0;i<len;i++){
|
||
CString csSel = m_listToolbar.GetItemText(i, 0);
|
||
if (csName.CompareNoCase(csSel)==0)
|
||
{
|
||
iHit = i+2;
|
||
break;
|
||
}
|
||
}
|
||
SET_FIELD(pTable, _T("flag"), iHit);
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else
|
||
MessageBox(_T("未能成功写入tchdata.dbf文件!"));
|
||
CAcUiTabChildDialog::OnOK();
|
||
}
|
||
|
||
void CSetToolbarPage::OnDblclkListMenu(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
OnButAdd();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CSetToolbarPage::OnDblclkListToolbar(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
OnButRemove();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CSetToolbarPage::OnButtonUp()
|
||
{
|
||
UpdateData(TRUE);
|
||
int nSel = m_listToolbar.GetSelectionMark();
|
||
if (nSel < 1)
|
||
return;
|
||
CString csTmp1 = m_listToolbar.GetItemText(nSel, 0);
|
||
CString csTmp2 = m_listToolbar.GetItemText(nSel-1, 0);
|
||
if (csTmp2 == _T(""))
|
||
return;
|
||
|
||
int len = m_lstToolbarData.Length();
|
||
for(int i=0;i<len;i++){
|
||
if (m_lstToolbarData[i]->m_csName.CompareNoCase(csTmp1)==0)
|
||
{
|
||
m_lstToolbarData[i]->m_iHit --;
|
||
}
|
||
if (m_lstToolbarData[i]->m_csName.CompareNoCase(csTmp2)==0)
|
||
{
|
||
m_lstToolbarData[i]->m_iHit ++;
|
||
}
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
ResetListToolbar();
|
||
m_listToolbar.SetItemState(nSel-1, LVIS_SELECTED, LVIS_SELECTED);
|
||
m_listToolbar.SetSelectionMark(nSel-1);
|
||
m_listToolbar.EnsureVisible(nSel-1, TRUE);
|
||
m_listToolbar.SetFocus();
|
||
|
||
//add by xlc on 071016
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
|
||
void CSetToolbarPage::OnButtonDown()
|
||
{
|
||
UpdateData(TRUE);
|
||
int nSel = m_listToolbar.GetSelectionMark();
|
||
|
||
//modify by xlc on 071011
|
||
//if (nSel < 1)
|
||
if (nSel < 0)
|
||
|
||
return;
|
||
CString csTmp1 = m_listToolbar.GetItemText(nSel, 0);
|
||
CString csTmp2 = m_listToolbar.GetItemText(nSel+1, 0);
|
||
if (csTmp2 == _T(""))
|
||
return;
|
||
int len = m_lstToolbarData.Length();
|
||
for(int i=0;i<len;i++){
|
||
if (m_lstToolbarData[i]->m_csName.CompareNoCase(csTmp1)==0)
|
||
{
|
||
m_lstToolbarData[i]->m_iHit ++;
|
||
}
|
||
if (m_lstToolbarData[i]->m_csName.CompareNoCase(csTmp2)==0)
|
||
{
|
||
m_lstToolbarData[i]->m_iHit --;
|
||
}
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
ResetListToolbar();
|
||
m_listToolbar.SetItemState(nSel+1, LVIS_SELECTED, LVIS_SELECTED);
|
||
m_listToolbar.SetSelectionMark(nSel+1);
|
||
m_listToolbar.EnsureVisible(nSel+1, TRUE);
|
||
m_listToolbar.SetFocus();
|
||
|
||
//add by xlc on 071016
|
||
GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION);
|
||
m_bChecked = TRUE;
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
|
||
void IsAppandAlias(DList<CBlockStruct> &lstAll, CBlockStruct *pItem)
|
||
{
|
||
int iLength = lstAll.Length();
|
||
int Index = -1;
|
||
for(int j=0;j<iLength;j++){
|
||
CBlockStruct *pItem2 = lstAll[j];
|
||
if (_tcsicmp(lstAll[j]->m_csDesName, pItem->m_csDesName) == 0) {
|
||
Index = j;
|
||
break;
|
||
}
|
||
}
|
||
if (Index > -1){
|
||
lstAll[Index]->m_csRecord = pItem->m_csRecord;
|
||
delete pItem;
|
||
}
|
||
else
|
||
lstAll.Append(pItem);
|
||
}
|
||
|
||
void CSetToolbarPage::ReadPgp()
|
||
{
|
||
FILE *fp=_tfopen(m_xsAcadPgp, _T("r"));
|
||
if (!fp)
|
||
return;
|
||
m_lstAlias.Reset();
|
||
while(!feof(fp)) {
|
||
TCHAR szBuf[256]=_T(""), szAlias[256]=_T(""), szCmd[256]=_T(""), szTmp[256]=_T("");
|
||
_fgetts(szBuf, 255, fp);
|
||
if (szBuf[0] && szBuf[0] != _T(';')) {
|
||
CT_strnth(szBuf, 1, szAlias);
|
||
CT_strnth(szBuf, 2, szCmd);
|
||
CT_strnth(szBuf, 3, szTmp);
|
||
if (szTmp[0])
|
||
continue;
|
||
CString csCmd = szCmd;
|
||
if (csCmd.Find(_T("*")) == 0){
|
||
csCmd = csCmd.Right(csCmd.GetLength() - 1);
|
||
CBlockStruct *pInfo = new CBlockStruct();
|
||
pInfo->m_csRecord = szAlias;
|
||
pInfo->m_csDesName = csCmd;
|
||
IsAppandAlias(m_lstAlias, pInfo);
|
||
}
|
||
}
|
||
}
|
||
fclose(fp);
|
||
}
|
||
|
||
void CSetToolbarPage::WritePgp()
|
||
{
|
||
XStringList lstPgp;
|
||
FILE *fp=_tfopen(m_xsAcadPgp, _T("r"));
|
||
if (!fp)
|
||
return;
|
||
m_lstAlias.Reset();
|
||
while(!feof(fp)) {
|
||
TCHAR szBuf[256]=_T(""), szAlias[256]=_T(""), szCmd[256]=_T(""), szTmp[256]=_T("");
|
||
_fgetts(szBuf, 255, fp);
|
||
CString csBuf = szBuf;
|
||
if (szBuf[0] && szBuf[0] != _T(';')) {
|
||
CT_strnth(szBuf, 1, szAlias);
|
||
CT_strnth(szBuf, 2, szCmd);
|
||
CT_strnth(szBuf, 3, szTmp);
|
||
if (szTmp[0])
|
||
continue;
|
||
CString csCmd = szCmd;
|
||
if (csCmd.Find(_T("*")) == 0){
|
||
csCmd = csCmd.Right(csCmd.GetLength() - 1);
|
||
CBlockStruct *pInfo = new CBlockStruct();
|
||
pInfo->m_csRecord = szAlias;
|
||
pInfo->m_csDesName = csCmd;
|
||
IsAppandAlias(m_lstAlias, pInfo);
|
||
}
|
||
}
|
||
lstPgp.Append(tstrnew(csBuf));
|
||
}
|
||
fclose(fp);
|
||
|
||
FILE *fp2 = _tfopen(m_xsAcadPgp, _T("w"));
|
||
if (!fp2)
|
||
return;
|
||
int len = lstPgp.Length();
|
||
for(int i=0; i < len; i++){
|
||
CString csTmp = lstPgp[i];
|
||
csTmp += _T("\n");
|
||
_fputts(csTmp, fp2);
|
||
}
|
||
fclose(fp2);
|
||
|
||
}
|
||
|
||
void CSetToolbarPage::OnItemchangedListMenu(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
if (m_bDragging)
|
||
return;
|
||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
||
|
||
int nSel = pNMListView->iItem;
|
||
if (nSel < 0)
|
||
return;
|
||
CString csSel = m_listMenu.GetItemText(nSel, 0);
|
||
TCHAR szSel[32];
|
||
CT_strnth(csSel, 1, szSel);
|
||
csSel = szSel;
|
||
int count = m_lstToolbarData.Length();
|
||
HBITMAP hBitmap = NULL;
|
||
for(int j=0;j<count;j++){
|
||
if (csSel.CompareNoCase(m_lstToolbarData[j]->m_csName)==0)
|
||
{
|
||
m_csCmd = m_lstToolbarData[j]->m_csCmd;
|
||
m_csAlias = GetAlias(m_csCmd);
|
||
UpdateData(FALSE);
|
||
break;
|
||
}
|
||
}
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CSetToolbarPage::OnButModify()
|
||
{
|
||
UpdateData(TRUE);
|
||
int nSel = m_listMenu.GetSelectionMark();
|
||
if (nSel < 0)
|
||
return;
|
||
CBlockStruct *pInfo = new CBlockStruct();
|
||
pInfo->m_csRecord = m_csAlias;
|
||
pInfo->m_csDesName = m_csCmd;
|
||
IsAppandAlias(m_lstAlias, pInfo);
|
||
m_bModifyAlias = TRUE;
|
||
|
||
ResetListMenu();
|
||
m_listMenu.SetItemState(nSel, LVIS_SELECTED, LVIS_SELECTED);
|
||
m_listMenu.SetSelectionMark(nSel);
|
||
m_listMenu.EnsureVisible(nSel, TRUE);
|
||
m_listMenu.SetFocus();
|
||
|
||
}
|
||
|
||
void CSetToolbarPage::CreateToolbars()
|
||
{
|
||
//ApplySet();
|
||
//add by xlc on 071016
|
||
if (!m_bModified)
|
||
return;
|
||
|
||
CodeBase db;
|
||
XString xsDbfFile;
|
||
DList<CToolbarData> lstToolbarData;
|
||
if (!FindFile(_T("tchdata.dbf"), xsDbfFile))
|
||
{
|
||
AfxMessageBox(_T("对不起,没有发现tchdata.dbf文件!"));
|
||
return;
|
||
}
|
||
|
||
CString csName, csDescribe, csIcon, csType,csCmd;
|
||
int iHit=0;
|
||
XDbfTable *pTable = db.Open(xsDbfFile);
|
||
if (!pTable)
|
||
{
|
||
return;
|
||
}
|
||
//if (pTable)
|
||
//{
|
||
// pTable->MoveFirst();
|
||
// while(!pTable->IsEOF()) {
|
||
// GET_FIELD(pTable, _T("chacmd"), csName);
|
||
// GET_FIELD(pTable, _T("engcmd"), csCmd);
|
||
// GET_FIELD(pTable, _T("explain"), csDescribe);
|
||
// GET_FIELD(pTable, _T("icon"), csIcon);
|
||
// GET_FIELD(pTable, _T("flag"), iHit);
|
||
// GET_FIELD(pTable, _T("type"), csType);
|
||
// if (iHit > 0)
|
||
// lstToolbarData.Append(new CToolbarData(csType, csCmd, csName, csDescribe, csIcon, iHit));
|
||
// pTable->MoveNext();
|
||
// }
|
||
//}
|
||
//else
|
||
// return;/**/
|
||
int nLen = m_lstToolbarData.Length();
|
||
int j=0;
|
||
/*if (pTable)
|
||
{
|
||
pTable->MoveFirst();
|
||
while (!pTable->IsEOF())
|
||
{
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
for (j=0;j<m_lstToolbarData.Length();j++)
|
||
{
|
||
CToolbarData *pToolBarData = m_lstToolbarData[j];
|
||
if (csName==pToolBarData->m_csCmd)
|
||
{
|
||
SET_FIELD(pTable, _T("flag"), iHit);
|
||
}
|
||
}
|
||
pTable->MoveNext();
|
||
}
|
||
}*/
|
||
for (j=0;j<m_lstToolbarData.Length();j++)
|
||
{
|
||
CToolbarData *pToolBarData = m_lstToolbarData[j];
|
||
if (pToolBarData->m_iHit>0)
|
||
{
|
||
lstToolbarData.Append(new CToolbarData(pToolBarData->m_csType,pToolBarData->m_csCmd,pToolBarData->m_csName,pToolBarData->m_csDescribe,pToolBarData->m_csIcon,pToolBarData->m_iHit));
|
||
}
|
||
}
|
||
lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
|
||
XString sMns;
|
||
CStdioFile mnsFile;
|
||
if (!FindFile(_T("tch.mns"), sMns)||!mnsFile.Open(sMns,CFile::modeReadWrite))
|
||
{
|
||
AfxMessageBox(_T("对不起,未能找到tch.mns文件!"));
|
||
return;
|
||
}
|
||
|
||
CString sLine;
|
||
DList<CString> sList;
|
||
while(mnsFile.ReadString(sLine))
|
||
if (sLine.Find(_T("ID_TCH_CUSTOM"))<0)//过滤原所有自定义信息,bug:将自定工具栏的自定义快捷鍵也清除了
|
||
sList.Append(new CString(sLine));
|
||
|
||
for(long i=0;i<sList.Length();i++)
|
||
{
|
||
sLine=*sList[i];
|
||
if (sLine.Find(_T("ID_TBSHORTCUT4"))>=0)
|
||
for(long j=0;j<lstToolbarData.Length();j++)
|
||
{
|
||
CToolbarData*pData=lstToolbarData[j];
|
||
XString sNew;
|
||
sNew<<_T("ID_TCH_CUSTOM_")<<j<<_T(" ")//标识
|
||
<<_T("[_Button(\"")<<pData->m_csName<<_T("\",\"")<<pData->m_csIcon<<_T("\",\"")<<pData->m_csIcon<<_T("\")]")//按钮
|
||
<<pData->m_csCmd;//命令
|
||
++i;
|
||
if (i<sList.Length())
|
||
{
|
||
sList[i];
|
||
sList.Insert(new CString(sNew));
|
||
}
|
||
else
|
||
sList.Append(new CString(sNew));
|
||
}
|
||
else if (sLine.Find(_T("***HELPSTRINGS"))>=0)
|
||
for(long j=0;j<lstToolbarData.Length();j++)
|
||
{
|
||
CToolbarData*pData=lstToolbarData[j];
|
||
XString sNew;
|
||
sNew<<_T("ID_TCH_CUSTOM_")<<j<<_T(" ")//标识
|
||
<<_T("[")<<pData->m_csDescribe<<_T("]");//说明
|
||
++i;
|
||
if (i<sList.Length())
|
||
{
|
||
sList[i];
|
||
sList.Insert(new CString(sNew));
|
||
}
|
||
else
|
||
sList.Append(new CString(sNew));
|
||
}
|
||
}
|
||
|
||
mnsFile.SetLength(0);
|
||
for(i=0;i<sList.Length();i++)
|
||
{
|
||
mnsFile.WriteString(*sList[i]);
|
||
mnsFile.WriteString(_T("\n"));
|
||
}
|
||
mnsFile.Close();
|
||
|
||
XPushVar<int> cmdecho(_T("CMDECHO"), 0);
|
||
acedCommand(RTSTR,_T("menuunload"),RTSTR,_T("上华快捷菜单"),RTNONE);
|
||
acedCommand(RTSTR,_T("menuload"),RTSTR,sMns,RTNONE);
|
||
|
||
//用于解决工具条被关问题
|
||
//CoInitialize(NULL);
|
||
//IAcadApplication *pApp = NULL;
|
||
//AfxGetApp()->GetIDispatch(FALSE)->QueryInterface(__uuidof(IAcadApplication), (void **)&pApp);
|
||
//if (pApp == NULL)
|
||
// return;
|
||
//IAcadMenuGroupsPtr pMenuGroups = pApp->GetMenuGroups();
|
||
//if (pMenuGroups == NULL)
|
||
//{
|
||
// pApp->Release();
|
||
// CoUninitialize();
|
||
// return;
|
||
//}
|
||
//long cnt = 0;
|
||
//pMenuGroups->get_Count(&cnt);
|
||
//IAcadMenuGroupPtr mnuGrp = NULL;
|
||
//IAcadMenuGroupPtr pMnuGrp = NULL;
|
||
//for(i=0;i<cnt;i++)
|
||
//{
|
||
// VARIANT vtName;
|
||
// vtName.vt = VT_I4;
|
||
// vtName.lVal = i;
|
||
// mnuGrp = pMenuGroups->Item(vtName);
|
||
// if (mnuGrp == NULL)
|
||
// {
|
||
// pApp->Release();
|
||
// CoUninitialize();
|
||
// return;
|
||
// }
|
||
// BSTR grpName;
|
||
// mnuGrp->get_Name(&grpName);
|
||
// CString cgrpName(grpName);
|
||
// if (cgrpName.CompareNoCase(_T("TCH"))==0)
|
||
// {
|
||
// pMnuGrp = mnuGrp;
|
||
// break;
|
||
// }
|
||
//}
|
||
//if (pMnuGrp == NULL)
|
||
//{
|
||
// pApp->Release();
|
||
// CoUninitialize();
|
||
// return;
|
||
//}
|
||
//IAcadToolbarsPtr tlbrs = NULL;
|
||
//IAcadToolbarPtr tlbr = NULL;
|
||
//pMnuGrp->get_Toolbars(&tlbrs);
|
||
//tlbr = FindToolbar(tlbrs);
|
||
//if (tlbr!=NULL)
|
||
//{
|
||
// tlbr->put_Visible(TRUE);
|
||
// tlbr->Dock(acToolbarDockBottom);
|
||
//}
|
||
|
||
//pApp->Release();
|
||
//CoUninitialize();
|
||
}
|
||
|
||
//add by xlc on 071015
|
||
HCURSOR CSetToolbarPage::OnQueryDragIcon()
|
||
{
|
||
return (HCURSOR) m_hIcon;
|
||
}
|
||
//add by xlc on 071015
|
||
void CSetToolbarPage::OnBegindragList(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
||
m_nDragIndex = pNMListView->iItem;
|
||
|
||
POINT pt;
|
||
int nOffset = 15;
|
||
if (m_listToolbar.GetSelectedCount() > 1)
|
||
pt.x = nOffset;
|
||
pt.y = nOffset;
|
||
|
||
RECT rect;
|
||
m_listToolbar.GetWindowRect(&rect);
|
||
|
||
m_pDragImage = new CImageList;
|
||
m_pDragImage->Create(IDB_BITMAP_BOX,rect.right-rect.left,1,ILC_COLOR32);
|
||
ASSERT(m_pDragImage);
|
||
|
||
m_pDragImage->BeginDrag(0, CPoint(0, nOffset));
|
||
m_pDragImage->DragEnter(GetDesktopWindow(), pNMListView->ptAction);
|
||
|
||
m_bDragging = TRUE;
|
||
m_nDropIndex = -1;
|
||
m_pDragList = &m_listToolbar;
|
||
m_pDropWnd = &m_listToolbar;
|
||
|
||
SetCapture ();
|
||
|
||
*pResult = 0;
|
||
}
|
||
//add by xlc on 071015
|
||
void CSetToolbarPage::OnLButtonUp(UINT nFlags, CPoint point)
|
||
{
|
||
if (m_bDragging)
|
||
{
|
||
ReleaseCapture ();
|
||
|
||
m_pDragImage->DragLeave (GetDesktopWindow ()); //结束拖拽
|
||
m_pDragImage->EndDrag ();
|
||
delete m_pDragImage;
|
||
|
||
CPoint pt (point); //当前鼠标坐标
|
||
ClientToScreen (&pt);
|
||
|
||
CWnd* pDropWnd = WindowFromPoint (pt);
|
||
ASSERT (pDropWnd);
|
||
|
||
if (pDropWnd->IsKindOf (RUNTIME_CLASS (CListCtrl)))
|
||
{
|
||
m_pDropList = (CListCtrl*)pDropWnd;
|
||
DropItemOnList(m_pDragList, m_pDropList);
|
||
}
|
||
|
||
m_bDragging = FALSE;
|
||
}
|
||
CAcUiTabChildDialog::OnLButtonUp(nFlags, point);
|
||
}
|
||
|
||
//add by xlc on 071015
|
||
void CSetToolbarPage::OnMouseMove(UINT nFlags, CPoint point)
|
||
{
|
||
if (m_bDragging)
|
||
{
|
||
CPoint pt(point); //当前鼠标位置
|
||
RECT lpRect;
|
||
m_listToolbar.GetItemRect(0,&lpRect,LVIR_BOUNDS);
|
||
|
||
int height = lpRect.bottom - lpRect.top;
|
||
int dist = point.y - lpRect.top;
|
||
int n = dist / height+1;
|
||
pt.y = lpRect.top + n * height;
|
||
|
||
CRect rect;
|
||
GetDlgItem(IDC_LIST_TOOLBAR)->GetWindowRect(rect);
|
||
CPoint ptS;
|
||
ptS.x = rect.left;
|
||
ptS.y = rect.top;
|
||
ScreenToClient(&ptS);
|
||
pt.x = ptS.x;
|
||
|
||
ClientToScreen(&pt);
|
||
m_pDragImage->DragMove(pt);
|
||
m_pDragImage->DragShowNolock(false);
|
||
|
||
pt.y = point.y;
|
||
pt.x = ptS.x+20;//point.x;
|
||
ClientToScreen(&pt);
|
||
|
||
CWnd* pDropWnd = WindowFromPoint (pt);
|
||
if (pDropWnd == NULL)
|
||
return;
|
||
|
||
if (pDropWnd != m_pDropWnd)
|
||
{
|
||
if (m_nDropIndex != -1)
|
||
{
|
||
TRACE("m_nDropIndex is -1\n");
|
||
CListCtrl* pList = (CListCtrl*)m_pDropWnd;
|
||
if (pList == NULL)
|
||
return;
|
||
|
||
pList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
|
||
pList->RedrawItems (m_nDropIndex, m_nDropIndex);
|
||
pList->UpdateWindow ();
|
||
m_nDropIndex = -1;
|
||
}
|
||
else
|
||
{
|
||
TRACE("m_nDropIndex is not -1\n");
|
||
CListCtrl* pList = (CListCtrl*)m_pDropWnd;
|
||
if (pList == NULL)
|
||
return;
|
||
|
||
int i = 0;
|
||
int nCount = pList->GetItemCount();
|
||
for(i = 0; i < nCount; i++)
|
||
{
|
||
pList->SetItemState(i, 0, LVIS_DROPHILITED);
|
||
}
|
||
pList->RedrawItems(0, nCount);
|
||
pList->UpdateWindow();
|
||
}
|
||
}
|
||
|
||
m_pDropWnd = pDropWnd;
|
||
pDropWnd->ScreenToClient(&pt);
|
||
|
||
CRect rcList;
|
||
m_listToolbar.GetWindowRect(&rcList);
|
||
CPoint pntScreen(point);
|
||
ClientToScreen(&pntScreen);
|
||
if (rcList.PtInRect(pntScreen))
|
||
{
|
||
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||
UINT uFlags;
|
||
CListCtrl* pList = (CListCtrl*)pDropWnd;
|
||
if (pList == NULL)
|
||
return;
|
||
|
||
pList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
|
||
pList->RedrawItems (m_nDropIndex, m_nDropIndex);
|
||
|
||
m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest(pt, &uFlags);
|
||
if (pList->RedrawItems(m_nDropIndex, m_nDropIndex))
|
||
pList->UpdateWindow();
|
||
|
||
m_pDragImage->DragShowNolock(true);
|
||
}
|
||
else
|
||
{
|
||
SetCursor(LoadCursor(NULL, IDC_NO));
|
||
}
|
||
|
||
}
|
||
|
||
CAcUiTabChildDialog::OnMouseMove(nFlags, point);
|
||
}
|
||
// add by xlc on 071015
|
||
void CSetToolbarPage::DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList)
|
||
{
|
||
if (pDragList == NULL|| pDropList==NULL)
|
||
return;
|
||
|
||
pDropList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
|
||
|
||
TCHAR szLabel[256];
|
||
LVITEM lviT;
|
||
LVITEM* plvitem;
|
||
|
||
ZeroMemory(&lviT, sizeof (LVITEM));
|
||
lviT.iItem = m_nDragIndex;
|
||
lviT.mask = LVIF_TEXT | LVIF_IMAGE;
|
||
lviT.pszText = szLabel;
|
||
lviT.cchTextMax = 255;
|
||
|
||
lvItem* pItem;
|
||
lvItem lvi;
|
||
lvi.plvi = &lviT;
|
||
lvi.plvi->iItem = m_nDragIndex;
|
||
lvi.plvi->mask = LVIF_TEXT | LVIF_IMAGE;
|
||
lvi.plvi->pszText = szLabel;
|
||
lvi.plvi->cchTextMax = 255;
|
||
|
||
if (pDragList->GetSelectedCount() == 1)
|
||
{
|
||
if (m_nDropIndex !=m_nDragIndex)
|
||
{
|
||
pDragList->GetItem (lvi.plvi); //拖拽项
|
||
|
||
if (pDragList == pDropList)
|
||
{
|
||
pDragList->DeleteItem (m_nDragIndex);
|
||
if (m_nDragIndex < m_nDropIndex)
|
||
m_nDropIndex--;
|
||
}
|
||
|
||
//插入项
|
||
lvi.plvi->iItem = (m_nDropIndex == -1) ? pDropList->GetItemCount () : m_nDropIndex;
|
||
pDropList->InsertItem (lvi.plvi);
|
||
|
||
pDropList->SetItemState (lvi.plvi->iItem, LVIS_SELECTED, LVIS_SELECTED);
|
||
}
|
||
}
|
||
else //多行
|
||
{
|
||
CList<lvItem*, lvItem*> listItems;
|
||
POSITION listPos;
|
||
|
||
POSITION pos = pDragList->GetFirstSelectedItemPosition();
|
||
while(pos)
|
||
{
|
||
plvitem = new LVITEM;
|
||
ZeroMemory(plvitem, sizeof(LVITEM));
|
||
pItem = new lvItem;
|
||
|
||
pItem->plvi = plvitem;
|
||
pItem->plvi->iItem = m_nDragIndex;
|
||
pItem->plvi->mask = LVIF_TEXT | LVIF_IMAGE;
|
||
pItem->plvi->pszText = new TCHAR[256];
|
||
pItem->plvi->cchTextMax = 255;
|
||
|
||
m_nDragIndex = pDragList->GetNextSelectedItem(pos);
|
||
|
||
pItem->plvi->iItem = m_nDragIndex;
|
||
pDragList->GetItem(pItem->plvi);
|
||
|
||
listItems.AddTail(pItem);
|
||
}
|
||
|
||
if (pDragList == pDropList)
|
||
{
|
||
pos = pDragList->GetFirstSelectedItemPosition();
|
||
while(pos)
|
||
{
|
||
pos = pDragList->GetFirstSelectedItemPosition();
|
||
m_nDragIndex = pDragList->GetNextSelectedItem(pos);
|
||
|
||
pDragList->DeleteItem(m_nDragIndex);
|
||
if (m_nDragIndex < m_nDropIndex)
|
||
m_nDropIndex--;
|
||
}
|
||
}
|
||
|
||
listPos = listItems.GetHeadPosition();
|
||
while(listPos)
|
||
{
|
||
pItem = listItems.GetNext(listPos);
|
||
|
||
m_nDropIndex = (m_nDropIndex == -1) ? pDropList->GetItemCount() : m_nDropIndex;
|
||
pItem->plvi->iItem = m_nDropIndex;
|
||
pDropList->InsertItem(pItem->plvi);
|
||
pDropList->SetItemState(pItem->plvi->iItem, LVIS_SELECTED, LVIS_SELECTED);
|
||
|
||
m_nDropIndex++;
|
||
}
|
||
}
|
||
|
||
m_strSelectItem.RemoveAll();
|
||
POSITION pos=pDragList->GetFirstSelectedItemPosition();
|
||
while(pos)
|
||
{
|
||
int index = pDragList->GetNextSelectedItem(pos);
|
||
CString strItem = pDragList->GetItemText(index,0);
|
||
m_strSelectItem.Add(strItem);
|
||
}
|
||
AdjustToolbar();
|
||
}
|
||
//add by xlc on 071016
|
||
void CSetToolbarPage::AdjustToolbar()
|
||
{
|
||
int len = m_lstToolbarData.Length();
|
||
int nCount = m_listToolbar.GetItemCount();
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
for(int j=0;j<m_listToolbar.GetItemCount();j++)
|
||
{
|
||
CString csTmp = m_listToolbar.GetItemText(j,0);
|
||
if (m_lstToolbarData[i]->m_csName.CompareNoCase(csTmp)==0)
|
||
{
|
||
m_lstToolbarData[i]->m_iHit = j+2;
|
||
nCount--;
|
||
break;
|
||
}
|
||
}
|
||
if (nCount == 0)
|
||
break;
|
||
}
|
||
m_lstToolbarData.QuickSort(CToolbarData::SortByItem);
|
||
ResetListToolbar();
|
||
for(i=0; i<m_strSelectItem.GetSize();i++)
|
||
{
|
||
LVFINDINFO info;
|
||
info.flags = LVFI_PARTIAL|LVFI_STRING;
|
||
info.psz = m_strSelectItem[i];
|
||
|
||
if ((m_nDropIndex = m_listToolbar.FindItem(&info))!=-1)
|
||
{
|
||
m_listToolbar.SetItemState(m_nDropIndex, LVIS_SELECTED, LVIS_SELECTED);
|
||
m_listToolbar.SetSelectionMark(m_nDropIndex);
|
||
m_listToolbar.EnsureVisible(m_nDropIndex, TRUE);
|
||
}
|
||
}
|
||
m_listToolbar.SetFocus();
|
||
|
||
|
||
m_bModified = TRUE;
|
||
}
|
||
|
||
// COptionSheet
|
||
int COptionSheet::c_iSelectPage = 0;
|
||
|
||
IMPLEMENT_DYNAMIC(COptionSheet, CAcUiTabMainDialog)
|
||
COptionSheet::COptionSheet(CWnd* pParentWnd)
|
||
:CAcUiTabMainDialog(COptionSheet::IDD,pParentWnd)
|
||
{
|
||
// AddPage(&m_pageScreenMenu);
|
||
//if (g_nProductId!=2&&g_nProductId!=3&&g_nProductId!=8&&g_nProductId!=6)//结构、给排水和电气不用自定义工具条、快捷键。
|
||
//{
|
||
// AddPage(&m_pageToolBar);
|
||
// AddPage(&m_pageShortCutKey);
|
||
//}
|
||
//AddPage(&m_FontDlgPage);
|
||
g_bCancel=FALSE;
|
||
}
|
||
void COptionSheet::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CAcUiTabMainDialog::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_TAB_SELFOPTION, m_tab);
|
||
}
|
||
COptionSheet::~COptionSheet()
|
||
{
|
||
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(COptionSheet, CAcUiTabMainDialog)
|
||
ON_WM_DESTROY()
|
||
ON_BN_CLICKED(IDC_RET_DEFAULT,COptionSheet::OnClickDefaultOption)
|
||
ON_BN_CLICKED(IDC_EXPORT,COptionSheet::OnClickExportOption)
|
||
ON_BN_CLICKED(IDC_IMPORT,COptionSheet::OnClickImportOption)
|
||
ON_BN_CLICKED(IDC_RET_APPLY,COptionSheet::OnClickApply)
|
||
ON_BN_CLICKED(IDC_OPTION_HELP, COptionSheet::OnCommandHelp)
|
||
ON_WM_CLOSE()
|
||
ON_WM_DESTROY()
|
||
ON_MESSAGE(TARCH_SETTING_MSG_BUTTONSTATION,OnUpdataApplyButton)
|
||
END_MESSAGE_MAP()
|
||
|
||
void COptionSheet::OnClickApply()
|
||
{
|
||
if (m_pageScreenMenu.m_bChecked)
|
||
{
|
||
ApplyData(0);
|
||
m_pageScreenMenu.m_bChecked = FALSE;
|
||
}
|
||
if (m_pageUserOperator.m_bChecked)
|
||
{
|
||
ApplyData(1);
|
||
m_pageUserOperator.m_bChecked = FALSE;
|
||
}
|
||
if (m_FontDlgPage.m_bChecked)
|
||
{
|
||
ApplyData(2);
|
||
m_FontDlgPage.m_bChecked = FALSE;
|
||
}
|
||
if (m_pageToolBar.m_bChecked)
|
||
{
|
||
ApplyData(3);
|
||
m_pageToolBar.m_bChecked = FALSE;
|
||
}
|
||
if (m_pageShortCutKey.m_bChecked||m_pageShortCutKey.BGridModify())
|
||
{
|
||
ApplyData(4);
|
||
m_pageShortCutKey.m_bChecked = FALSE;
|
||
}
|
||
acedCommand(RTSTR, _T("REGEN"), RTNONE);
|
||
CButton *pButton = (CButton*)GetDlgItem(IDC_RET_APPLY);
|
||
pButton->EnableWindow(FALSE);
|
||
}
|
||
LRESULT COptionSheet::OnUpdataApplyButton(WPARAM w,LPARAM l)
|
||
{
|
||
CButton *pButton = (CButton*)GetDlgItem(IDC_RET_APPLY);
|
||
pButton->EnableWindow(TRUE);
|
||
return 0;
|
||
}
|
||
void COptionSheet::ApplyData(int nIndex)
|
||
{
|
||
switch (nIndex)
|
||
{
|
||
case 0:
|
||
{
|
||
//CPropertyPage* pPage = GetPage(0);
|
||
CAdUiTabChildDialog *pDlg = NULL;
|
||
pDlg = m_tab.GetDialogPointer(0);
|
||
HWND hWnd;
|
||
hWnd = pDlg->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
// BOOL bVisiable;
|
||
int index = ((CButton*)pDlg->GetDlgItem(IDC_SCREEN_MENU))->GetCheck();
|
||
if (index == 0)
|
||
{
|
||
m_pageScreenMenu.m_bScreenMenu = FALSE;
|
||
}
|
||
else
|
||
{
|
||
m_pageScreenMenu.m_bScreenMenu = TRUE;
|
||
}
|
||
index = ((CButton*)pDlg->GetDlgItem(IDC_RADIO1))->GetCheck();
|
||
if (index == 0)
|
||
{
|
||
m_pageScreenMenu.m_bLimitHeight = TRUE;
|
||
}
|
||
else
|
||
{
|
||
m_pageScreenMenu.m_bLimitHeight = FALSE;
|
||
}
|
||
index = ((CButton*)pDlg->GetDlgItem(IDC_SCROLL_BAR))->GetCheck();
|
||
if (index == 0)
|
||
{
|
||
m_pageScreenMenu.m_bScrollBar = FALSE;
|
||
}
|
||
else
|
||
{
|
||
m_pageScreenMenu.m_bScrollBar = TRUE;
|
||
}
|
||
index = ((CButton*)pDlg->GetDlgItem(IDC_OPEN_FIRST))->GetCheck();
|
||
if (index == 0)
|
||
{
|
||
m_pageScreenMenu.m_bAutoOpenFirst = FALSE;
|
||
}
|
||
else
|
||
{
|
||
m_pageScreenMenu.m_bAutoOpenFirst = TRUE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//m_pageScreenMenu.m_bScreenMenu = IsScreenMenuVisible();
|
||
m_pageScreenMenu.m_bLimitHeight = g_bLimitHeight;
|
||
m_pageScreenMenu.m_bScrollBar = g_bScrollBar;
|
||
m_pageScreenMenu.m_bAutoOpenFirst = g_bDefaultOpenFirst;
|
||
}
|
||
m_pageScreenMenu.LoadMenu();
|
||
if (g_nProductId==kTARCH && g_nVersion>6.9)
|
||
acedCommand(RTSTR,_T("tmnload"),RTNONE);
|
||
else
|
||
acedCommand(RTSTR,_T("tmnload1"),RTNONE);
|
||
//ShowScreenMenu(m_pageScreenMenu.m_bScreenMenu);
|
||
m_pageScreenMenu.m_cBkCol1.Invalidate();
|
||
m_pageScreenMenu.m_cBkCol2.Invalidate();
|
||
m_pageScreenMenu.m_cBkCol3.Invalidate();
|
||
m_pageScreenMenu.m_cBkCol4.Invalidate();
|
||
acedGetAcadFrame()->RedrawWindow(NULL,NULL,RDW_ALLCHILDREN|RDW_INVALIDATE);
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
CAdUiTabChildDialog *pDlg = NULL;
|
||
pDlg = m_tab.GetDialogPointer(2);
|
||
HWND hWnd;
|
||
hWnd = pDlg->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
m_FontDlgPage.ApplySet();
|
||
}
|
||
acedGetAcadFrame()->RedrawWindow(NULL,NULL,RDW_ALLCHILDREN|RDW_INVALIDATE);
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
m_pageToolBar.ApplySetToolBar();
|
||
m_pageToolBar.m_bModified = TRUE;
|
||
m_pageToolBar.CreateToolbars();
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
CAdUiTabChildDialog *pDlg = NULL;
|
||
pDlg = m_tab.GetDialogPointer(4);
|
||
HWND hWnd;
|
||
hWnd = pDlg->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
m_pageShortCutKey.ApplyShortCutKey();
|
||
m_pageShortCutKey.WritePgp();
|
||
}
|
||
}
|
||
case 1:
|
||
{
|
||
//m_pageShortCutKey.WriteShortCutKey();
|
||
//m_pageShortCutKey.WritePgp();
|
||
CAdUiTabChildDialog *pDlg = NULL;
|
||
pDlg = m_tab.GetDialogPointer(1);
|
||
HWND hWnd;
|
||
hWnd = pDlg->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
m_pageUserOperator.ApplySet();
|
||
}
|
||
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
void COptionSheet::OnClickDefaultOption()
|
||
{
|
||
//MessageBox(_T("test"));
|
||
XString fullFile;
|
||
if (!FindFile(_T("TOptionsDef.xml"), fullFile))
|
||
{
|
||
MessageBox(_T("对不起,没有发现TOptionsDef.xml文件!"));
|
||
return;
|
||
}
|
||
CString strPath = fullFile;
|
||
CXMLDOMFile *pXMLDoc = new CXMLDOMFile;
|
||
if (pXMLDoc->IsFileExist(strPath))
|
||
{
|
||
if (!pXMLDoc->Open(strPath))
|
||
{
|
||
delete pXMLDoc;
|
||
pXMLDoc = NULL;
|
||
// Zyu modify on 100726,支持64位
|
||
#ifndef _WIN64
|
||
MessageBox(_T("打开XML文档失败!请安装MSXML4.0SP2组件"));
|
||
#else
|
||
MessageBox(_T("打开XML文档失败!请安装MSXML6.0组件"));
|
||
#endif
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
delete pXMLDoc;
|
||
pXMLDoc = NULL;
|
||
MessageBox(_T("xml文件不存在"));
|
||
return;
|
||
}
|
||
CString strPageName;
|
||
int nIndex = m_tab.GetActiveTab()/*GetActiveIndex()*/;
|
||
if (nIndex==0)
|
||
{
|
||
strPageName = _T("屏幕菜单");
|
||
}
|
||
else if (nIndex == 1)
|
||
{
|
||
strPageName = _T("操作配置");
|
||
}
|
||
else if (nIndex == 2)
|
||
{
|
||
strPageName = _T("基本界面");
|
||
}
|
||
else if (nIndex==3)
|
||
{
|
||
strPageName = _T("工具条");
|
||
}
|
||
else if (nIndex == 4)
|
||
{
|
||
strPageName = _T("快捷键");
|
||
}
|
||
//CAcModuleResourceOverride vTemp;
|
||
CImportXMLDocDlg importDlg(pXMLDoc,strPageName,1);
|
||
//importDlg.SetWindowText(_T("导入默认设置"));
|
||
if (importDlg.DoModal()==IDOK)
|
||
{
|
||
CTArchSettingEditTools setEditTool;
|
||
setEditTool.SetXMLDoc(pXMLDoc);
|
||
setEditTool.ImportAllTArchSettingData(importDlg.m_treeXmlDoc.m_mapData);
|
||
CAdUiTabChildDialog* pPage =m_tab.GetDialogPointer(nIndex);
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
HWND hWnd;
|
||
//其他窗口为创建则不发送消息
|
||
switch (nIndex)
|
||
{
|
||
case 0:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
case 4:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
std::map<CString,NodeInfoAry>::iterator iter;
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("屏幕菜单"));//界面1
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(0);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("操作配置"));//界面5
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(1);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("基本界面"));//界面2
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(2);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("工具条"));//界面3
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(3);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("快捷键"));//界面4
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(4);
|
||
}
|
||
}
|
||
delete pXMLDoc;
|
||
}
|
||
void COptionSheet::OnClickExportOption()
|
||
{
|
||
CFileDialog dlg(FALSE, _T("xml"), _T("上华配置.xml"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT
|
||
, _T("xml文档(*.xml)|*.xml||"));
|
||
|
||
if (dlg.DoModal() != IDOK)
|
||
return;
|
||
CString strPath = dlg.GetPathName();
|
||
CXMLDOMFile *pXMLDoc = new CXMLDOMFile;
|
||
CTArchSettingEditTools setEditTools;
|
||
if (!setEditTools.ExportTArchSettingData(strPath))
|
||
{
|
||
// Zyu modify on 100726,支持64位
|
||
#ifndef _WIN64
|
||
MessageBox(_T("创建XML文档失败!请安装MSXML4.0SP2组件"));
|
||
#else
|
||
MessageBox(_T("创建XML文档失败!请安装MSXML6.0组件"));
|
||
#endif
|
||
}
|
||
|
||
pXMLDoc->Save();
|
||
delete pXMLDoc;
|
||
}
|
||
void COptionSheet::OnClickImportOption()
|
||
{
|
||
CFileDialog dlg(TRUE,
|
||
NULL, // no default extension
|
||
NULL, // ..or file name
|
||
OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT,
|
||
_T("xml Files (*.xml)|*.xml||"));
|
||
if (dlg.DoModal()==IDOK)
|
||
{
|
||
CString strPath = dlg.GetPathName();
|
||
CXMLDOMFile *pXMLDoc = new CXMLDOMFile;
|
||
if (pXMLDoc->IsFileExist(strPath))
|
||
{
|
||
if (!pXMLDoc->Open(strPath))
|
||
{
|
||
delete pXMLDoc;
|
||
pXMLDoc = NULL;
|
||
// Zyu modify on 100726,支持64位
|
||
#ifndef _WIN64
|
||
MessageBox(_T("打开XML文档失败!请安装MSXML4.0SP2组件"));
|
||
#else
|
||
MessageBox(_T("打开XML文档失败!请安装MSXML6.0组件"));
|
||
#endif
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
delete pXMLDoc;
|
||
pXMLDoc = NULL;
|
||
MessageBox(_T("xml文件不存在"));
|
||
return;
|
||
}
|
||
CXMLDOMNodePtr pRoot = pXMLDoc->GetRoot();
|
||
CString strAttriName = pRoot->GetAttributeName();
|
||
CString strAttriValue = pRoot->GetAttributeValue(strAttriName);
|
||
if (strAttriValue !=_T("上华软件设置"))
|
||
{
|
||
delete pXMLDoc;
|
||
pXMLDoc = NULL;
|
||
MessageBox(_T("该文件不是上华设置文件"));
|
||
return;
|
||
}
|
||
int nIndex =m_tab.GetActiveTab()/* GetActiveIndex()*/;
|
||
CString strPageName;
|
||
if (nIndex==0)
|
||
{
|
||
strPageName = _T("屏幕菜单");
|
||
}
|
||
else if (nIndex == 1)
|
||
{
|
||
strPageName = _T("操作配置");
|
||
}
|
||
else if (nIndex == 2)
|
||
{
|
||
strPageName = _T("基本界面");
|
||
}
|
||
else if (nIndex==3)
|
||
{
|
||
strPageName = _T("工具条");
|
||
}
|
||
else if (nIndex == 4)
|
||
{
|
||
strPageName = _T("快捷键");
|
||
}
|
||
CImportXMLDocDlg importDlg(pXMLDoc,strPageName);
|
||
if (importDlg.DoModal()==IDOK)
|
||
{
|
||
CTArchSettingEditTools setEditTool;
|
||
setEditTool.SetXMLDoc(pXMLDoc);
|
||
setEditTool.ImportAllTArchSettingData(importDlg.m_treeXmlDoc.m_mapData);
|
||
//当前窗口
|
||
CAdUiTabChildDialog* pPage =m_tab.GetDialogPointer(nIndex);
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
HWND hWnd;
|
||
//其他窗口为创建则不发送消息
|
||
switch (nIndex)
|
||
{
|
||
case 0:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(4);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
pPage =m_tab.GetDialogPointer(0);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(1);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(2);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
pPage =m_tab.GetDialogPointer(3);
|
||
hWnd = pPage->GetSafeHwnd();
|
||
if (hWnd!=NULL)
|
||
{
|
||
pPage->SendMessage(TARCH_SETTING_MSG_UPDATA);
|
||
}
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
std::map<CString,NodeInfoAry>::iterator iter;
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("屏幕菜单"));//界面1
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(0);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("操作配置"));//界面5
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(1);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("基本界面"));//界面2
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(2);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("工具条"));//界面3
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(3);
|
||
}
|
||
iter = importDlg.m_treeXmlDoc.m_mapData.find(_T("快捷键"));//界面4
|
||
if (iter!=importDlg.m_treeXmlDoc.m_mapData.end())
|
||
{
|
||
ApplyData(4);
|
||
}
|
||
}
|
||
delete pXMLDoc;
|
||
|
||
}
|
||
|
||
}
|
||
// COptionSheet 消息处理程序
|
||
BOOL COptionSheet::OnInitDialog()
|
||
{
|
||
BOOL bResult = CAcUiTabMainDialog::OnInitDialog();
|
||
SetAcadTabPointer(&m_tab);
|
||
/*int i = m_tab.GetActiveTab();*/
|
||
AddTab(0, _T("屏幕菜单"), CScreenMenuPage::IDD, &m_pageScreenMenu);
|
||
AddTab(1,_T("操作配置"),CUserOpreatorSet::IDD , &m_pageUserOperator);
|
||
AddTab(2, _T("基本界面"),CFontPropertyPage::IDD , &m_FontDlgPage);
|
||
AddTab(3, _T("工具条"),CSetToolbarPage::IDD , &m_pageToolBar);
|
||
AddTab(4, _T("快捷键"),CShortCutKeyPage::IDD , &m_pageShortCutKey);
|
||
m_tab.SetActiveTab(c_iSelectPage);
|
||
return bResult;
|
||
}
|
||
|
||
|
||
void COptionSheet::OnDestroy()
|
||
{
|
||
CAcUiTabMainDialog::OnDestroy();
|
||
|
||
//add by xlc on 090804 cancel时不保存数据
|
||
if (g_bCancel)
|
||
{
|
||
return;
|
||
}
|
||
c_iSelectPage = m_tab.GetActiveTab();
|
||
}
|
||
void COptionSheet::OnCancel()
|
||
{
|
||
g_bCancel = TRUE;
|
||
|
||
CAcUiTabMainDialog::OnCancel();
|
||
}
|
||
void COptionSheet::OnOK()
|
||
{
|
||
//int nTest =100;
|
||
m_FontDlgPage.SendMessage(TARCH_SETTING_MSG_BUTTONOK);
|
||
m_FontDlgPage.WriteIni();
|
||
CAcUiTabMainDialog::OnOK();
|
||
}
|
||
void COptionSheet::OnCommandHelp()
|
||
{
|
||
XString sTchIni;
|
||
CString csHelpFile;
|
||
if (FindFile(_T("tch.ini"), sTchIni))
|
||
{
|
||
INI_struct *inis=NULL;
|
||
if (CT_get_INIs(sTchIni, _T("Product"), &inis))
|
||
{
|
||
TCHAR *pHelpFile=CT_get_INI2(inis, _T("HelpFile"));
|
||
if (pHelpFile)
|
||
csHelpFile=pHelpFile;
|
||
CT_free_INIs(inis);
|
||
}
|
||
}
|
||
XString sFile;
|
||
if (FindFile((const TCHAR *)csHelpFile, sFile))
|
||
{
|
||
CString csHelpKey;
|
||
GetWindowText(csHelpKey);
|
||
HH_AKLINK link;
|
||
link.cbStruct = sizeof(HH_AKLINK) ;
|
||
link.fReserved = FALSE ;
|
||
link.pszKeywords = csHelpKey;
|
||
link.pszUrl = NULL ;
|
||
link.pszMsgText = NULL ;
|
||
link.pszMsgTitle = NULL ;
|
||
link.pszWindow = NULL ;
|
||
link.fIndexOnFail = TRUE ;
|
||
::HtmlHelp(NULL,(LPCTSTR)sFile,HH_DISPLAY_TOPIC ,NULL);
|
||
// Zyu modify on 100722,支持64位
|
||
//::HtmlHelp(NULL,(LPCTSTR)sFile,HH_KEYWORD_LOOKUP ,(DWORD)&link);
|
||
//::HtmlHelp(NULL,(LPCTSTR)sFile,HH_DISPLAY_INDEX ,(DWORD)(const TCHAR *)csHelpKey);
|
||
::HtmlHelp(NULL,(LPCTSTR)sFile,HH_KEYWORD_LOOKUP ,(DWORD_PTR)&link);
|
||
::HtmlHelp(NULL,(LPCTSTR)sFile,HH_DISPLAY_INDEX ,(DWORD_PTR)(const TCHAR *)csHelpKey);
|
||
}
|
||
}
|
||
/////////////////////
|
||
//add by xlc on 070924
|
||
CCommandDlg::CCommandDlg(CWnd* pParent /*=NULL*/)
|
||
: GlwCAcUiDialog(CCommandDlg::IDD, pParent)
|
||
{
|
||
m_iType = -1;
|
||
m_csCmd = _T("");
|
||
m_strCnName = _T("");
|
||
|
||
m_bClick = FALSE;
|
||
//{{AFX_DATA_INIT(CCommandDlg)
|
||
CodeBase db;
|
||
|
||
if (!FindFile(_T("tchdata.dbf"), m_xsDbfFile)) {
|
||
MessageBox(_T("对不起,没有发现tchdata.dbf文件!"));
|
||
return;
|
||
}
|
||
if (!FindFile(_T("TCH.DLL"), m_xsDllFile)) {
|
||
MessageBox(_T("对不起,没有发现TCH.DLL文件!"));
|
||
return;
|
||
}
|
||
|
||
CString csCmd, csName, csDescribe, csIcon, csType;
|
||
int iHit;
|
||
XDbfTable *pTable = db.Open(m_xsDbfFile);
|
||
if (pTable)
|
||
{
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF())
|
||
{
|
||
GET_FIELD(pTable, _T("chacmd"), csName);
|
||
GET_FIELD(pTable, _T("engcmd"), csCmd);
|
||
GET_FIELD(pTable, _T("explain"), csDescribe);
|
||
GET_FIELD(pTable, _T("icon"), csIcon);
|
||
GET_FIELD(pTable, _T("flag"), iHit);
|
||
GET_FIELD(pTable, _T("type"), csType);
|
||
m_lstToolbarData.Append(new CToolbarData(csType, csCmd, csName, csDescribe, csIcon, iHit));
|
||
if (m_lstType.Index(csType) < 0)
|
||
m_lstType.Append(tstrnew(csType));
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
//}}AFX_DATA_INIT
|
||
}
|
||
|
||
|
||
void CCommandDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CCommandDlg)
|
||
DDX_Control(pDX, IDC_LIST_CMD, m_listCmd);
|
||
DDX_Control(pDX, IDC_LIST_MENU, m_listMenu);
|
||
DDX_Control(pDX, IDC_LIST_TYPE, m_listType);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CCommandDlg, GlwCAcUiDialog)
|
||
//{{AFX_MSG_MAP(CCommandDlg)
|
||
// NOTE: the ClassWizard will add message map macros here
|
||
ON_NOTIFY(NM_CLICK, IDC_LIST_MENU, OnClickListMenu)
|
||
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_MENU, OnItemchangedListMenu)
|
||
ON_NOTIFY(NM_DBLCLK, IDC_LIST_CMD, OnDblClkListCmd)
|
||
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_CMD, OnItemchangedListCmd)
|
||
ON_LBN_SELCHANGE(IDC_LIST_TYPE, OnSelchangeListType)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CCommandDlg message handlers
|
||
BOOL CCommandDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
int len = m_lstType.Length();
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
m_listMenu.InsertItem(i,m_lstType[i]);
|
||
m_listType.AddString(m_lstType[i]);
|
||
}
|
||
int index = 0;
|
||
for(i = 0; i < m_lstToolbarData.Length(); i++)
|
||
{ CString csType = m_lstToolbarData[i]->m_csCmd;
|
||
if (m_strCnName.CompareNoCase(m_lstToolbarData[i]->m_csCmd)==0)
|
||
{
|
||
LVFINDINFO info;
|
||
info.flags = LVFI_PARTIAL|LVFI_STRING;
|
||
info.psz = m_lstToolbarData[i]->m_csType;
|
||
index = m_listMenu.FindItem(&info);
|
||
if (index == -1)
|
||
index = 0;
|
||
break;
|
||
}
|
||
}
|
||
m_listMenu.SetItemState(index,LVIS_SELECTED|LVIS_FOCUSED, 255);
|
||
m_listMenu.SetSelectionMark(index);
|
||
m_listMenu.EnsureVisible(index, TRUE);
|
||
m_listMenu.SetFocus();
|
||
|
||
GetDlgItem(IDC_EDIT_MENU)->SetWindowText(m_listMenu.GetItemText(index,0));
|
||
|
||
for(i = 0; i < m_lstToolbarData.Length(); i++)
|
||
{
|
||
if (m_strCnName.CompareNoCase(m_lstToolbarData[i]->m_csCmd)==0)
|
||
{
|
||
CString strType = m_lstToolbarData[i]->m_csType;
|
||
int index = m_listType.FindStringExact(-1,strType);
|
||
if (index != LB_ERR)
|
||
m_listType.SetCurSel(index);
|
||
break;
|
||
}
|
||
}
|
||
|
||
ResetListCmd();
|
||
|
||
LVFINDINFO info;
|
||
info.flags = LVFI_PARTIAL|LVFI_STRING;
|
||
if (i >= m_lstToolbarData.Length())
|
||
{
|
||
index = 0;
|
||
}
|
||
else
|
||
{
|
||
info.psz = m_lstToolbarData[i]->m_csName;
|
||
index = m_listCmd.FindItem(&info);
|
||
|
||
if (index == -1)
|
||
index = 0;
|
||
}
|
||
|
||
m_listCmd.SetFocus();
|
||
m_listCmd.SetItemState(index, LVIS_SELECTED|LVIS_FOCUSED, 255);
|
||
m_listCmd.SetSelectionMark(index);
|
||
m_listCmd.EnsureVisible(index, TRUE);
|
||
GetDlgItem(IDC_EDIT_CMD)->SetWindowText(m_listCmd.GetItemText(index,0));
|
||
return TRUE;
|
||
}
|
||
|
||
void CCommandDlg::ResetListCmd()
|
||
{
|
||
m_listCmd.DeleteAllItems();
|
||
m_imageCmd.DeleteImageList();
|
||
|
||
m_imageCmd.Create(16, 16, ILC_COLOR|ILC_MASK, 0, 32);
|
||
HINSTANCE hInstance = LoadLibrary(m_xsDllFile);
|
||
|
||
/* POSITION pos = m_listMenu.GetFirstSelectedItemPosition();
|
||
if (pos != NULL)
|
||
{
|
||
m_iType = m_listMenu.GetNextSelectedItem(pos);
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
*/
|
||
CString csType;
|
||
m_iType = m_listType.GetCurSel();
|
||
if (m_iType != -1)
|
||
{
|
||
m_listType.GetText(m_iType,csType);
|
||
}
|
||
/* CString csType;
|
||
if (m_iType>=0)
|
||
{
|
||
csType = m_listMenu.GetItemText(m_iType,0);
|
||
}
|
||
*/ else
|
||
{
|
||
return;
|
||
}
|
||
m_listCmd.SetImageList(&m_imageCmd, LVSIL_SMALL);
|
||
int len = m_lstToolbarData.Length();
|
||
int n=0;
|
||
for(int i=0;i<len;i++){
|
||
|
||
CString csChaName, csIcon, csCmdName, csAlias;
|
||
HBITMAP hBitmap;
|
||
if (m_lstToolbarData[i]->m_csType.CompareNoCase(csType)==0)
|
||
{
|
||
csChaName = m_lstToolbarData[i]->m_csName;
|
||
csCmdName = m_lstToolbarData[i]->m_csCmd;
|
||
if (csChaName == _T("") || csCmdName == _T(""))
|
||
continue;
|
||
|
||
csIcon = m_lstToolbarData[i]->m_csIcon;
|
||
hBitmap = LoadBitmap(hInstance, csIcon);
|
||
CBitmap bitmap;
|
||
bitmap.Attach(hBitmap);
|
||
m_imageCmd.Add(&bitmap, RGB(192, 192, 192));
|
||
TCHAR strText[64];
|
||
_tcscpy(strText, csChaName);
|
||
LV_ITEM listItem;
|
||
listItem.mask = LVIF_TEXT | LVIF_IMAGE;
|
||
listItem.iSubItem = 0;
|
||
listItem.iItem = n;
|
||
listItem.pszText = strText;
|
||
listItem.iImage = n;
|
||
m_listCmd.InsertItem( &listItem );
|
||
n++;
|
||
}
|
||
}
|
||
|
||
FreeLibrary(hInstance);
|
||
}
|
||
|
||
void CCommandDlg::OnClickListMenu(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
POSITION pos = m_listMenu.GetFirstSelectedItemPosition();
|
||
int index=-1;
|
||
if (pos != NULL)
|
||
{
|
||
index = m_listMenu.GetNextSelectedItem(pos);
|
||
}
|
||
if (m_iType == index)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_bClick = TRUE;
|
||
ResetListCmd();
|
||
|
||
m_listCmd.SetItemState(0, LVIS_SELECTED|LVIS_FOCUSED, 255);
|
||
m_listCmd.SetSelectionMark(0);
|
||
m_listCmd.EnsureVisible(0, TRUE);
|
||
|
||
ResetMenuTip();
|
||
ResetCmdTip();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CCommandDlg::OnItemchangedListMenu(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
if (m_bClick)
|
||
{
|
||
m_bClick = FALSE;
|
||
return;
|
||
}
|
||
ResetListCmd();
|
||
|
||
m_listCmd.SetItemState(0, LVIS_SELECTED|LVIS_FOCUSED, 255);
|
||
m_listCmd.SetSelectionMark(0);
|
||
m_listCmd.EnsureVisible(0, TRUE);
|
||
|
||
ResetMenuTip();
|
||
ResetCmdTip();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CCommandDlg::OnItemchangedListCmd(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
ResetCmdTip();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CCommandDlg::OnDblClkListCmd(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
OnOK();
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CCommandDlg::GetCurrentCmd()
|
||
{
|
||
POSITION pos = m_listCmd.GetFirstSelectedItemPosition();
|
||
int index=-1;
|
||
int n = m_listCmd.GetItemCount( );
|
||
if (pos != NULL)
|
||
{
|
||
index = m_listCmd.GetNextSelectedItem(pos);
|
||
m_strCnName = m_listCmd.GetItemText(index, 0);
|
||
for(int i = 0; i < m_lstToolbarData.Length(); i++)
|
||
{
|
||
if (m_strCnName.CompareNoCase(m_lstToolbarData[i]->m_csName)==0)
|
||
{
|
||
m_csCmd = m_lstToolbarData[i]->m_csCmd;
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
m_csCmd.Empty();
|
||
|
||
}
|
||
|
||
void CCommandDlg::OnOK()
|
||
{
|
||
GetCurrentCmd();
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
void CCommandDlg::ResetMenuTip()
|
||
{
|
||
POSITION pos = m_listMenu.GetFirstSelectedItemPosition();
|
||
int index=-1;
|
||
if (pos != NULL)
|
||
{
|
||
index = m_listMenu.GetNextSelectedItem(pos);
|
||
GetDlgItem(IDC_EDIT_MENU)->SetWindowText(m_listMenu.GetItemText(index,0));
|
||
}
|
||
}
|
||
void CCommandDlg::ResetCmdTip()
|
||
{
|
||
POSITION pos = m_listCmd.GetFirstSelectedItemPosition();
|
||
int index=-1;
|
||
if (pos != NULL)
|
||
{
|
||
index = m_listCmd.GetNextSelectedItem(pos);
|
||
GetDlgItem(IDC_EDIT_CMD)->SetWindowText(m_listCmd.GetItemText(index,0));
|
||
}
|
||
}
|
||
|
||
void CCommandDlg::OnSelchangeListType()
|
||
{
|
||
int iType = m_listType.GetCurSel();
|
||
if (iType == m_iType)
|
||
return;
|
||
|
||
ResetListCmd();
|
||
|
||
m_listCmd.SetItemState(0, LVIS_SELECTED|LVIS_FOCUSED, 255);
|
||
m_listCmd.SetSelectionMark(0);
|
||
m_listCmd.EnsureVisible(0, TRUE);
|
||
ResetCmdTip();
|
||
}
|
||
|
||
|
||
//add by xlc on 071018
|
||
CCommandPgpDlg::CCommandPgpDlg(CWnd* pParent /*=NULL*/)
|
||
: GlwCAcUiDialog(CCommandPgpDlg::IDD, pParent)
|
||
{
|
||
m_strCmd = _T("");
|
||
m_strType = _T("");
|
||
m_strTypeArray.RemoveAll();
|
||
|
||
//{{AFX_DATA_INIT(CCommandPgpDlg)
|
||
CodeBase db;
|
||
|
||
if (!FindFile(_T("acad.pgp"), m_xsAcadPgp)) {
|
||
MessageBox(_T("对不起,没有发现acad.pgp文件!"));
|
||
return;
|
||
}
|
||
|
||
CStdioFile file;
|
||
if (!file.Open(m_xsAcadPgp, CFile::modeRead))
|
||
{
|
||
AfxMessageBox(CString(_T("打开文件 \"")) + m_xsAcadPgp + _T("\" 失败"));
|
||
return ;
|
||
}
|
||
|
||
CString sString;
|
||
CString strType;
|
||
while(file.ReadString(sString))
|
||
{
|
||
TCHAR sKey[256] = _T("");
|
||
TCHAR sName[256] = _T("");
|
||
|
||
if (sString[0])
|
||
{
|
||
if (sString[0] == _T(';') && sString[1] == _T(';'))
|
||
{
|
||
strType = sString.Right(sString.GetLength()-2);
|
||
m_strTypeArray.Add(strType);
|
||
}
|
||
else if (sString[0] != _T(';'))
|
||
{
|
||
if (sString.Find(_T("*")) == -1 ||sString.Find(_T(":")) != -1)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
CString str = sString;
|
||
CPgpStruck pgpStruck;
|
||
CString strCmd = str.Right(str.GetLength()-str.Find(_T("*"))-1);
|
||
pgpStruck.m_strType = strType;
|
||
pgpStruck.m_strCmd = strCmd;
|
||
m_lstPgpCmd.AddTail(pgpStruck);
|
||
}
|
||
}
|
||
}
|
||
file.Close();
|
||
|
||
//}}AFX_DATA_INIT
|
||
}
|
||
|
||
|
||
void CCommandPgpDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CCommandPgpDlg)
|
||
DDX_Control(pDX, IDC_LIST_CMD, m_listCmd);
|
||
DDX_Control(pDX, IDC_LIST_TYPE, m_listType);
|
||
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CCommandPgpDlg, GlwCAcUiDialog)
|
||
//{{AFX_MSG_MAP(CCommandPgpDlg)
|
||
// NOTE: the ClassWizard will add message map macros here
|
||
ON_LBN_SELCHANGE(IDC_LIST_TYPE, OnSelchangeListType)
|
||
ON_LBN_DBLCLK(IDC_LIST_CMD, OnDblclkListCmd)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CCommandPgpDlg message handlers
|
||
BOOL CCommandPgpDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
// Zyu modify on 100722,支持64位
|
||
//int len = m_strTypeArray.GetSize();
|
||
INT_PTR len = m_strTypeArray.GetSize();
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
m_listType.InsertString(i,m_strTypeArray[i]);
|
||
}
|
||
|
||
for(i = 0; i < m_lstPgpCmd.GetLength(); i++)
|
||
{
|
||
if (m_strCmd.CompareNoCase(m_lstPgpCmd[i].m_strCmd)==0)
|
||
{
|
||
m_strType = m_lstPgpCmd[i].m_strType;
|
||
int index = m_listType.FindStringExact(-1,m_strType);
|
||
if (index != LB_ERR)
|
||
m_listType.SetCurSel(index);
|
||
break;
|
||
}
|
||
}
|
||
ResetListCmd();
|
||
|
||
if (i < m_lstPgpCmd.GetLength())
|
||
{
|
||
int index = m_listCmd.FindStringExact(-1,m_strCmd);
|
||
if (index != LB_ERR)
|
||
m_listCmd.SetCurSel(index);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
//重置命令列表
|
||
void CCommandPgpDlg::ResetListCmd()
|
||
{
|
||
m_listCmd.ResetContent();
|
||
int index = m_listType.GetCurSel();
|
||
if (index != -1)
|
||
{
|
||
m_listType.GetText(index,m_strType);
|
||
}
|
||
for(int i = 0; i < m_lstPgpCmd.GetLength(); i++)
|
||
{
|
||
if (m_strType.CompareNoCase(m_lstPgpCmd[i].m_strType)==0)
|
||
{
|
||
m_listCmd.AddString(m_lstPgpCmd[i].m_strCmd);
|
||
}
|
||
}
|
||
m_listCmd.SetCurSel(0);
|
||
}
|
||
|
||
void CCommandPgpDlg::OnSelchangeListType()
|
||
{
|
||
ResetListCmd();
|
||
}
|
||
|
||
void CCommandPgpDlg::OnDblclkListCmd()
|
||
{
|
||
OnOK();
|
||
}
|
||
void CCommandPgpDlg::OnOK()
|
||
{
|
||
int index = m_listCmd.GetCurSel();
|
||
if (index != LB_ERR)
|
||
{
|
||
m_listCmd.GetText(index,m_strCmd);
|
||
}
|
||
else
|
||
return;
|
||
|
||
CDialog::OnOK();
|
||
}
|
||
|