620 lines
17 KiB
C++
620 lines
17 KiB
C++
// SetToolbarDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "SetToolbarDlg.h"
|
|
#include "tapi.h"
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSetToolbarDlg dialog
|
|
//extern void CreateToolbars();
|
|
void SetToolbarCmd()
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
CSetToolbarDlg dlg;
|
|
if(!dlg.m_bInit)
|
|
return;
|
|
if(dlg.DoModal() == IDOK && dlg.m_bModifyToolbar)
|
|
CreateToolbars();
|
|
}
|
|
|
|
CSetToolbarDlg::CSetToolbarDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSetToolbarDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSetToolbarDlg)
|
|
m_iType = -1;
|
|
m_csAlias = _T("");
|
|
m_csCmd = _T("");
|
|
//}}AFX_DATA_INIT
|
|
m_bInit = FALSE;
|
|
m_bModifyAlias = FALSE;
|
|
m_bModifyToolbar = 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;
|
|
|
|
if(!FindFile(_T("acad.pgp"), m_xsAcadPgp)) {
|
|
MessageBox(_T("对不起,没有发现acad.pgp文件!"));
|
|
return;
|
|
}
|
|
ReadPgp();
|
|
}
|
|
|
|
|
|
|
|
void CSetToolbarDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSetToolbarDlg)
|
|
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(CSetToolbarDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CSetToolbarDlg)
|
|
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)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSetToolbarDlg message handlers
|
|
|
|
BOOL CSetToolbarDlg::OnInitDialog()
|
|
{
|
|
CDialog::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]);
|
|
m_iType = 0;
|
|
ResetListMenu();
|
|
ResetListToolbar();
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CSetToolbarDlg::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 == csSel){
|
|
// 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 == m_lstToolbarData[j]->m_csName){
|
|
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 );
|
|
m_bModifyToolbar = TRUE;
|
|
}
|
|
|
|
void CSetToolbarDlg::OnButRemove()
|
|
{
|
|
UpdateData(TRUE);
|
|
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;
|
|
}
|
|
}
|
|
m_bModifyToolbar = TRUE;
|
|
}
|
|
|
|
void CSetToolbarDlg::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 CSetToolbarDlg::OnSelchangeComboType()
|
|
{
|
|
UpdateData(TRUE);
|
|
m_csCmd = _T("");
|
|
m_csAlias = _T("");
|
|
UpdateData(FALSE);
|
|
|
|
ResetListMenu();
|
|
}
|
|
|
|
void CSetToolbarDlg::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);
|
|
}
|
|
|
|
const TCHAR* CSetToolbarDlg::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 CSetToolbarDlg::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);
|
|
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 == csType){
|
|
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 CSetToolbarDlg::OnOK()
|
|
{
|
|
if(m_bModifyToolbar){
|
|
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 == csSel){
|
|
iHit = i+2;
|
|
break;
|
|
}
|
|
}
|
|
SET_FIELD(pTable, _T("flag"), iHit);
|
|
pTable->MoveNext();
|
|
}
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
if(m_bModifyAlias){
|
|
WritePgp();
|
|
MessageBox(_T("已经成功修改ACAD.PGP文件!注意,只有重新启动ACAD,新快捷命令才有效!"));
|
|
}
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CSetToolbarDlg::OnDblclkListMenu(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
OnButAdd();
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CSetToolbarDlg::OnDblclkListToolbar(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
OnButRemove();
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CSetToolbarDlg::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 == csTmp1){
|
|
m_lstToolbarData[i]->m_iHit --;
|
|
}
|
|
if(m_lstToolbarData[i]->m_csName == csTmp2){
|
|
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();
|
|
m_bModifyToolbar = TRUE;
|
|
}
|
|
|
|
|
|
void CSetToolbarDlg::OnButtonDown()
|
|
{
|
|
UpdateData(TRUE);
|
|
int nSel = m_listToolbar.GetSelectionMark();
|
|
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 == csTmp1){
|
|
m_lstToolbarData[i]->m_iHit ++;
|
|
}
|
|
if(m_lstToolbarData[i]->m_csName == csTmp2){
|
|
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();
|
|
m_bModifyToolbar = 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);
|
|
}
|
|
|
|
//2011-6-21 SR 修改为只更改上华快捷命令
|
|
void CSetToolbarDlg::ReadPgp()
|
|
{
|
|
FILE *fp=fopen(_AS(m_xsAcadPgp), "r");
|
|
if(!fp)
|
|
return;
|
|
//m_lstAlias 只存储上华快捷命令
|
|
m_lstAlias.Reset();
|
|
BOOL bStart = FALSE;
|
|
while(!feof(fp)) {
|
|
char szBuf[256]="";
|
|
TCHAR szAlias[256]=_T(""), szCmd[256]=_T(""), szTmp[256]=_T("");
|
|
fgets(szBuf, 255, fp);
|
|
CString csTmp = szBuf;
|
|
if(csTmp.Find(_T("Tangent")) > -1)
|
|
bStart = TRUE;
|
|
if(!bStart)
|
|
continue;
|
|
|
|
if(szBuf[0] && szBuf[0] != ';') {
|
|
CT_strnth(TString(szBuf), 1, szAlias);
|
|
CT_strnth(TString(szBuf), 2, szCmd);
|
|
CT_strnth(TString(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 CSetToolbarDlg::WritePgp()
|
|
{
|
|
XStringList lstPgp;
|
|
FILE *fp=fopen(_AS(m_xsAcadPgp), "r");
|
|
if(!fp)
|
|
return;
|
|
while(!feof(fp)) {
|
|
char szBuf[256]="";
|
|
TCHAR szAlias[256]=_T(""), szCmd[256]=_T("");
|
|
fgets(szBuf, 255, fp);
|
|
CString csBuf = szBuf;
|
|
if(szBuf[0] && szBuf[0] != ';') {
|
|
CT_strnth(TString(szBuf), 1, szAlias);
|
|
CT_strnth(TString(szBuf), 2, szCmd);
|
|
CString csCmd = szCmd;
|
|
if(csCmd != _T("") && csCmd.Find(_T("*")) == 0 ){
|
|
csCmd = csCmd.Right(csCmd.GetLength() - 1);
|
|
for(int i=0;i<m_lstAlias.Length();i++){
|
|
CString csTmpCmd = m_lstAlias[i]->m_csDesName;
|
|
CString csTmpAlias = m_lstAlias[i]->m_csRecord;
|
|
if(_tcsicmp(csTmpCmd, csCmd) == 0){
|
|
if(_tcsicmp(szAlias, csTmpAlias) != 0){
|
|
csBuf = csTmpAlias;
|
|
if(csBuf == _T(""))
|
|
csBuf = _T("***");
|
|
else
|
|
csBuf = csBuf + _T(", *") + csCmd + _T("\n");
|
|
}
|
|
m_lstAlias.Remove(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(csBuf != _T("***"))
|
|
lstPgp.Append(tstrnew(csBuf));
|
|
}
|
|
fclose(fp);
|
|
|
|
for(int j=0;j<m_lstAlias.Length();j++){
|
|
CString csTmpCmd = m_lstAlias[j]->m_csDesName;
|
|
CString csTmpAlias = m_lstAlias[j]->m_csRecord;
|
|
CString csTmpBuf = csTmpAlias;
|
|
csTmpBuf = csTmpBuf + _T(", *") + csTmpCmd + _T("\n");
|
|
lstPgp.Append(tstrnew(csTmpBuf));
|
|
}
|
|
|
|
|
|
FILE *fp2 = fopen(_AS(m_xsAcadPgp), "w");
|
|
if(!fp2)
|
|
return;
|
|
int len = lstPgp.Length();
|
|
for(int i=0; i < len; i++){
|
|
CString csTmp = lstPgp[i];
|
|
if(csTmp != "" && csTmp[csTmp.GetLength()-1] != 10)
|
|
csTmp += "\n";
|
|
fputs(_AS(csTmp), fp2);
|
|
}
|
|
fclose(fp2);
|
|
|
|
}
|
|
|
|
void CSetToolbarDlg::OnItemchangedListMenu(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
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 == m_lstToolbarData[j]->m_csName){
|
|
m_csCmd = m_lstToolbarData[j]->m_csCmd;
|
|
m_csAlias = GetAlias(m_csCmd);
|
|
UpdateData(FALSE);
|
|
break;
|
|
}
|
|
}
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CSetToolbarDlg::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;
|
|
int len = m_lstAlias.Length();
|
|
for(int i=0;i<len;i++){
|
|
if(m_csAlias != _T("") && _tcsicmp(m_lstAlias[i]->m_csRecord, m_csAlias) == 0){
|
|
CString csTmp;
|
|
csTmp.Format(_T("与%s命令有冲突!"), m_lstAlias[i]->m_csDesName);
|
|
MessageBox(csTmp);
|
|
return;
|
|
}
|
|
}
|
|
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();
|
|
|
|
}
|