Developers

Adding multiple tabs

A place for developers to exchange information about extending OmniPeek, and ask technical questions about plugins on MyPeek, scripting, and programming.
gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

Adding multiple tabs

Postby gdvc84@motorola.com » Tue Jul 20, 2010 5:55 pm

Hi,

I am trying to add a 2nd tab to my plug-in. I’m not quite sure how do I do this easily. This is what I’ve figured out:

General approach:
- DoAddTab() returns HWND to me
- This, I assume is a location in the window assigned for my tab
- I have to create a dialog based on a template and map it to HWND above

Looking at how it is done now,

- DoAddTab() returns HWND
- Using a TabParent class, the HWND is subclassed – so that the messages get routed through TabParent class
- A new dialog is created with the template and TabParent as parameters

The above works fine for one tab. To add the second tab, If my understanding is right, then I will have to have 2 TabParent objects inside my C*Context class. Am I right? Is there any other way to do it?

Thanks,

Spacepacket
Posts: 78
Joined: Thu May 22, 2008 9:36 am

RE: Adding multiple tabs

Postby Spacepacket » Wed Jul 21, 2010 11:57 am

Hi gdvc84. Yes, you need a CTabParent for each tab.

Here is a sample from the Roaming plug-in, which creates 3 tabs:

// ----------------------------------------------------------------------------
// Init
// ----------------------------------------------------------------------------

int
CRoamingContext::Init(
PluginCreateContextParam* ioParams )
{
CPeekContext::Init( ioParams );

HWND hLogTabWnd = NULL;
int nResult = DoAddTabWithGroup(
_T( "Log" ),
_T( "Roaming" ),
_T( "STATIC" ),
(void**) &hLogTabWnd );

ASSERT( nResult == 0 );
if ( nResult != 0 ) return PLUGIN_RESULT_ERROR;
ASSERT( hLogTabWnd != NULL );
if ( hLogTabWnd == NULL ) return PLUGIN_RESULT_ERROR;


HWND hAvgTabWnd = NULL;
nResult = DoAddTabWithGroup(
_T( "by Node" ),
_T( "Roaming" ),
_T( "STATIC" ),
(void**) &hAvgTabWnd );

ASSERT( nResult == 0 );
if ( nResult != 0 ) return PLUGIN_RESULT_ERROR;
ASSERT( hAvgTabWnd != NULL );
if ( hAvgTabWnd == NULL ) return PLUGIN_RESULT_ERROR;


HWND hAPTabWnd = NULL;
nResult = DoAddTabWithGroup(
_T( "by AP" ),
_T( "Roaming" ),
_T( "STATIC" ),
(void**) &hAPTabWnd );

ASSERT( nResult == 0 );
if ( nResult != 0 ) return PLUGIN_RESULT_ERROR;
ASSERT( hAPTabWnd != NULL );
if ( hAPTabWnd == NULL ) return PLUGIN_RESULT_ERROR;

AFX_MANAGE_STATE( AfxGetStaticModuleState() );

// Subclass the static window Peek created.
#undef SubclassWindow // The MSVC compiler picks up this macro

m_LogTabParent.SubclassWindow( hLogTabWnd ); // instead of this function.
m_NodeTabParent.SubclassWindow( hAvgTabWnd ); // instead of this function.
m_APTabParent.SubclassWindow( hAPTabWnd ); // instead of this function.

// Create a dialog to be embedded in the Parent window. The Parent window will delete it.
m_pLogTab = new CRoamingLogTab;
ASSERT( m_pLogTab != NULL );
if ( m_pLogTab == NULL ) return PLUGIN_RESULT_ERROR;

m_pLogTab->SetContext( this );
m_pLogTab->Create( IDD_Roaming_TAB, &m_LogTabParent );
m_LogTabParent.SetChild( m_pLogTab );
m_pLogTab->ShowWindow( SW_SHOW );


// Create a dialog to be embedded in the Parent window. The Parent window will delete it.
m_pNodeTab = new CRoamingNodeTab;
ASSERT( m_pNodeTab != NULL );
if ( m_pNodeTab == NULL ) return PLUGIN_RESULT_ERROR;

m_pNodeTab->SetContext( this );
m_pNodeTab->Create( IDD_Roaming_TAB, &m_NodeTabParent );
m_NodeTabParent.SetChild( m_pNodeTab );
m_pNodeTab->ShowWindow( SW_SHOW );


// Create a dialog to be embedded in the Parent window. The Parent window will delete it.
m_pAPTab = new CRoamingAPTab;
ASSERT( m_pAPTab != NULL );
if ( m_pAPTab == NULL ) return PLUGIN_RESULT_ERROR;

m_pAPTab->SetContext( this );
m_pAPTab->Create( IDD_Roaming_TAB, &m_APTabParent );
m_APTabParent.SetChild( m_pAPTab );
m_pAPTab->ShowWindow( SW_SHOW );

return PLUGIN_RESULT_SUCCESS;
}


Return to “Developers”

Who is online

Users browsing this forum: No registered users and 2 guests