Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Gunasekaran Velu
|
Oct 6, 2005 - 1:09 AM
|
hi folks i want to display the message when tab menu is clicked in the CExtTabPageContainerFlatWnd Thanks in Advance Guna
|
|
Technical Support
|
Oct 6, 2005 - 1:48 PM
|
The pop-up menu with a tab list is called in the CExtTabWnd::OnTabWndClickedButton() virtual method, so, if you want to change the default behavior, you need to override this method in your CExtTabFlatWnd -derived class (i.e. CYourTabFlatWnd ). Then you need to override the OnTabWndGetTabImpl() method in the CExtTabPageContainerFlatWnd -derived class and return your CYourTabFlatWnd object: virtual CExtTabWnd* OnTabWndGetTabImpl()
{
return new CExtTWPC < CYourTabFlatWnd >;
}
|
|
Gunasekaran Velu
|
Oct 6, 2005 - 11:50 PM
|
this is my code class CManagedTabPageContainer : public CExtTabPageContainerFlatWnd { class CManagedTabWnd : public CExtTabFlatWnd { int m_nShift; int m_nSize; public: CManagedTabWnd(){ m_nShift=-1; m_nSize=-1; } int GetShift(){ CRect rc; GetWindowRect(rc); return _CalcRgnShift( OrientationIsHorizontal(), rc ); } int GetSize(){ return OnFlatTabWndGetSize( OrientationIsHorizontal() ); } void SetShift( int nShift ){ m_nShift = nShift; } void SetSize( int nSize ){ m_nSize = nSize; } protected: virtual int _CalcRgnShift( bool bHorz, const CRect & rc ) { int nShift = 0; if( m_nShift >= 0 ) nShift = m_nShift; else nShift = ::MulDiv( bHorz ? rc.Height() : rc.Width(), 1, 4 ); return nShift; } virtual int OnFlatTabWndGetSize( bool bHorz ) { int nSize = 0; if(bHorz) if( m_nSize > 0 ) nSize = m_nSize; else nSize = 16;//::GetSystemMetrics( SM_CXHSCROLL ); else if( m_nSize > 0 ) nSize = m_nSize; else nSize = 16;//::GetSystemMetrics( SM_CYHSCROLL ); return nSize; } }; // class CManagedTabWnd virtual CExtTabWnd* OnTabWndGetTabImpl(){ return new CExtTWPC < CManagedTabWnd >; } virtual bool OnTabWndClickedButton( LONG nHitTest, bool bButtonPressed, INT nMouseButton, // MK_... values UINT nMouseEventFlags) { ASSERT_VALID( this ); nMouseButton; nMouseEventFlags; if( nHitTest==__ETWH_BUTTON_CLOSE && !bButtonPressed ){ CString s; s.Format(_T("\"Close\" button clicked on page - %d"), PageSelectionGet()); AfxMessageBox(s); } if( nHitTest==__ETWH_BUTTON_HELP && !bButtonPressed ){ CString s; s.Format(_T("\"Help\" button clicked on page - %d"), PageSelectionGet()); AfxMessageBox(s); } Invalidate(); return true; } public: void SetShift( int nShift ){ ((CManagedTabWnd*)m_pWndTab)->SetShift( nShift ); ((CManagedTabWnd*)m_pWndTab)->UpdateTabWnd(); } void SetSize( int nSize ){ ((CManagedTabWnd*)m_pWndTab)->SetSize( nSize ); ((CManagedTabWnd*)m_pWndTab)->UpdateTabWnd(); _RepositionBarsImpl(); } int GetShift(){ return ((CManagedTabWnd*)m_pWndTab)->GetShift(); } int GetSize(){ return ((CManagedTabWnd*)m_pWndTab)->GetSize(); } }; // class CManagedTabPageContainer the above code in MainFrm.h in my pgm.i have overwrite the OnTabWndClickedButton() method( see above) but when i debug the pgm and i clicked the tab menu but the should not fire the OnTabWndClickedButton() this function. can u help me.
|
|
Technical Support
|
Oct 7, 2005 - 5:25 AM
|
You need to override the OnTabWndClickedButton method in the CManagedTabWnd class (not in CManagedTabPageContainer ), because CTabPageContainerFlatWnd::OnTabWndClickedButton() is called after it was called in CExtTabWnd . Below is a OnTabWndClickedButton() method which should be inserted into the CManagedTabWnd class. When you select a new page in the pop-up menu, the message box will appear with a question "Do you want to select the _NAME_ page?". It seem it is what you are asking about. virtual bool OnTabWndClickedButton(
LONG nHitTest,
bool bButtonPressed,
INT nMouseButton, // MK_... values
UINT nMouseEventFlags
)
{
ASSERT_VALID( this );
nMouseEventFlags;
if( (! bButtonPressed)
&& nMouseButton == MK_LBUTTON
&& nHitTest == __ETWH_BUTTON_TAB_LIST
&& (GetTabWndStyle() & __ETWS_ENABLED_BTN_TAB_LIST) != 0
&& (ItemGetCount() > 0)
)
{
// show tab list popup menu
CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
if( pPopup->CreatePopupMenu( GetSafeHwnd() ) )
{
UINT nStartID = 0xffff;
for( LONG nIndex = 0; nIndex < m_arrItems.GetSize(); nIndex++ )
{
TAB_ITEM_INFO * pTii = ItemGet( nIndex );
if( pTii != NULL )
{
bool bGrouped = (GetTabWndStyle()&__ETWS_GROUPED) ? true : false;
if( bGrouped
&& nIndex != 0
)
{
LONG nGroupStart;
LONG nGroupEnd;
ItemGetGroupRange(
nIndex,
nGroupStart,
nGroupEnd
);
if( nGroupStart == nIndex )
VERIFY( pPopup->ItemInsertCommand( CExtPopupMenuWnd::TYPE_SEPARATOR, -1 ) );
}
CExtCmdIcon* pCmdIcon = OnTabWndQueryItemIcon(pTii);
HICON hIcon = NULL;
if( pCmdIcon )
hIcon =
pCmdIcon->IsEmpty()
? NULL
: pCmdIcon->GetIcon();
VERIFY(
pPopup->ItemInsertCommand(
nStartID + nIndex,
-1,
pTii->TextGet(),
NULL,
hIcon,
true,
( SelectionGet() == nIndex )
)
);
}
}
CPoint ptTrack( m_rcBtnTabList.left, m_rcBtnTabList.bottom );
ClientToScreen( &ptTrack );
CRect rcExcludeArea( m_rcBtnTabList );
ClientToScreen( &rcExcludeArea );
DWORD nAlign = TPMX_LEFTALIGN;
switch( __ETWS_ORIENT_MASK & OrientationGet() )
{
case __ETWS_ORIENT_TOP:
nAlign = TPMX_TOPALIGN;
break;
case __ETWS_ORIENT_BOTTOM:
nAlign = TPMX_BOTTOMALIGN;
break;
case __ETWS_ORIENT_LEFT:
nAlign = TPMX_LEFTALIGN;
break;
case __ETWS_ORIENT_RIGHT:
nAlign = TPMX_RIGHTALIGN;
break;
}
UINT nCmdRetVal = 0;
HWND hWndOwn = m_hWnd;
if( pPopup->TrackPopupMenu(
TPMX_OWNERDRAW_FIXED
| nAlign
| TPMX_COMBINE_DEFAULT
| TPMX_DO_MESSAGE_LOOP
| TPMX_NO_WM_COMMAND
| TPMX_NO_CMD_UI
| TPMX_NO_HIDE_RARELY,
ptTrack.x,
ptTrack.y,
&rcExcludeArea,
NULL,
_CbPaintCombinedTabListBtnContent,
&nCmdRetVal
)
)
{
if( ! ::IsWindow(hWndOwn) )
return true;
// user selected the nCmdRetVal item
if( nCmdRetVal != 0 )
{
CString s;
s.Format(
_T("Do you want to select the %s page?"),
ItemTextGet( nCmdRetVal - nStartID )
);
if( IDYES == AfxMessageBox( s, MB_YESNO ) )
SelectionSet( nCmdRetVal - nStartID , true, true );
}
Invalidate();
}
else
{
ASSERT( FALSE );
delete pPopup;
}
if( ! ::IsWindow(hWndOwn) )
return true;
}
else
{
ASSERT( FALSE );
delete pPopup;
}
return true;
}
return
CExtTabFlatWnd::OnTabWndClickedButton(
nHitTest,
bButtonPressed,
nMouseButton,
nMouseEventFlags
);
}
|
|
Gunasekaran Velu
|
Oct 8, 2005 - 5:32 AM
|
i tried this funtion in CManagedTabWnd but i did not get the answer. ok where can i over write this function MainFrm.h or MainFrm.cpp Thanks Guna
|
|
Technical Support
|
Oct 10, 2005 - 5:25 AM
|
We have just sent you the TabPages sample with which we tested the behavior discussed earlier.
|
|