Objective Grid: Accelerators not working in conjunction with Objective Edit

Article ID: 712
Last updated: 11 Jun, 2018
Article ID: 712
Last updated: 11 Jun, 2018
Revision: 3
Views: 1763
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


I am using Objective Edit and Objective Grid as worksheets in the same CGXTabWnd but I have a problem with Accelerators eaten up by Objective Edit. How can I work around this?


Cause



Action


Here is the solution for this problem. The basic idea is to have two different accelerator tables - one for grid views and other views and one for the edit control. When both Objective Edit and Objective Grid are used in the same CGXTabWnd you can switch the accelerator tables in the MDI child window that holds the tab window.

Here are the steps:

Create a separate Accelerator table and a Menu with the same resource id in Resource Studio.

In InitInstance() create a document template:

m_pEditTemplate = new CMultiDocTemplate(
IDR_EDITVIEW,
RUNTIME_CLASS(CGridSampleDoc),
RUNTIME_CLASS(CScrltabsMDIChildWnd),
RUNTIME_CLASS(CObjectiveEditView));

(Don't call AddDocTemplate() - this is not necessary)

In ExitInstance() delete the template with

delete m_pEditTemplate;

In the CMDIChildWnd register the tabwindow as follows:

BOOL CScrltabsMDIChildWnd::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
CGridSampleApp* pApp = (CGridSampleApp*) AfxGetApp();

// Specify the runtime class for the
// first sheet don't forget to register
// the document template in InitInstance!
pContext->m_pNewViewClass = RUNTIME_CLASS(CGridSample9View);

// Creates the tab window
VERIFY(m_wndTab.Create(this, _T("What's New?"), pContext));

// Each view should associated with
// the same document. Next sheets

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample10View), _T("Float Cells"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample11View), _T("Sorting"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample12View), _T("Merge Cells"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample8View), _T("1.2 Features"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSampleView), _T("Simple"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample2View), _T("Formats"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample3View), _T("Base Styles"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample4View), _T("Welcome"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample5View), _T("More Controls"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample6View), _T("Grid Children"), pContext);

m_wndTab.CreateView(RUNTIME_CLASS(CGridSample7View), _T("Headers"), pContext);

pContext->m_pNewDocTemplate = pApp->m_pEditTemplate;

m_wndTab.CreateView(RUNTIME_CLASS(CObjectiveEditView), _T("Edit"), pContext);

return TRUE;

Finally, the most important step is the accelerator table swapping in OnUpdateFrameMenu():

void CScrltabsMDIChildWnd::OnUpdateFrameMenu(BOOL bActivate, CWnd* pActivateWnd, HMENU hMenuAlt)
{
CGridSampleApp* pApp = (CGridSampleApp*) AfxGetApp();

CMDIChildWnd::OnUpdateFrameMenu(bActivate, pActivateWnd, m_wndTab.GetBeam().GetTab(m_wndTab.GetBeam().GetCurSel()).hMenu);

if (m_wndTab.GetActivePane()->IsKindOf(RUNTIME_CLASS(CObjectiveEditView)))

m_hAccelTable = pApp->m_pEditTemplate->m_hAccelTable;
else
m_hAccelTable = pApp->m_pSplitterTemplate->m_hAccelTable;
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 712
Last updated: 11 Jun, 2018
Revision: 3
Views: 1763
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category