right mouse menu is gone in an item |
Post Reply |
Author | |
rienzi
Groupie Joined: 20 August 2009 Status: Offline Points: 38 |
Post Options
Thanks(0)
Posted: 20 August 2009 at 6:32am |
hi everybody, i'm a Chinese software developer, please help me
i established a SDI project in VC2005 and used XTToolkitPro.h in it i use task panel and Tab View in my application, the main user interface contains two vertical splitter in it. The two splitter divides the View into three parts. Task panel is in the left part, tab views in the middle and the right parts contains an wmp control. i think you can imagine the layout of my user interface in one of the Tab Views i add a CXTPPropertyGrid in it as how the sample shows me and then i adds CXTPPropertyGridItems in this control all the views are inherited from CFormView class the propertygrid control works well except one problem: the right mouse button diappears when i right click on an selected propertygrid item and i can not select the whole text in my propertygrid item with my mouse by clicking and dragging mouse as usual i think it is a big problem because clients have to use right button menu in an edit control and i don't know how to solve this problem i established another SDI application without tab views and task panel and splitter, the right mouse button works weill as i expect. This proves that my XTToolkitPro library runs normally here is all of my codes in the formview which contains my propertygrid control, please forget all the Chinese characters below //ProductView.h #pragma once #include "afxwin.h" class CProductView : public CFormView { DECLARE_DYNCREATE(CProductView) protected: CProductView(); // 动态创建所使用的受保护的构造函数 virtual ~CProductView(); public: enum { IDD = IDD_PRODUCT_VIEW }; #ifdef _DEBUG virtual void AssertValid() const; #ifndef _WIN32_WCE virtual void Dump(CDumpContext& dc) const; #endif #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 afx_msg LRESULT OnGridNotify(WPARAM, LPARAM); DECLARE_MESSAGE_MAP() public: CStatic m_wndPlaceHolder; virtual void OnInitialUpdate(); CXTPPropertyGrid m_wndPropertyGrid; afx_msg void OnSize(UINT nType, int cx, int cy); typedef void (CXTPPropertyGridItem::*ITEMFUNCTIONPTR)(); void _DoCollapseExpand(CXTPPropertyGridItems* pItems, ITEMFUNCTIONPTR pFunction); }; // ProductView.cpp // #include "stdafx.h" #include "AdksProductSys.h" #include "ProductView.h" // CProductView IMPLEMENT_DYNCREATE(CProductView, CFormView) CProductView::CProductView() : CFormView(CProductView::IDD) { } CProductView::~CProductView() { } void CProductView::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); DDX_Control(pDX, IDC_PLACEHOLDER, m_wndPlaceHolder); } BEGIN_MESSAGE_MAP(CProductView, CFormView) ON_WM_SIZE() ON_MESSAGE(XTPWM_PROPERTYGRID_NOTIFY, OnGridNotify) END_MESSAGE_MAP() // CProductView 诊断 #ifdef _DEBUG void CProductView::AssertValid() const { CFormView::AssertValid(); } #ifndef _WIN32_WCE void CProductView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif #endif //_DEBUG // CProductView 消息处理程序 void CProductView::_DoCollapseExpand(CXTPPropertyGridItems* pItems, ITEMFUNCTIONPTR pFunction) { for (int i = 0; i < pItems->GetCount(); i++) { CXTPPropertyGridItem* pItem = pItems->GetAt(i); if (pItem->HasChilds()) { (pItem->*pFunction)(); _DoCollapseExpand(pItem->GetChilds(), pFunction); } } } void CProductView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // TODO: 在此添加专用代码和/或调用基类 CRect rcClient; GetClientRect(&rcClient); //将属性控件设置为与视图一样宽 CRect rc; m_wndPlaceHolder.GetWindowRect(&rc); ScreenToClient(&rc); rc.right=rcClient.right; m_wndPlaceHolder.MoveWindow(0,0,rc.Width(),rc.Height()); //字体设置为原来的1.5倍 LOGFONT lfIcon; VERIFY( ::SystemParametersInfo( SPI_GETICONTITLELOGFONT, sizeof( lfIcon ), &lfIcon, 0 ) ); lfIcon.lfHeight *= 1.5; CFont fntNormal; fntNormal.CreateFontIndirect(&lfIcon ); m_wndPropertyGrid.SetFont(&fntNormal); //允许使用Tab键选择选项 m_wndPropertyGrid.NavigateItems(TRUE); if(m_wndPropertyGrid.Create(rc,this,IDC_PROPERTY_GRID)) { m_wndPropertyGrid.SetVariableItemsHeight(TRUE); CXTPPropertyGridItem *pFundamentals=m_wndPropertyGrid.AddCategory(_T("基本信息")); m_wndPropertyGrid.SetTheme(xtpGridThemeOffice2003); pFundamentals->SetTooltip(_T("修改产品基本信息")); pFundamentals->SetDescription(_T("按Tab键逐行修改产品基本信息")); COleDateTime dates; dates=COleDateTime::GetCurrentTime(); CXTPPropertyGridItemDate* pCreateDate=(CXTPPropertyGridItemDate*)pFundamentals->AddChildItem(new CXTPPropertyGridItemDate(_T("数据产生时间"),dates)); CXTPPropertyGridItemDate* pModifyDate=(CXTPPropertyGridItemDate*)pFundamentals->AddChildItem(new CXTPPropertyGridItemDate(_T("最后更改时间"),dates)); pCreateDate->SetDescription(_T("日期格式: 日/月/年")); pModifyDate->SetDescription(_T("日期格式: 日/月/年")); CXTPPropertyGridItem* pItem=pFundamentals->AddChildItem(new CXTPPropertyGridItem(_T("ISRC号"))); pFundamentals->AddChildItem(new CXTPPropertyGridItem(_T("ISBN号"))); pFundamentals->AddChildItem(new CXTPPropertyGridItem(_T("条码"))); pFundamentals->AddChildItem(new CXTPPropertyGridItem(_T("产品名称"))); pFundamentals->AddChildItem(new CXTPPropertyGridItem(_T("系列名称"))); pFundamentals->AddChildItem(new CXTPPropertyGridItemDouble(_T("定价"))); CXTPPropertyGridItem *pPublish=m_wndPropertyGrid.AddCategory(_T("出版信息")); pPublish->SetTooltip(_T("修改产品出版信息")); pPublish->SetDescription(_T("按Tab键逐行修改产品出版信息")); pFundamentals->AddChildItem(new CXTPPropertyGridItem(_T("出版单位"))); CXTPPropertyGridItemDate* pFirstVersionDate=(CXTPPropertyGridItemDate*)pPublish->AddChildItem(new CXTPPropertyGridItemDate(_T("首版年月"),dates)); CXTPPropertyGridItemDate* pCurrentVersionDate=(CXTPPropertyGridItemDate*)pPublish->AddChildItem(new CXTPPropertyGridItemDate(_T("本版年月"),dates)); pFirstVersionDate->SetDescription(_T("日期格式: 日/月/年")); pCurrentVersionDate->SetDescription(_T("日期格式: 日/月/年")); pPublish->AddChildItem(new CXTPPropertyGridItemNumber(_T("发行数量"))); pPublish->AddChildItem(new CXTPPropertyGridItem(_T("出版地"))); pPublish->AddChildItem(new CXTPPropertyGridItem(_T("装帧"))); CXTPPropertyGridItem* pCategory1=pPublish->AddChildItem(new CXTPPropertyGridItemEnum(_T("中图分类法"),0)); pCategory1->GetConstraints()->AddConstraint(_T("分类1"),0); pCategory1->GetConstraints()->AddConstraint(_T("分类2"),1); pCategory1->GetConstraints()->AddConstraint(_T("分类3"),2); CXTPPropertyGridItem* pCategory2=pPublish->AddChildItem(new CXTPPropertyGridItemEnum(_T("销售分类法"),0)); pCategory2->GetConstraints()->AddConstraint(_T("分类1"),0); pCategory2->GetConstraints()->AddConstraint(_T("分类2"),1); pCategory2->GetConstraints()->AddConstraint(_T("分类3"),2); CXTPPropertyGridItem* pCategory3=pPublish->AddChildItem(new CXTPPropertyGridItemEnum(_T("自身分类法"),0)); pCategory3->GetConstraints()->AddConstraint(_T("分类1"),0); pCategory3->GetConstraints()->AddConstraint(_T("分类2"),1); pCategory3->GetConstraints()->AddConstraint(_T("分类3"),2); CXTPPropertyGridItem *pContent=m_wndPropertyGrid.AddCategory(_T("人员和内容")); pContent->SetTooltip(_T("修改产品相关人员和内容信息")); pContent->SetDescription(_T("按Tab键逐行修改相关人员和内容信息")); pContent->AddChildItem(new CXTPPropertyGridItem(_T("主题词"))); CXTPPropertyGridItem* pPersonnel=pContent->AddChildItem(new CXTPPropertyGridItemCategory(_T("相关人员"))); pPersonnel->SetID(XTP_ID_PROPERTYGRID_PERSONNEL); pPersonnel->SetTooltip(_T("修改产品相关人员信息")); pItem=pPersonnel->AddChildItem(new CXTPPropertyGridItem(_T("身份"))); pItem->SetDescription(_T("编辑相关人员的身份,点击按钮添加相关人员")); pItem->SetID(510); pItem->SetFlags(xtpGridItemHasEdit | xtpGridItemHasComboButton); pItem->GetConstraints()->AddConstraint(_T("作者"),0); pItem->GetConstraints()->AddConstraint(_T("演讲者"),1); pItem->GetConstraints()->AddConstraint(_T("导演"),2); CXTPPropertyGridInplaceButton* pButton=pItem->GetInplaceButtons()->AddButton(new CXTPPropertyGridInplaceButton(1)); pButton->SetCaption(_T("添加相关人员")); CXTPPropertyGridItem* pAbstract=pContent->AddChildItem(new CXTPPropertyGridItem(_T("内容摘要"))); pAbstract->SetMultiLinesCount(4); pAbstract->SetEditStyle(ES_MULTILINE | ES_AUTOVSCROLL); pAbstract->SetDescription(_T("编辑内容摘要")); _DoCollapseExpand(m_wndPropertyGrid.GetCategories(),&CXTPPropertyGridItem::Expand); } } void CProductView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: 在此处添加消息处理程序代码 if(IsWindow(m_wndPlaceHolder.m_hWnd)) { m_wndPlaceHolder.MoveWindow(0,0,cx,500,FALSE); } if(IsWindow(m_wndPropertyGrid.m_hWnd)) { m_wndPropertyGrid.MoveWindow(0,0,cx,500,FALSE); } } LRESULT CProductView::OnGridNotify(WPARAM wParam, LPARAM lParam) { if(wParam == XTP_PGN_INPLACEBUTTONDOWN) { CXTPPropertyGridInplaceButton* pButton = (CXTPPropertyGridInplaceButton*)lParam; if(pButton->GetItem()->GetID() == 510 && pButton->GetID() == 1) //Item的ID=510是"身份"项的ID, 按钮ID=1是"添加相关人员"按钮的ID { CString Status=pButton->GetItem()->GetValue(); if(Status==_T("")) AfxMessageBox(_T("请填写相关人员身份")); else { CXTPPropertyGridItem* pItem=0; pItem=m_wndPropertyGrid.FindItem(XTP_ID_PROPERTYGRID_PERSONNEL); if(pItem) { CXTPPropertyGridItem* pAddedPersonnel=pItem->AddChildItem(new CXTPPropertyGridItem(Status)); pAddedPersonnel->SetID(520); //Item的ID=520是添加后的相关人员项的ID pAddedPersonnel->SetDescription(_T("编辑姓名,点击删除按钮删除此项")); CXTPPropertyGridInplaceButton* pButton=pAddedPersonnel->GetInplaceButtons()->AddButton(new CXTPPropertyGridInplaceButton(2)); //按钮ID=2是添加后的相关人员项的ID pButton->SetCaption(_T("删除")); } } return TRUE; } else if(pButton->GetItem()->GetID() == 520 && pButton->GetID() ==2) { pButton->GetItem()->Remove(); } } return 0; } and here is the codes of CMainFrame class object // MainFrm.h // #pragma once class CMainFrame : public CXTPFrameWnd { protected: // 仅从序列化创建 CMainFrame(); DECLARE_DYNCREATE(CMainFrame) // 属性 public: CXTSplitterWndEx m_wndSplitter; CXTPTaskPanel m_wndTaskPanel; // 操作 public: BOOL CreateTaskPanel(); // 重写 public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); // 实现 public: virtual ~CMainFrame(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // 控件条嵌入成员 CXTPStatusBar m_wndStatusBar; //CToolBar m_wndToolBar; //不用MFC的状态条,因此将它注释掉 void CreateTaskPanelItems(); // 生成的消息映射函数 protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnCustomize(); afx_msg void OnUpdateCustomize(CCmdUI *pCmdUI); afx_msg LRESULT OnTaskPanelNotify(WPARAM wParam,LPARAM lParam); DECLARE_MESSAGE_MAP() public: afx_msg void OnClose(); protected: virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); }; // MainFrm.cpp // #include "stdafx.h" #include "AdksProductSys.h" #include "MainFrm.h" #include "VideoPlayerView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() ON_COMMAND(XTP_ID_CUSTOMIZE,OnCustomize) ON_UPDATE_COMMAND_UI(XTP_ID_CUSTOMIZE,OnUpdateCustomize) ON_WM_CLOSE() ON_MESSAGE(XTPWM_TASKPANEL_NOTIFY,OnTaskPanelNotify) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // 状态行指示器 ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; // CMainFrame 构造/析构 CMainFrame::CMainFrame() { // TODO: 在此添加成员初始化代码 } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; //创建状态条 //注意:所有控制条包括状态条都必须在 //命令条以前创建 if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } //初始化命令栏 if(!InitCommandBars()) return -1; //获得一个控制栏对象的指针 CXTPCommandBars* pCommandBars=GetCommandBars(); if(pCommandBars==NULL) { TRACE0("创建控制栏对象失败\n"); return -1; //创建失败 } //加入菜单栏 CXTPCommandBar* pMenuBar=pCommandBars->SetMenu(_T("菜单"),IDR_MAINFRAME); if(pMenuBar==NULL) { TRACE0("创建菜单栏失败"); return -1; //创建失败 } //创建工具栏 CXTPToolBar *pToolBar=(CXTPToolBar*)pCommandBars->Add(_T("工具栏"),xtpBarTop); if(!pToolBar||!pToolBar->LoadToolBar(IDR_MAINFRAME)) { TRACE0("创建工具栏失败"); return -1; //创建失败 } //设置Office2003主题 CXTPPaintManager::SetTheme(/*xtpThemeVisualStudio2008*//*xtpThemeNativeWinXP*/xtpThemeOffice2003); //为工具栏和菜单读取以前的状态 //LoadCommandBars (_T("CommandBars")); //暂时不用 /* if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } // TODO: 如果不需要工具栏可停靠,则删除这三行 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); */ return 0; } void CMainFrame::OnCustomize() { //获得一个命令栏对象指针 CXTPCommandBars* pCommandBars=GetCommandBars(); if(pCommandBars!=NULL) { //实例化自定义对话框对象 CXTPCustomizeSheet dlg(pCommandBars); //增加键盘页到自定义对话框 CXTPCustomizeKeyboardPage pageKeyboard(&dlg); dlg.AddPage(&pageKeyboard); pageKeyboard.AddCategories(IDR_MAINFRAME); //增加选项页到实例化对话框 CXTPCustomizeOptionsPage pageOptions(&dlg); dlg.AddPage(&pageOptions); //增加命令页到实化对话框 CXTPCustomizeCommandsPage* pCommands=dlg.GetCommandsPage(); pCommands->AddCategories(IDR_MAINFRAME); //利用命令栏管理器初始化自定义对话框 pCommands->InsertAllCommandsCategory(); pCommands->InsertBuiltInMenus(IDR_MAINFRAME); pCommands->InsertNewMenuCategory(); //显示对话框 dlg.DoModal(); } } void CMainFrame::OnUpdateCustomize(CCmdUI *pCmdUI) { pCmdUI->Enable(FALSE); } void CMainFrame::OnClose() { // TODO: 在此添加消息处理程序代码和/或调用默认值 //为工具栏和菜单保存现有状态 //SaveCommandBars(_T("CommandBars")); //暂时不用 CXTPFrameWnd::OnClose(); } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: 在此处通过修改 // CREATESTRUCT cs 来修改窗口类或样式 cs.lpszClass=_T("XTPMainFrame"); CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(),cs.lpszClass,CS_DBLCLKS,AfxGetApp()->LoadIcon(IDR_MAINFRAME)); cs.style|=WS_CLIPCHILDREN|WS_CLIPSIBLINGS; return TRUE; } void CMainFrame::CreateTaskPanelItems() { CXTPTaskPanelGroup* pGroupProduct=m_wndTaskPanel.AddGroup(ID_TASKGROUP_PRODUCT); pGroupProduct->AddLinkItem(ID_TASKITEM_NEW); pGroupProduct->AddLinkItem(ID_TASKITEM_SEARCH); pGroupProduct->SetSpecialGroup(); CXTPTaskPanelGroup* pGroupProductInfo=m_wndTaskPanel.AddGroup(ID_TASKGROUP_PRODUCTINFO); pGroupProductInfo->AddLinkItem(ID_TASKITEM_EDITPRODUCTINFO); CXTPTaskPanelGroup* pGroupVideoInfo=m_wndTaskPanel.AddGroup(ID_TASKGROUP_VIDEOINFO); pGroupVideoInfo->AddLinkItem(ID_TASKITEM_EDITVIDEOINFO); CXTPTaskPanelGroup* pGroupDraftInfo=m_wndTaskPanel.AddGroup(ID_TASKGROUP_DRAFTINFO); pGroupDraftInfo->AddLinkItem(ID_TASKITEM_DRAFTINFO); pGroupDraftInfo->AddLinkItem(ID_TASKITEM_ORTHERINFO); //m_wndTaskPanel.GetImageManager()->SetIcons(XTPImageManager()->IsAlphaIconsSupported()? //IDB_TASKICONS_ALPHA: IDB_TASKICONS_NORMAL, 0, 0, CSize(16, 16)); //m_wndTaskPanel.GetImageManager()->SetIcon(IDI_SYSTEM_TASKS, IDI_SYSTEM_TASKS, CSize(32, 32)); } BOOL CMainFrame::CreateTaskPanel() { if (!m_wndTaskPanel.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP, CRect(0, 0, 0, 0), &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0))) return FALSE; m_wndTaskPanel.SetOwner(this); m_wndSplitter.SetColumnInfo(0, 210, 0); CreateTaskPanelItems(); return TRUE; } // CMainFrame 诊断 #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG // CMainFrame 消息处理程序 BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { // TODO: 在此添加专用代码和/或调用基类 m_wndSplitter.CreateStatic(this,1,3); if(!CreateTaskPanel()) return FALSE; CRect rect; GetClientRect(&rect); m_wndSplitter.CreateView(0,1,pContext->m_pNewViewClass,CSize(rect.Width()*3/4,rect.Height()),pContext); m_wndSplitter.CreateView(0,2,RUNTIME_CLASS(CVideoPlayerView),CSize(rect.Width()/4,rect.Height()),pContext); m_wndSplitter.ShowTopBorder(FALSE,0); return TRUE; //return CXTPFrameWnd::OnCreateClient(lpcs, pContext); } LRESULT CMainFrame::OnTaskPanelNotify(WPARAM wParam,LPARAM lParam) //在任务面板某项中点击了左键 { /* switch(wParam) { case XTP_TPN_CLICK: { CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)lParam; TRACE(_T("Click Event: pItem.Caption = %s, pItem.ID = %i\n"), pItem->GetCaption(), pItem->GetID()); } break; case XTP_TPN_RCLICK: { CXTPTaskPanelItem* pItem = (CXTPTaskPanelItem*)lParam; TRACE(_T("RClick Event: pItem.Caption = %s, pItem.ID = %i\n"), pItem->GetCaption(), pItem->GetID()); } break; } */ return 0; } i think my Chinese English did not confuse you and i am really confused by this problem for days and prone to psychological collapse, please give me some time and give me a solution, thousands of thanks |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Please attach whole sample code that can be debug.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |