Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS General Discussion » MDI Tab Window Again Collapse All
Subject Author Date
James Hughes Sep 28, 2003 - 2:47 AM

Hi

One small problem that I am having is with text displayed on the tab for a MDI window. I have two MDI windows with different names, however the text on all tab buttons is the name for which ever tab window is created/added first.

I use the CreateNewChild method of the CMDIFrameWnd class to create/add a new MDI window. I have a class derived from CExtTabMdiWnd, stepping through the OnTabWndItemInsert method and looking at the m_sText member
after calling the base class OnTabWndItemInsert being empty. If I set the text based on the title of the window for the item being insert has no effect.

Also looked at the OnTabWndDrawItem function, which has is passed text to be displayed in the tab. Even if I have set the items text (see above) this value is always the first window title.

Am I missing something here or being stupid ? :o)

Cheers
James

Sergiy Lavrynenko Sep 29, 2003 - 2:38 AM

Dear James,

CExtTabMdiWnd uses title of the active document as tab’s text. If no document - it uses title of the frame window. This techique is implemented in the CExtTabMdiWnd::OnTabWndQueryItemText() method. If you want to see tab text equal to the caption of appropriate MDI child frames, please use CExtTabMdiWnd-derived class like this:

class CMyTabs : public CExtTabMdiWnd
{
protected:
	virtual __EXT_MFC_SAFE_LPCTSTR OnTabWndQueryItemText(
		const TAB_ITEM_INFO * pTii
		) const
	{
		HWND hWndMdiChildFrame =
			(HWND) ( pTii->LParamGet() );
		ASSERT( hWndMdiChildFrame != NULL );
		ASSERT( ::IsWindow(hWndMdiChildFrame) );
		static CString g_sLastCaptionTextBuffer;
		int nTextLen =
			::GetWindowTextLength(
				hWndMdiChildFrame
				);
		if( nTextLen <= 0 )
			return
				CExtTabMdiWnd::
					OnTabWndQueryItemText( pTii );
		int nCaptionTextLen =
			::GetWindowText(
				hWndMdiChildFrame,
				g_sLastCaptionTextBuffer.GetBuffer(
					nTextLen + 2 ),
				nTextLen + 1
				);
		g_sLastCaptionTextBuffer.ReleaseBuffer();
		if( nCaptionTextLen <= 0 )
			return
				CExtTabMdiWnd::
					OnTabWndQueryItemText( pTii );
		return ((LPCTSTR)g_sLastCaptionTextBuffer);
	}
};


Best regards, Sergiy.