MFC TABS umstellen auf windows Tabs

Nun ja, nicht gleich löschen. Wenn's dann doch nicht funktioniert, braucht man die Zeile ja wieder.
Ich meinte, wie man halt so in C++ einen Kommentar schreibt: mit "//" am Anfang der Zeile.
Für den Compiler das ist das dann so gut wie gelöscht :)
 
hi

das hat auch nicht geklappt !

hier der gesamte source von maintabctrl.cpp

Code:
/////////////////////////////////////////////////////
  
  #include "stdafx.h"
  #include "Resource.h"
  #include "MFC_MUTE_GUI.h"
  #include "MuteMainTabCtrl.h"
  #include "MuteSearchDlg.h"
  #include "MuteDownloadsDlg.h"
  #include "MuteUploadsDlg.h"
  #include "MuteConnectionsDlg.h"
  #include "MuteSharedFilesDlg.h"
  #include "MuteOptionsDlg.h"	  
  #include "MSDNIcons.h"
  
  
  #ifdef _DEBUG
  #define new DEBUG_NEW
  #undef THIS_FILE
  static char THIS_FILE[] = __FILE__;
  #endif
  
  /////////////////////////////////////////////////////////////////////////////
  // CMuteMainDlgTabCtrl
  
  //**************************************************************************************
  //  FUNCTION:	-	CMuteMainDlgTabCtrl()
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  CMuteMainDlgTabCtrl::CMuteMainDlgTabCtrl()
  {
  	unsigned int	unMaxX = 0;
  	unsigned int	unMaxY = 0;
  	unsigned int	unCnt;	
  	vector<CString>	vecStrIconFileNames;
  	LPICONRESOURCE	lpi;
  	TCHAR szDirectory[MAX_PATH] = "";
    
  	::ZeroMemory( &m_tabPages, sizeof(m_tabPages) );	
  	m_nNumberOfPages = 6;
  	
  	unCnt = 0;
  	m_tabPages[unCnt++] = new CMuteSearchDlg;
  	m_tabPages[unCnt++] = new CMuteDownloadsDlg;
  	m_tabPages[unCnt++] = new CMuteUploadsDlg;
  	m_tabPages[unCnt++] = new CMuteConnectionsDlg;
  	m_tabPages[unCnt++] = new CMuteSharedFilesDlg;
  	m_tabPages[unCnt++] = new CMuteOptionsDlg;
  
  	((CMuteSearchDlg *)m_tabPages[0] )->SetPtrToDownloadWindow( (CDialog *) m_tabPages[1] );
  	
  	
  	// version 0.0.6 -- can now use larger icons statically (as resources)
  	// just change the height and width here to match the size of the icons
  	// defaults:
  	unMaxX = 16;
  	unMaxY = 16;
  	m_unIconWidth = unMaxX;
  	m_unIconHeight = unMaxY;
  
  	::ZeroMemory( &m_IconHandles, m_nNumberOfPages * sizeof(HICON) );
  	vecStrIconFileNames.resize(m_nNumberOfPages);
  
  	::GetCurrentDirectory(sizeof(szDirectory) - 1, szDirectory);
  
  	unCnt = 0;
  	vecStrIconFileNames[unCnt] = szDirectory;
  	vecStrIconFileNames[unCnt] += "\\icons\\searchTab.ico";
 	m_IconHandles[unCnt] = (HICON)LoadImage( AfxGetInstanceHandle(), vecStrIconFileNames[unCnt], IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
  	
  	unCnt++;
  	vecStrIconFileNames[unCnt] = szDirectory;
  	vecStrIconFileNames[unCnt] += "\\icons\\downloadsTab.ico";
 	m_IconHandles[unCnt] = (HICON)LoadImage( AfxGetInstanceHandle(), vecStrIconFileNames[unCnt], IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
  	
  	unCnt++;
  	vecStrIconFileNames[unCnt] = szDirectory;
  	vecStrIconFileNames[unCnt] += "\\icons\\uploadsTab.ico";
 	m_IconHandles[unCnt] = (HICON)LoadImage( AfxGetInstanceHandle(), vecStrIconFileNames[unCnt], IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
  	
  	unCnt++;
  	vecStrIconFileNames[unCnt] = szDirectory;
  	vecStrIconFileNames[unCnt] += "\\icons\\connectionsTab.ico";
 	m_IconHandles[unCnt] = (HICON)LoadImage( AfxGetInstanceHandle(), vecStrIconFileNames[unCnt], IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
  	
  	unCnt++;
  	vecStrIconFileNames[unCnt] = szDirectory;
  	vecStrIconFileNames[unCnt] += "\\icons\\sharedfilesTab.ico";
 	m_IconHandles[unCnt] = (HICON)LoadImage( AfxGetInstanceHandle(), vecStrIconFileNames[unCnt], IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
  	
  	unCnt++;
  	vecStrIconFileNames[unCnt] = szDirectory;
  	vecStrIconFileNames[unCnt] += "\\icons\\settingsTab.ico";
 	m_IconHandles[unCnt] = (HICON)LoadImage( AfxGetInstanceHandle(), vecStrIconFileNames[unCnt], IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
  	
  	// determine the max x and y icons.. 
  	for( unCnt = 0; unCnt < (unsigned int) m_nNumberOfPages; unCnt++ )
  	{
  		lpi = NULL;
  		lpi = ReadIconFromICOFile( vecStrIconFileNames[unCnt] );
  		if( NULL != lpi )
  		{
  			if( lpi->nNumImages > 0 )
  			{
 				if( lpi->IconImages[0].Width > unMaxX )
  				{
 		 		unMaxX = lpi->IconImages[0].Width;
  				}
  
 				if( lpi->IconImages[0].Height > unMaxY )
  				{
 		 		unMaxY = lpi->IconImages[0].Height;
 		 	}	 		 		 	
  
  				// Free all the bits
 				for( UINT i=0; i< lpi->nNumImages; i++ )
  				{
 		 		if( lpi->IconImages[i].lpBits != NULL )
  					{
 		 			free( lpi->IconImages[i].lpBits );
  					}
 		 	}	 	
  			}
  			free( lpi );
  		}	
  	}
  
  	m_unIconWidth = unMaxX;
  	m_unIconHeight = unMaxY;
  
  	m_pImgLst.Create(m_unIconWidth,m_unIconHeight,ILC_COLOR32|ILC_MASK,0,10);
  	m_pImgLst.SetBkColor(CLR_NONE);
  	
  	unCnt = 0;
  	if( NULL != m_IconHandles[unCnt] )
  	{
  		m_pImgLst.Add(m_IconHandles[unCnt]);
  	}
  	else
  	{
  		m_pImgLst.Add(AfxGetApp()->LoadIcon(IDI_SEARCH_ICON));
  	}
  
  	unCnt++;
  	if( NULL != m_IconHandles[unCnt] )
  	{
  		m_pImgLst.Add(m_IconHandles[unCnt]);
  	}
  	else
  	{
  		m_pImgLst.Add(AfxGetApp()->LoadIcon(IDI_DOWNLOAD2_ICON));
  	}
  
  	unCnt++;
  	if( NULL != m_IconHandles[unCnt] )
  	{
  		m_pImgLst.Add(m_IconHandles[unCnt]);
  	}
  	else
  	{
  		m_pImgLst.Add(AfxGetApp()->LoadIcon(IDI_UPLOAD2_ICON));
  	}
  
  	unCnt++;
  	if( NULL != m_IconHandles[unCnt] )
  	{
  		m_pImgLst.Add(m_IconHandles[unCnt]);
  	}
  	else
  	{
  		m_pImgLst.Add(AfxGetApp()->LoadIcon(IDI_CONNECTIONS_ICON));
  	}
  	
  	unCnt++;
  	if( NULL != m_IconHandles[unCnt] )
  	{
  		m_pImgLst.Add(m_IconHandles[unCnt]);
  	}
  	else
  	{
  		m_pImgLst.Add(AfxGetApp()->LoadIcon(IDI_SHARED_FILES_ICON));
  	}
  
  	unCnt++;
  	if( NULL != m_IconHandles[unCnt] )
  	{
  		m_pImgLst.Add(m_IconHandles[unCnt]);
  	}
  	else
  	{
  		m_pImgLst.Add(AfxGetApp()->LoadIcon(IDI_PREFERENCES_ICON));
  	}	
  
  	m_bFirstTime = true;
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  CMuteMainDlgTabCtrl::~CMuteMainDlgTabCtrl()
  {
  	for(int nCount=0; nCount < m_nNumberOfPages; nCount++)
  	{
  		delete m_tabPages[nCount];
  	}
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	Init()
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  void CMuteMainDlgTabCtrl::Init()
  {
  	int i;
  	m_tabCurrent = 0;
  	
  	i = 0;
  	m_tabPages[i++]->Create( CMuteSearchDlg::IDD, this );
  	m_tabPages[i++]->Create( CMuteDownloadsDlg::IDD, this );
  	m_tabPages[i++]->Create( CMuteUploadsDlg::IDD, this );
  	m_tabPages[i++]->Create( CMuteConnectionsDlg::IDD, this );	
  	m_tabPages[i++]->Create( CMuteSharedFilesDlg::IDD, this );
 	m_tabPages[i++]->Create( CMuteOptionsDlg::IDD, this );		
  
  
  	for( i = 0; i < m_nNumberOfPages; i++ )
  	{
  		m_tabPages[i]->ShowWindow(SW_SHOW);
  	}
  	
  	m_tabPages[m_tabCurrent]->SetFocus();
  
  	if( m_bFirstTime )
  	{
 		SendMessage( TCM_SETITEMSIZE,0,MAKELPARAM (m_unIconWidth + 3, m_unIconHeight + 3) );
  
  	   m_bFirstTime = false;
  	}
  
  	SetRectangle();	
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	GotoPageIndex()
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		Equivalent of clicking on a tab..to show the current tabs' page
  //**************************************************************************************
  void CMuteMainDlgTabCtrl::GotoPageIndex( const unsigned int nPageIndex )
  {
  	if( (int) nPageIndex > (m_nNumberOfPages - 1) )
  	{
  		return;
  	}
  	
  	m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
  	m_tabCurrent = nPageIndex;
  	m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
  	m_tabPages[m_tabCurrent]->SetFocus();
  	SetCurSel(m_tabCurrent);
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	SetRectangle()
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  void CMuteMainDlgTabCtrl::SetRectangle()
  {
  	CRect tabRect, itemRect;
  	int nX, nY, nXc, nYc;
  
  	GetClientRect(&tabRect);
  	GetItemRect(0, &itemRect);
  
  	nX=itemRect.left;
  	nY=itemRect.bottom+1;
  	nXc=tabRect.right-itemRect.left-1;
  	nYc=tabRect.bottom-nY-3;
  
  	m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
  	
  	for(int nCount=1; nCount < m_nNumberOfPages; nCount++)
  	{
 		m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
  	}
  }
  
  BEGIN_MESSAGE_MAP(CMuteMainDlgTabCtrl, CTabCtrl)
  	//{{AFX_MSG_MAP(CMuteMainDlgTabCtrl)
  	ON_WM_LBUTTONDOWN()
  	ON_WM_CREATE()
  	ON_WM_SIZE()
  	//}}AFX_MSG_MAP
  END_MESSAGE_MAP()
  
  /////////////////////////////////////////////////////////////////////////////
  // CMuteMainDlgTabCtrl message handlers
  
  void CMuteMainDlgTabCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
  {
  	CTabCtrl::OnLButtonDown(nFlags, point);
  
  	if( m_tabCurrent != GetCurFocus() )
  	{
  		m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
  		m_tabCurrent = GetCurFocus();
  		m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
  		m_tabPages[m_tabCurrent]->SetFocus();
  	}
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	DrawItem()
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  void CMuteMainDlgTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
  {
  	CRect rect = lpDrawItemStruct->rcItem;
  	IMAGEINFO info;
  	int nTabIndex = lpDrawItemStruct->itemID;
  	if (nTabIndex < 0) return;
  	BOOL bSelected = (nTabIndex == GetCurSel());
  	
  	char label[64];
  	TC_ITEM tci;
  	tci.mask = TCIF_TEXT|TCIF_IMAGE;
  	tci.pszText = label;	 
  	tci.cchTextMax = 63;		
  	if (!GetItem(nTabIndex, &tci )) return;
  
  	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
  	if (!pDC) return;
  	int nSavedDC = pDC->SaveDC();
  
  	rect.top += ::GetSystemMetrics(SM_CYEDGE);
  	
  	if (bSelected)
  	{
  		rect.bottom -= 1;
  	}
  	else
  	{
  		rect.bottom += 2;
  	}
  
  	//pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE));
  
  
  	pDC->SetBkMode(TRANSPARENT);
  
  	// Draw image
  	CImageList* pImageList = &m_pImgLst;
  	if (pImageList && tci.iImage >= 0) 
  	{	
 		rect.left += pDC->GetTextExtent(_T(" ")).cx;	 // Margin
  
  		// Get height of image so we
  		pImageList->GetImageInfo(nTabIndex, &info);
  		CRect ImageRect(info.rcImage);
  		int nYpos = rect.top;
  
  		pImageList->Draw(pDC, nTabIndex, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
  		rect.left += ImageRect.Width();
  	}
  
  	if (bSelected) {
  		rect.top -= ::GetSystemMetrics(SM_CYEDGE);
  		pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_NOPREFIX);
  		rect.top += ::GetSystemMetrics(SM_CYEDGE);
  	} else {
  		pDC->DrawText(label, rect, DT_SINGLELINE|DT_BOTTOM|DT_CENTER|DT_NOPREFIX);
  	}
  
  	if (nSavedDC)
  		pDC->RestoreDC(nSavedDC);
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  void CMuteMainDlgTabCtrl::PreSubclassWindow()
  {
  	CTabCtrl::PreSubclassWindow();
  	ModifyStyle(0, TCS_OWNERDRAWFIXED);
  }
  
  //**************************************************************************************
  //  FUNCTION:	-	
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		
  //**************************************************************************************
  int CMuteMainDlgTabCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
  {
  	if (CTabCtrl::OnCreate(lpCreateStruct) == -1)
  		return -1;
  	ModifyStyle(0, TCS_OWNERDRAWFIXED);
  	return 0;
  }
  
  
  //*******************************************************************
  //  FUNCTION:   -	
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	
  //*******************************************************************
  void CMuteMainDlgTabCtrl::OnSize(UINT nType, int cx, int cy) 
  {
  	CTabCtrl::OnSize(nType, cx, cy);
  
  	CRect tabRect, itemRect;
  	int nTabIndex = GetCurSel();
  	int nX, nY, nXc, nYc;
  
  	GetClientRect(&tabRect);
  	GetItemRect(0, &itemRect);
  
  	nX=itemRect.left;
  	nY=itemRect.bottom+1;
  	nXc=tabRect.right-itemRect.left-1;
  	nYc=tabRect.bottom-nY-3;
  
  	for(int nCount=0; nCount < m_nNumberOfPages; nCount++)
  	{
  		if( nTabIndex == nCount )
  		{
 		 m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
  		}
  		else
  		{
 		 m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
  		}
  	}	
  	SetCurSel( nTabIndex );
  }
 
hier das maintabctrl.h

Code:
#if !defined(AFX_MYTABCTRL_H__F3E8650F_019C_479F_9E0F_60FE1181F49F__INCLUDED_)
 #define AFX_MYTABCTRL_H__F3E8650F_019C_479F_9E0F_60FE1181F49F__INCLUDED_
 
 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 // MyTabCtrl.h : header file
 //
 
 
 /////////////////////////////////////////////////////////////////////////////
 // CMuteMainDlgTabCtrl window
 
 class CMuteMainDlgTabCtrl : public CTabCtrl
 {
 // Construction
 public:
 	CMuteMainDlgTabCtrl();
 	virtual ~CMuteMainDlgTabCtrl();
 
 // Attributes
 public:
 	CDialog		*m_tabPages[6];
 	int			m_tabCurrent;
 	int			m_nNumberOfPages;
 
 private:
 	CImageList	m_pImgLst;
 	HICON		m_IconHandles[6];
 
 // Operations
 public:
 	void	Init();
 	void	SetRectangle();	
 	void	GotoPageIndex( const unsigned int nPageIndex );
 	inline unsigned int	GetIconWidth() const 
 	{
 		return m_unIconWidth;
 	}
 
 protected:
 	// Overrides
 	// ClassWizard generated virtual function overrides
 	//{{AFX_VIRTUAL(CMuteMainDlgTabCtrl)
 	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
 	virtual void PreSubclassWindow();
 	//}}AFX_VIRTUAL
 
 	bool	m_bFirstTime;
 	unsigned int m_unIconWidth;
 	unsigned int m_unIconHeight;
 
 	// Generated message map functions
 protected:
 	//{{AFX_MSG(CMuteMainDlgTabCtrl)
 	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);		
 	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	//}}AFX_MSG
 	
 
 	DECLARE_MESSAGE_MAP()
 };
 
 
 /////////////////////////////////////////////////////////////////////////////
 
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 
 #endif // !defined(AFX_MYTABCTRL_H__F3E8650F_019C_479F_9E0F_60FE1181F49F__INCLUDED_)
 
Gebracht hat das Ausommentieren wirklich nichts.

Es läuft dann wohl daraus hinaus, die DrawItem()-Funktion herauszuwerfen.

Ich sehe jetzt bloß nicht, wo die einzelnen Tabs ins TabCtrl eingefügt werden.
Gibt es in dem Projekt irgendwo ein InsertItem() im Zusammenhang mit dem TabCtrl?
Und zeige auch mal die MuteMainTabCtrl.h.
 
hier das mutemaintabctrl.h

Code:
#if !defined(AFX_MYTABCTRL_H__F3E8650F_019C_479F_9E0F_60FE1181F49F__INCLUDED_)
     #define AFX_MYTABCTRL_H__F3E8650F_019C_479F_9E0F_60FE1181F49F__INCLUDED_
     
     #if _MSC_VER > 1000
     #pragma once
     #endif // _MSC_VER > 1000
     // MyTabCtrl.h : header file
     //
     
     
     /////////////////////////////////////////////////////////////////////////////
     // CMuteMainDlgTabCtrl window
     
     class CMuteMainDlgTabCtrl : public CTabCtrl
     {
     // Construction
     public:
     	CMuteMainDlgTabCtrl();
     	virtual ~CMuteMainDlgTabCtrl();
     
     // Attributes
     public:
     	CDialog		*m_tabPages[6];
     	int			m_tabCurrent;
     	int			m_nNumberOfPages;
     
     private:
     	CImageList	m_pImgLst;
     	HICON		m_IconHandles[6];
     
     // Operations
     public:
     	void	Init();
     	void	SetRectangle();	
     	void	GotoPageIndex( const unsigned int nPageIndex );
     	inline unsigned int	GetIconWidth() const 
     	{
     		return m_unIconWidth;
     	}
     
     protected:
     	// Overrides
     	// ClassWizard generated virtual function overrides
     	//{{AFX_VIRTUAL(CMuteMainDlgTabCtrl)
     	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
     	virtual void PreSubclassWindow();
     	//}}AFX_VIRTUAL
     
     	bool	m_bFirstTime;
     	unsigned int m_unIconWidth;
     	unsigned int m_unIconHeight;
     
     	// Generated message map functions
     protected:
     	//{{AFX_MSG(CMuteMainDlgTabCtrl)
  	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);		
     	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
     	afx_msg void OnSize(UINT nType, int cx, int cy);
     	//}}AFX_MSG
     	
     
     	DECLARE_MESSAGE_MAP()
     };
     
     
     /////////////////////////////////////////////////////////////////////////////
     
     //{{AFX_INSERT_LOCATION}}
     // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
     
     #endif // !defined(AFX_MYTABCTRL_H__F3E8650F_019C_479F_9E0F_60FE1181F49F__INCLUDED_)

und MFC_MUTE_GUIDlg.cpp:

Code:
// MUTEMFC2Dlg.cpp : implementation file
  //
  // 02-17-2005 JROC - Changed tray icon tooltip from "MFC_MUTE_0.3" to "MFC MUTE"
  #include "stdafx.h"
  #include "MFC_MUTE_GUI.h"
  #include "MFC_MUTE_GUIDlg.h"
  #include "MuteDownloadsDlg.h"
  #include <LIMITS.H > // JROC BUG FIX FOR MICRO$OFT DEBUG HEAP ALLOC CRT BUG
  #include "minorGems/util/SettingsManager.h" 
  #include "StrParse.h"
  #include "ColorNames.h"
  
  #ifdef _DEBUG
  #define new DEBUG_NEW
  #undef THIS_FILE
  static char THIS_FILE[] = __FILE__;
  #endif
  
  
  
  #define MUTE_TASK_TRAY_CB_ID			(WM_APP+1)
  #define MUTE_TASK_TRAY_RESTORE_CMD_ID	(WM_USER+100) // ARBITRARY
 #define MUTE_TASK_TRAY_QUIT_CMD_ID		(MUTE_TASK_TRAY_RESTORE_CMD_ID + 1) // ARBITRARY
  
  
  AFX_STATIC const UINT _unTaskbarRestartMSGID = ::RegisterWindowMessage(TEXT("TaskbarCreated"));
  BOOL (WINAPI *_TransparentBlt)(HDC, int, int, int, int, HDC, int, int, int, int, UINT)= NULL;
  
  /////////////////////////////////////////////////////////////////////////////
  // CMUTEMFC2Dlg dialog
  
  CMUTEMFC2Dlg::CMUTEMFC2Dlg(CWnd* pParent /*=NULL*/)
  	: CMUTEMFC2DialogBase(CMUTEMFC2Dlg::IDD, pParent)
  {
  	//{{AFX_DATA_INIT(CMUTEMFC2Dlg)
  		// NOTE: the ClassWizard will add member initialization here
  	//}}AFX_DATA_INIT
  	m_hIcon = AfxGetApp()->LoadIcon(IDI_MUTE_ICON);
  	
  	m_bQuitingAppDialogIsShowing	= false;
 	m_bdoubleclicked				= false;
 	m_bIsTrayIconActive				= false;
  	m_ulLastNumOfConnections		= 0;
 	m_timeStart	 		 	= time(NULL);
  }
  
  void CMUTEMFC2Dlg::DoDataExchange(CDataExchange* pDX)
  {
  	CMUTEMFC2DialogBase::DoDataExchange(pDX);
  	//{{AFX_DATA_MAP(CMUTEMFC2Dlg)
  		// NOTE: the ClassWizard will add DDX and DDV calls here
  	DDX_Control( pDX, IDC_MUTE_MAIN_TAB, m_oTabCtrl );
  	DDX_Control( pDX, IDC_CONNECTION_STATUS_LABEL, m_oConnectionStatusLabel );
  	//}}AFX_DATA_MAP
  }
  
  BEGIN_MESSAGE_MAP(CMUTEMFC2Dlg, CMUTEMFC2DialogBase)
  	//{{AFX_MSG_MAP(CMUTEMFC2Dlg)
  	ON_COMMAND( MUTE_TASK_TRAY_RESTORE_CMD_ID, TrayRestore )
  	ON_COMMAND( MUTE_TASK_TRAY_QUIT_CMD_ID, TrayQuit )
  	ON_WM_SYSCOMMAND()
  	ON_REGISTERED_MESSAGE( _unTaskbarRestartMSGID, AddTrayIcon )
  	ON_MESSAGE( MUTE_TASK_TRAY_CB_ID, OnTrayMessage )
  	ON_MESSAGE( MUTE_MAIN_GUI_UPDATE_CONNECTION_STAT_MSG, UpdateConnectionStatus )
  	ON_WM_PAINT()
  	ON_WM_QUERYDRAGICON()
  	ON_WM_SIZE()
  	ON_WM_CLOSE()	
  	ON_WM_QUERYENDSESSION()
  	ON_WM_TIMER()
  	ON_WM_SHOWWINDOW()
  	ON_WM_WINDOWPOSCHANGING()
  	//}}AFX_MSG_MAP
  END_MESSAGE_MAP()
  
  /////////////////////////////////////////////////////////////////////////////
  // CMUTEMFC2Dlg message handlers
  
  BOOL CMUTEMFC2Dlg::OnInitDialog()
  {
  	CString	strTemp;
  	int		nTabIndex;
  	CSize	dlgSize;
  	CRect	rc;
  
  	CMUTEMFC2DialogBase::OnInitDialog();		
  	
  	// so we can Shrink the window even more
  	// Tony motivated me to do this... 
  	GetWindowRect( &rc );
  	dlgSize.cx = (long)(0.60 * rc.Width());
  	dlgSize.cy = (long)(0.60 * rc.Height());
  	SetMinTrackSize( dlgSize ); //
  
 	SetIcon(m_hIcon, TRUE);			// Set big icon
  	SetIcon(m_hIcon, FALSE);		// Set small icon
  	
  	AddAnchor( m_oTabCtrl, TOP_LEFT, BOTTOM_RIGHT );
  	AddAnchor( m_oConnectionStatusLabel, BOTTOM_LEFT, BOTTOM_RIGHT );
  
  	m_oConnectionStatusLabel.SetFontBold(TRUE);
  	m_oConnectionStatusLabel.SetTextColor(colWhite);
  	m_oConnectionStatusLabel.SetBkColor(colRed);
  	m_TrayIconMenu.CreatePopupMenu();
  	m_TrayIconMenu.AddMenuTitle("MUTE TRAY CONTROL", true);
  
  	// 01-22-2005 -- just put a loop in instead of individual calls to
  	// InsertItem
  	for( nTabIndex = 0; nTabIndex < m_oTabCtrl.m_nNumberOfPages; nTabIndex++ )
  	{
  		m_oTabCtrl.InsertItem(nTabIndex,strTemp, nTabIndex);
  	}
  
  	m_oTabCtrl.Init();
  	m_oTabCtrl.SetFocus();
  	m_oTabCtrl.GotoPageIndex(3);
  
  	SetTimer( 666, 30000, NULL ); // JROC BUG FIX FOR MICRO$OFT DEBUG HEAP ALLOC CRT BUG
  	SetTimer( 667, 1000, NULL );
  	LoadWindowPlacement();
  	SetStrings();
  
  	GetWindowText( m_strBaseWindowText );
  	return FALSE;  // return TRUE  unless you set the focus to a control
  }
  
  
  //*******************************************************************
  //  FUNCTION:   -	OnSysCommand
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	
  //*******************************************************************
  void CMUTEMFC2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
  {
  	if ((nID & 0xFFF0) == SC_MINIMIZETRAY)
  	{
  		AddTrayIcon(0,0);
  		ShowWindow(SW_HIDE);		
  	}		
  	else
  	{		
  		CMUTEMFC2DialogBase::OnSysCommand(nID, lParam);
  	}
  }
  
  //*******************************************************************
  //  FUNCTION:   -	OnPaint()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	
  //*******************************************************************
  void CMUTEMFC2Dlg::OnPaint() 
  {
  	if (IsIconic())
  	{
  		CPaintDC dc(this); // device context for painting
  
  		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  
  		// Center icon in client rectangle
  		int cxIcon = GetSystemMetrics(SM_CXICON);
  		int cyIcon = GetSystemMetrics(SM_CYICON);
  		CRect rect;
  		GetClientRect(&rect);
  		int x = (rect.Width() - cxIcon + 1) / 2;
  		int y = (rect.Height() - cyIcon + 1) / 2;
  
  		// Draw the icon
  		dc.DrawIcon(x, y, m_hIcon);
  	}
  	else
  	{
  		CMUTEMFC2DialogBase::OnPaint();
  	}
  }
  
  HCURSOR CMUTEMFC2Dlg::OnQueryDragIcon()
  {
  	return (HCURSOR) m_hIcon;
  }
  
  void CMUTEMFC2Dlg::OnSize(UINT nType, int cx, int cy) 
  {
  	CMUTEMFC2DialogBase::OnSize(nType, cx, cy);	
  }
  
  //*******************************************************************
  //  FUNCTION:   -	PreTranslateMessage()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	
  //*******************************************************************
  BOOL CMUTEMFC2Dlg::PreTranslateMessage(MSG* pMsg) 
  {
  	if ( pMsg->message == WM_KEYDOWN )
  	{
  		if ( (pMsg->wParam == VK_ESCAPE) || (pMsg->wParam == VK_RETURN) )
  		{
  			// Don't close the window if the user hits the ESC key.
  			return FALSE;
  		}
  	}	
  	return CMUTEMFC2DialogBase::PreTranslateMessage(pMsg);
  }
  
  
  //*******************************************************************
  //  FUNCTION:   -	OnClose()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	
  //*******************************************************************
  void CMUTEMFC2Dlg::OnClose() 
  {
  	SaveWindowPlacement();
  	if( ! ((CMuteDownloadsDlg *) m_oTabCtrl.m_tabPages[1])->areDownloadsActive() )
  	{
  		CleanupAndExit();
  	}
  	else
  	{	
  		CString	strCaption, strText;
  
  		int nMBReturnVal;
 		m_bQuitingAppDialogIsShowing = true; // prevents the task tray from popping up while displaying this message box
  		
 		strCaption = m_ExtStr.LoadString( IDS_MUTE_CLOSE_MSG_CAPTION_ENG + g_unStringLanguageIdOffset );
 		strText = m_ExtStr.LoadString( IDS_MUTE_CLOSE_MSG_TEXT_ENG + g_unStringLanguageIdOffset );
  		
  		nMBReturnVal = MessageBox( strText, strCaption, MB_ICONQUESTION | MB_YESNO);
  
  		if( IDYES == nMBReturnVal )
  		{
  			CleanupAndExit();
  		}
  
  		m_bQuitingAppDialogIsShowing = false;
  	}
  }
  
  
  //*******************************************************************
  //  FUNCTION:   -	OnQueryEndSession()	
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	Called by frame work when a user is logging off or shutting down.
  //*******************************************************************
  BOOL CMUTEMFC2Dlg::OnQueryEndSession()
  {
  	CleanupAndExit();
  	return TRUE;
  }
  
  
  //**************************************************************************************
  //  FUNCTION:	-	CleanupAndExit()
  //  RETURNS:	-	
  //  PARAMETERS:	-	
  //  COMMENTS:		Clears up any remnants of Tray Icons... 
  //**************************************************************************************
  void CMUTEMFC2Dlg::CleanupAndExit()
  {	
  	CWaitCursor			wait;
  	CMuteDownloadsDlg	*pDlg;
  		
  	for( int i = 0; i < m_oTabCtrl.m_nNumberOfPages; i++ )
  	{
  		pDlg = (CMuteDownloadsDlg *)m_oTabCtrl.m_tabPages[i];
 		pDlg->SendMessage( WM_CLOSE, 0, 0);		
  	}
  
  	RemoveTrayIcon();
  	
  	m_TrayIconMenu.DestroyMenu();
  
  	KillTimer(666);	
  	AfxGetApp()->DoWaitCursor(1);
  	Sleep(2000);
  	EndDialog(IDCANCEL);
  }
  
  //**************************************************************************************
  //  FUNCTION:   -	OnTrayMessage()
  //  RETURNS:	-	
  //  PARAMETERS: -	WPARAM wparam, LPARAM lparam  -- see the Mouse messages in windows help
  //  COMMENTS:   -	This function is a call back that is called when the user uses the mouse
 //					on the tray icon.
  //**************************************************************************************
  LONG CMUTEMFC2Dlg::OnTrayMessage( WPARAM wparam, LPARAM lparam )
  {   
  	if( m_bQuitingAppDialogIsShowing )
  	{
  		// get out now, because we are showing the quit dialog!
  		return -1;
  	}
  	// The tray icon sent us a message.  Let's see what it is
  	switch ( lparam )
  	{
  		case WM_LBUTTONDBLCLK:
  			m_bdoubleclicked = true;
  			break;		
  		case WM_CONTEXTMENU:
  		case WM_RBUTTONDOWN:
  			{
 				// The user clicked the right mouse button.
 				CMenu	oMenu;
  				CPoint oPoint;
  				 
 		 	// Figure out where the mouse is so we			 
 				// can display the menu near it.
  				GetCursorPos( &oPoint );
  				SetForegroundWindow();
 		 		 		 		
 		 	m_TrayIconMenu.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, oPoint.x, oPoint.y, this);
  			}
  			break;
  		case WM_LBUTTONUP:
  		if(m_bdoubleclicked)
  		{
 			PostMessage( WM_COMMAND, MUTE_TASK_TRAY_RESTORE_CMD_ID, 0);
  			m_bdoubleclicked = false;
  		}
  		break;
  		default:
  			break;
  	}
  
  	return 0;
  }
  
  
  //**************************************************************************************
  //  FUNCTION:   -	AddTrayIcon()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:   -	This function adds the icon to the task tray.
  //**************************************************************************************
  LRESULT CMUTEMFC2Dlg::AddTrayIcon(WPARAM, LPARAM lParam)
  {
  	// We don't use ShowIcon here because 
  	// ShowIcon relies on the tray icon already
  	// having been created. This creates the icon 
  	// in the tray.
  	NOTIFYICONDATA strNIData;
  
  	strNIData.cbSize = sizeof( NOTIFYICONDATA );
  	strNIData.hWnd   = GetSafeHwnd();
  	strNIData.uID	= MUTE_TASK_TRAY_CB_ID;
  	strNIData.uCallbackMessage = MUTE_TASK_TRAY_CB_ID;
  	_tcscpy( strNIData.szTip, "MFC MUTE" );
  	strNIData.hIcon = m_hIcon;//::LoadIcon( AfxGetResourceHandle(), MAKEINTRESOURCE( IDR_MAINFRAME ) );
  	strNIData.uFlags = NIF_MESSAGE | NIF_TIP | NIF_ICON;
  	Shell_NotifyIcon(NIM_ADD, &strNIData);
  #if _WIN32_IE >= 0x0500
  	// If this isn't compiled under the correct version
  	// of the SDK and IE, this code will not compile.
  	strNIData.uVersion = 0;
  	Shell_NotifyIcon(NIM_SETVERSION, &strNIData);
  #endif // _WIN32_IE >= 0x0500	
  
  	m_bIsTrayIconActive = true;
  	return (LRESULT) TRUE;
  }
  
  //**************************************************************************************
  //  FUNCTION:   -	RemoveTrayIcon()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:   -	This function removes the icon from the tray
  //**************************************************************************************
  void CMUTEMFC2Dlg::RemoveTrayIcon()
  {
  	NOTIFYICONDATA	strNIData;   
  	/* kill Tray Icon */
  	strNIData.cbSize = sizeof( NOTIFYICONDATA );
  	strNIData.hWnd   = GetSafeHwnd();
  	strNIData.uID	= MUTE_TASK_TRAY_CB_ID;
  	strNIData.uCallbackMessage = MUTE_TASK_TRAY_CB_ID;
  	Shell_NotifyIcon( NIM_DELETE, &strNIData ); 
  	m_bIsTrayIconActive = false;
  }
  
  //*******************************************************************
  //  FUNCTION:   -	TrayRestore()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	When user chooses to restore from tray icon.
  //*******************************************************************
  void CMUTEMFC2Dlg::TrayRestore()
  {
  	RemoveTrayIcon();
  	ShowWindow(SW_SHOW);
  	SetForegroundWindow();
  }
  
  //*******************************************************************
  //  FUNCTION:   -	TrayQuit()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	When user chooses to quit from tray icon.
  //*******************************************************************
  void CMUTEMFC2Dlg::TrayQuit()
  {
  	OnClose();
  }
  
  
  //*******************************************************************
  //  FUNCTION:   -	SetStrings()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	Get current language and set appropriate strings 
  //*******************************************************************
  void CMUTEMFC2Dlg::SetStrings()
  {
  
  	CString			strTemp;
 	CString			strTemp2;	
 	int				nTabIndex;
  	TC_ITEM			ti;
  	unsigned int	i;
  
  	ti.mask = TCIF_TEXT;
  	
  	strTemp2.Empty();
  	for(i = 0; i < m_oTabCtrl.GetIconWidth()/4; i++ )
  	{
  		strTemp2 += " ";
  	}
  
  	// search tab 
  	nTabIndex = 0;
 	strTemp = m_ExtStr.LoadString(IDS_TAB_TITLE_SEARCH_TEXT_ENG + g_unStringLanguageIdOffset );	
  	strTemp.Insert(0,strTemp2);
  	strTemp+=strTemp2;	
  	ti.pszText = strTemp.GetBuffer(MAX_PATH);
  	m_oTabCtrl.SetItem(nTabIndex,&ti);
  	strTemp.ReleaseBuffer();
  	nTabIndex++;
  
  	// downloads tab
  	strTemp = m_ExtStr.LoadString( IDS_TAB_TITLE_DLOAD_TEXT_ENG + g_unStringLanguageIdOffset );
  	strTemp.Insert(0,strTemp2);
  	strTemp+=strTemp2;	
  	ti.pszText =strTemp.GetBuffer(MAX_PATH);
  	m_oTabCtrl.SetItem(nTabIndex,&ti);
  	strTemp.ReleaseBuffer();
  	nTabIndex++;
  
  	// uploads tab
  	strTemp = m_ExtStr.LoadString( IDS_TAB_TITLE_ULOAD_TEXT_ENG + g_unStringLanguageIdOffset );
  	strTemp.Insert(0,strTemp2);
  	strTemp+=strTemp2;	
  	ti.pszText =strTemp.GetBuffer(MAX_PATH);
  	m_oTabCtrl.SetItem(nTabIndex,&ti);
  	strTemp.ReleaseBuffer();
  	nTabIndex++;
  
  	// connections tab
  	strTemp = m_ExtStr.LoadString( IDS_TAB_TITLE_CONNECTIONS_TEXT_ENG + g_unStringLanguageIdOffset );
  	strTemp.Insert(0,strTemp2);
  	strTemp+=strTemp2;	
  	ti.pszText = strTemp.GetBuffer(MAX_PATH);
  	m_oTabCtrl.SetItem(nTabIndex,&ti);
  	strTemp.ReleaseBuffer();
  	nTabIndex++;
  
  	// shared files tab	";
  	// connections tab
  	strTemp = m_ExtStr.LoadString( IDS_TAB_TITLE_SHAREDFILES_TEXT_ENG + g_unStringLanguageIdOffset );
  	strTemp.Insert(0,strTemp2);
  	strTemp+=strTemp2;	
  	ti.pszText = strTemp.GetBuffer(MAX_PATH);
  	m_oTabCtrl.SetItem(nTabIndex,&ti);
  	strTemp.ReleaseBuffer();
  	nTabIndex++;
  	
  	// settings tab
  	strTemp = m_ExtStr.LoadString( IDS_TAB_TITLE_SETTINGS_TEXT_ENG + g_unStringLanguageIdOffset );
  	strTemp.Insert(0,strTemp2);
  	strTemp+=strTemp2;	
  	ti.pszText =strTemp.GetBuffer(MAX_PATH);
  	m_oTabCtrl.SetItem(nTabIndex,&ti);
  	strTemp.ReleaseBuffer();
  	nTabIndex++;	
  	
  
  	// MENU
  	m_TrayIconMenu.DeleteMenu(MUTE_TASK_TRAY_RESTORE_CMD_ID,MF_BYCOMMAND);
  	strTemp = m_ExtStr.LoadString( IDS_TASK_TRAY_MENU_RESTORE_ENG + g_unStringLanguageIdOffset );
      m_TrayIconMenu.AppendMenu(MF_STRING,MUTE_TASK_TRAY_RESTORE_CMD_ID, strTemp, MAKEINTRESOURCE(IDI_RESTORE_WINDOW_ICON) );
  
  	m_TrayIconMenu.DeleteMenu(MUTE_TASK_TRAY_QUIT_CMD_ID,MF_BYCOMMAND);
  	strTemp = m_ExtStr.LoadString( IDS_TASK_TRAY_MENU_QUIT_ENG + g_unStringLanguageIdOffset );
      m_TrayIconMenu.AppendMenu(MF_STRING,MUTE_TASK_TRAY_QUIT_CMD_ID, strTemp, MAKEINTRESOURCE(IDI_EXIT_MUTE_ICON) );
  
  	strTemp.Format( "%d ", m_ulLastNumOfConnections );
 	strTemp += m_ExtStr.LoadString( IDS_TAB_TITLE_CONNECTIONS_TEXT_ENG + g_unStringLanguageIdOffset );		
  	m_oConnectionStatusLabel.SetText( strTemp );
  	
  	Invalidate();
  }
  
  void CMUTEMFC2Dlg::OnShowWindow(BOOL bShow, UINT nStatus) 
  {
  	CMUTEMFC2DialogBase::OnShowWindow(bShow, nStatus);		
  	SetStrings();
  }	
  
  void CMUTEMFC2Dlg::OnTimer(UINT nIDEvent) 
  {
  	switch( nIDEvent )
  	{
  
  	case 666:
  #ifdef _DEBUG
  		// reference 
 		// http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_21088390.html
  		// JROC BUG FIX FOR MICRO$OFT DEBUG HEAP ALLOC CRT BUG
  		long lRequest;
  		long NewCrtBreakAlloc;
  		void *my_pointer;
  
  		my_pointer = malloc(10);
  		_CrtIsMemoryBlock(my_pointer, 10, &lRequest, NULL, NULL);
  		free(my_pointer);
  		
  		if (lRequest > -1)
  		  NewCrtBreakAlloc = LONG_MIN / 2;
  		else
  		  NewCrtBreakAlloc = LONG_MAX / 2;
  		
  		_CrtSetBreakAlloc(NewCrtBreakAlloc);	   
  #endif
  		break;
  	case 667:
  		// update caption with run time
  		CString str;
  		time_t currTime = time(NULL);
  		CTimeSpan ts( currTime - m_timeStart );
  		str = m_strBaseWindowText;
  		str += ts.Format( " %D:%H:%M:%S" );
  		SetWindowText( str );
  		break;
  	}
  
  	CMUTEMFC2DialogBase::OnTimer(nIDEvent);
  }
  
  //*******************************************************************
  //  FUNCTION:   -	SaveWindowPlacement
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	Saves window placement info, so we can bring app
 //		 		up in the exact place it was when closed.
  //*******************************************************************
  void CMUTEMFC2Dlg::SaveWindowPlacement()
  {	
  	char			value[ 100 ];
 	int				show;
  	int				x;
  	int				y;
 	int				right;
 	int				bottom;
  	WINDOWPLACEMENT info;
  	
  	info.length = sizeof(WINDOWPLACEMENT);
  	if ( FALSE != GetWindowPlacement( &info ) )
  	{
  		if( m_bIsTrayIconActive )
  		{			
  			show = SW_HIDE;
  		}
  		else
  		{
  			show = info.showCmd;	
  		}
  
  		x		= info.rcNormalPosition.left;
  		y		= info.rcNormalPosition.top;
  		right	= info.rcNormalPosition.right;
  		bottom	= info.rcNormalPosition.bottom;
  		sprintf( value, "%d,%d,%d,%d,%d", show, x, y, right, bottom );
  		SettingsManager::setSetting( "mfcWindowPlacement", value );
  	}
  }
  
  //*******************************************************************
  //  FUNCTION:   -	LoadWindowPlacement
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:	-	Loads window placement info so app pops up in same
 //					place as it was closed.
  //*******************************************************************
  void CMUTEMFC2Dlg::LoadWindowPlacement()
  {
  	WINDOWPLACEMENT info;
  	char *mfcWindowPlacement = SettingsManager::getStringSetting( "mfcWindowPlacement" );
  
  	info.length = sizeof(WINDOWPLACEMENT);
  	if( NULL != mfcWindowPlacement )
  	{
  		CStringParser parser( mfcWindowPlacement, ',' );
  		if( 5 == parser.nGetNumFields() )
  		{
 		 GetWindowPlacement( &info );		 
 			info.showCmd = atoi( parser.m_strOutput[0].c_str() ); 		
 			info.rcNormalPosition.left = atoi(parser.m_strOutput[1].c_str() );
 			info.rcNormalPosition.top = atoi(parser.m_strOutput[2].c_str() );
 			info.rcNormalPosition.right = atoi(parser.m_strOutput[3].c_str() );
 			info.rcNormalPosition.bottom = atoi(parser.m_strOutput[4].c_str() );
  			SetWindowPlacement( &info );
  			if( SW_HIDE == info.showCmd )
  			{
 		 	AddTrayIcon(0,0); 			
  			}
  		}
  
  		delete [] mfcWindowPlacement;
  	}
  }
  
  //**************************************************************************************
  //  FUNCTION:   -	OnWindowPosChanging()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:   -	Allows the program to start with a hidden dialog without a taskbar icon.
  //**************************************************************************************
  void CMUTEMFC2Dlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) 
  {
  	if( m_bIsTrayIconActive )
  	{
  		// Make the window hidden without the need of a timer.
  		lpwndpos->flags &= ~SWP_SHOWWINDOW;
  	}
  
  	CDialog::OnWindowPosChanging( lpwndpos );
  }
  
  //**************************************************************************************
  //  FUNCTION:   -	UpdateConnectionStatus()
  //  RETURNS:	-	
  //  PARAMETERS: -	
  //  COMMENTS:   -	Draws the right stuff on the status bar for connections..
  //**************************************************************************************
  LRESULT CMUTEMFC2Dlg::UpdateConnectionStatus(WPARAM, LPARAM lParam)
  {
 	CString str;	 		 	
  	m_ulLastNumOfConnections = (unsigned long) lParam;
  
  	str.Format( "%d ", m_ulLastNumOfConnections );
 	str += m_ExtStr.LoadString( IDS_TAB_TITLE_CONNECTIONS_TEXT_ENG + g_unStringLanguageIdOffset );		
  	m_oConnectionStatusLabel.SetText( str );
  	
  	if( 0 == m_ulLastNumOfConnections )
  	{	
  		m_oConnectionStatusLabel.SetBkColor( colRed );
  	}
  	else
  	{				
  		m_oConnectionStatusLabel.SetBkColor( colGreen );
  	}
  	m_oConnectionStatusLabel.Invalidate();
  	return (LRESULT) TRUE;
  }

da sind auch dinge mit tabcontrol drin!

hier MFC_MUTE_GUIdlg.h:
Code:
// MUTEMFC2Dlg.h : header file
 //
 
 #if !defined(AFX_MUTEMFC2DLG_H__37736F54_1FD7_498D_BFA6_1B322527C2F6__INCLUDED_)
 #define AFX_MUTEMFC2DLG_H__37736F54_1FD7_498D_BFA6_1B322527C2F6__INCLUDED_
 
 #include "MuteMainTabCtrl.h"
 #include "TitleMenu.h"
 #include "ResizableLib\ResizableDialog.h"
 #include "DialogMinTrayBtn.h"
 #include "Label.h"
 #include "ExternString.h"
 
 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000
 
 #define MUTE_MAIN_GUI_UPDATE_CONNECTION_STAT_MSG	(WM_USER+2000)
 
 /////////////////////////////////////////////////////////////////////////////
 // CMUTEMFC2Dlg dialog
 
 class CMUTEMFC2Dlg : public CDialogMinTrayBtn<CResizableDialog>
 {
 // Construction
 protected:
 	typedef CDialogMinTrayBtn<CResizableDialog> CMUTEMFC2DialogBase;
 
 public:
 	void SetStrings();
 	CMUTEMFC2Dlg(CWnd* pParent = NULL);	// standard constructor
 
 // Dialog Data
 	//{{AFX_DATA(CMUTEMFC2Dlg)
 	enum { IDD = IDD_MUTEMFC2_DIALOG };
 		// NOTE: the ClassWizard will add data members here
 	CMuteMainDlgTabCtrl		m_oTabCtrl;
 	CLabel	    		    m_oConnectionStatusLabel;
 	//}}AFX_DATA
 
 	// ClassWizard generated virtual function overrides
 	//{{AFX_VIRTUAL(CMUTEMFC2Dlg)
 	public:
 	virtual BOOL PreTranslateMessage(MSG* pMsg);
 	protected:
 	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
 	//}}AFX_VIRTUAL
 
 // Implementation
 protected:
 	HICON m_hIcon;
 	CExternStr m_ExtStr;
 	// Generated message map functions
 
 	void RemoveTrayIcon();
 	void CleanupAndExit();
 	void SaveWindowPlacement();
 	void LoadWindowPlacement();
 
 	//{{AFX_MSG(CMUTEMFC2Dlg)
 	afx_msg void TrayRestore();	
 	afx_msg void TrayQuit();
 	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);	
 	afx_msg LRESULT AddTrayIcon(WPARAM, LPARAM lParam);
 	afx_msg LRESULT UpdateConnectionStatus(WPARAM, LPARAM lParam);
 	afx_msg LONG OnTrayMessage( WPARAM wparam, LPARAM lparam );
 	virtual BOOL OnInitDialog();
 	afx_msg void OnPaint();
 	afx_msg HCURSOR OnQueryDragIcon();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg void OnClose();
 	afx_msg BOOL OnQueryEndSession();
 	afx_msg void OnTimer(UINT nIDEvent);
 	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
 	afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 
 private:	
 	bool				m_bIsTrayIconActive;
 	bool				m_bdoubleclicked;
 	bool				m_bQuitingAppDialogIsShowing;
 	CTitleMenu			m_TrayIconMenu;
 	unsigned long		m_ulLastNumOfConnections;
 	time_t				m_timeStart;
 	CString				m_strBaseWindowText;
 };
 
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 
 #endif // !defined(AFX_MUTEMFC2DLG_H__37736F54_1FD7_498D_BFA6_1B322527C2F6__INCLUDED_)
 
Zuletzt bearbeitet:
Suche mal in der Klasse "CMuteMainDlgTabCtrl" diese Zeile (kommt zweimal vor)
Code:
ModifyStyle(0, TCS_OWNERDRAWFIXED);
und kommentiere sie aus. Damit wird DrawItem() nicht mehr verwendet und Windows zeichnet die Tabs, die dann hoffentlich brauchbar aussehen :)
 

Neue Beiträge

Zurück