int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine, int nCmdShow)
{
	ASSERT(hPrevInstance == NULL);

	int nReturnCode = -1;
	__try
	{
	CWinThread* pThread = AfxGetThread();
	CWinApp* pApp = AfxGetApp();

	// AFX internal initialization
	if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
		goto InitFailure;

	// App global initializations (rare)
	if (pApp != NULL && !pApp->InitApplication())
		goto InitFailure;

	// Perform specific initializations
	if (!pThread->InitInstance())
	{
		if (pThread->m_pMainWnd != NULL)
		{
			TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n");
			pThread->m_pMainWnd->DestroyWindow();
		}
		nReturnCode = pThread->ExitInstance();
		goto InitFailure;
	}
	nReturnCode = pThread->Run();

InitFailure:
#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}
	AfxLockTempMaps();
	AfxUnlockTempMaps(-1);
#else
	;
#endif
	}
	__except(RecordExceptionInfo(GetExceptionInformation()))
	{
	}

	// must call AfxWinTerm after handling exception or we'll crash
	// again trying to destroy the tooltip window

	AfxWinTerm();

	return nReturnCode;
}
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine, int nCmdShow)
{
	ASSERT(hPrevInstance == NULL);

	int nReturnCode = -1;
	CWinThread* pThread = AfxGetThread();
	CWinApp* pApp = AfxGetApp();

	// AFX internal initialization
	bool InitSuccess = AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
    // App global initializations (rare)
	if (pApp != NULL)
      InitSuccess = InitSuccess && pApp->InitApplication();

	// Perform specific initializations
	InitSuccess = InitSuccess && pThread->InitInstance();

    // Run the BCI2000 core module.
    if( InitSuccess )
    {
      CoreModuleMFC coreModule;
      nReturnCode = ( coreModule.Run( __argc, __argv ) ? 0 : -1 );
    }
    else
    {
		if (pThread->m_pMainWnd != NULL)
		{
			TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
			pThread->m_pMainWnd->DestroyWindow();
		}
	}
    pThread->ExitInstance();

#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE1("Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}
	AfxLockTempMaps();
	AfxUnlockTempMaps(-1);
#endif

	AfxWinTerm();
	return nReturnCode;
}
/*
================
CSyntaxRichEditCtrl::OnToolTipNotify
================
*/
BOOL CSyntaxRichEditCtrl::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

	*pResult = 0;

	idStr name;

	if ( GetNameForMousePosition( name ) ) {
		CString toolTip;

		if ( GetToolTip == NULL || !GetToolTip( name, toolTip ) ) {

			int keyWordIndex = FindKeyWord( name, name.Length() );

			if ( keyWordIndex != -1 && keyWords[keyWordIndex].description[0] != '\0' ) {
				toolTip = keyWords[keyWordIndex].description;
			} else {
				toolTip = name.c_str();
			}
		}

		AFX_MODULE_THREAD_STATE *state = AfxGetModuleThreadState();

		// set max tool tip width to enable multi-line tool tips using "\r\n" for line breaks
		state->m_pToolTip->SetMaxTipWidth( 500 );

		// set the number of milliseconds after which the tool tip automatically disappears
		state->m_pToolTip->SetDelayTime( TTDT_AUTOPOP, 5000 + toolTip.GetLength() * 50 );

#ifndef _UNICODE
		if( pNMHDR->code == TTN_NEEDTEXTA ) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			lstrcpyn( m_pchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTW->lpszText = (WCHAR*)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			_mbstowcsz( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTW->lpszText = (WCHAR*)m_pwchTip;
		}
#else
		if( pNMHDR->code == TTN_NEEDTEXTA ) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			_wcstombsz( m_pchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTA->lpszText = (LPTSTR)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			lstrcpyn( m_pwchTip, toolTip, toolTip.GetLength() + 1 );
			pTTTA->lpszText = (LPTSTR) m_pwchTip;
		}
#endif

		return TRUE;
	}
	return FALSE;
}
DWORD WINAPI _WinThreadProc( LPVOID lpParameter )
/***********************************************/
{
    CWinThread *pThread = (CWinThread *)lpParameter;
    ASSERT( pThread != NULL );
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    ASSERT( pState->m_pCurrentWinThread == NULL );
    pState->m_pCurrentWinThread = pThread;
    AfxInitThread();
    int nExitCode;
    if( pThread->m_pfnThreadProc != NULL ) {
        nExitCode = pThread->m_pfnThreadProc( pThread->m_pThreadParams );
    } else {
        if( pThread->InitInstance() ) {
            nExitCode = pThread->Run();
        } else {
            nExitCode = -1;
        }
    }
    if( pThread->m_bAutoDelete ) {
        delete pThread;
    }
    AfxTermThread( NULL );
    return( nExitCode );
}
Exemple #5
0
BOOL CControlBar::PreTranslateMessage( MSG *pMsg )
/************************************************/
{
    if( CWnd::PreTranslateMessage( pMsg ) ) {
        return( TRUE );
    }

    if( m_dwStyle & CBRS_FLYBY ) {
        if( (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) ) {
            CPoint point( ::GetMessagePos() );
            ScreenToClient( &point );

            AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
            ASSERT( pState != NULL );
            
            INT_PTR nID = OnToolHitTest( point, NULL );
            if( pState->m_nLastStatus != nID || pState->m_pLastStatus != this ) {
                CWnd    *pOwner = GetOwner();
                ASSERT( pOwner != NULL );
                if( nID > 0 ) {
                    pState->m_nLastStatus = nID;
                    pState->m_pLastStatus = this;
                    pOwner->SendMessage( WM_SETMESSAGESTRING, nID );
                    SetTimer( TIMER_ID, 100, NULL );
                } else {
                    pState->m_nLastStatus = -1;
                    pState->m_pLastStatus = NULL;
                    pOwner->SendMessage( WM_POPMESSAGESTRING, AFX_IDS_IDLEMESSAGE );
                }
            }
        }
    }
    return( FALSE );
}
Exemple #6
0
void* __cdecl operator new(size_t nSize)
{
	void* pResult;
#ifdef _AFXDLL
	_PNH pfnNewHandler = _pfnUninitialized;
#endif
	for (;;)
	{
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
		pResult = _malloc_dbg(nSize, _NORMAL_BLOCK, NULL, 0);
#else
		pResult = malloc(nSize);
#endif
		if (pResult != NULL)
			return pResult;

#ifdef _AFXDLL
		if (pfnNewHandler == _pfnUninitialized)
		{
			AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
			pfnNewHandler = pState->m_pfnNewHandler;
		}
		if (pfnNewHandler == NULL || (*pfnNewHandler)(nSize) == 0)
			break;
#else
		if (_afxNewHandler == NULL || (*_afxNewHandler)(nSize) == 0)
			break;
#endif
	}
	return pResult;
}
Exemple #7
0
CControlBar::~CControlBar()
{
	ASSERT_VALID(this);

	m_pInPlaceOwner = NULL;

	DestroyWindow();    // avoid PostNcDestroy problems

	// also done in OnDestroy, but done here just in case
	if (m_pDockSite != NULL)
		m_pDockSite->RemoveControlBar(this);

	// free docking context
	CDockContext* pDockContext = m_pDockContext;
	m_pDockContext = NULL;
	delete pDockContext;

	// free array
	if (m_pData != NULL)
	{
		ASSERT(m_nCount != 0);
		free(m_pData);
	}

	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();
	if (pModuleThreadState->m_pLastStatus == this)
	{
		pModuleThreadState->m_pLastStatus = NULL;
		pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);
	}
}
Exemple #8
0
void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int nLine)
{
#ifdef _AFX_NO_DEBUG_CRT
	UNUSED_ALWAYS(nType);
	UNUSED_ALWAYS(lpszFileName);
	UNUSED_ALWAYS(nLine);
	return ::operator new(nSize);
#else
	void* pResult;
#ifdef _AFXDLL
	_PNH pfnNewHandler = _pfnUninitialized;
#endif
	for (;;)
	{
		pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
		if (pResult != NULL)
			return pResult;

#ifdef _AFXDLL
		if (pfnNewHandler == _pfnUninitialized)
		{
			AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
			pfnNewHandler = pState->m_pfnNewHandler;
		}
		if (pfnNewHandler == NULL || (*pfnNewHandler)(nSize) == 0)
			break;
#else
		if (_afxNewHandler == NULL || (*_afxNewHandler)(nSize) == 0)
			break;
#endif
	}
	return pResult;
#endif
}
BOOL DoExit()
{
#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}
	AfxLockTempMaps();
	AfxUnlockTempMaps(-1);
#endif

	AfxWinTerm();
	return TRUE;
}
Exemple #10
0
CDC * PASCAL CDC::FromHandle( HDC hDC )
/*************************************/
{
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHDC;
    ASSERT( pHandleMap != NULL );
    return( (CDC *)pHandleMap->FromHandle( hDC ) );
}
Exemple #11
0
_PNH AFXAPI AfxGetNewHandler(void)
{
#ifdef _AFXDLL
	AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
	return pState->m_pfnNewHandler;
#else
	return _afxNewHandler;
#endif
}
Exemple #12
0
CMenu * PASCAL CMenu::FromHandlePermanent( HMENU hMenu )
/******************************************************/
{
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHMENU;
    ASSERT( pHandleMap != NULL );
    return( (CMenu *)pHandleMap->LookupPermanent( hMenu ) );
}
Exemple #13
0
CImageList * PASCAL CImageList::FromHandlePermanent( HIMAGELIST hImageList )
/**************************************************************************/
{
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHIMAGELIST;
    ASSERT( pHandleMap != NULL );
    return( (CImageList *)pHandleMap->LookupPermanent( hImageList ) );
}
Exemple #14
0
void PASCAL CMenu::DeleteTempMap()
/********************************/
{
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHMENU;
    ASSERT( pHandleMap != NULL );
    pHandleMap->DeleteTemp();
}
Exemple #15
0
BOOL CListCtrlA::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ){
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

	CString i,j,k,l,m;
	UINT nID = pNMHDR->idFrom;
	AFX_MODULE_THREAD_STATE* pThreadState = AfxGetModuleThreadState();
	CToolTipCtrl *pToolTip = pThreadState->m_pToolTip;
	if(pToolTip==NULL) return FALSE;
	pToolTip->SetMaxTipWidth(500);
	if( nID == 0 )	  	// Notification in NT from automatically
		return FALSE;   	// created tooltip

	int row = ((nID-1) >> 10) & 0x3fffff ;
	int col = (nID-1) & 0x3ff;
	i = GetItemText( row, 0 );
	j = GetItemText( row, 3 );
	k = GetItemText( row, 4 );
	l = GetItemText( row, 2 );
	m = GetItemText( row, 1 );
	strTipText.Format(_T("名前:%s\nアーティスト:%s\nアルバム:%s\n時間:%s\n種類:%s"),i,j,k,l,m);

//#ifndef _UNICODE
//	if (pNMHDR->code == TTN_NEEDTEXTA)
//		lstrcpyn(pTTTA->szText, strTipText, 579);
//	else
//		_mbstowcsz(pTTTW->szText, strTipText, 579);
//#else
//	if (pNMHDR->code == TTN_NEEDTEXTA)
//		_wcstombsz(pTTTA->szText, strTipText, 579);
//	else
//		lstrcpyn(pTTTW->szText, strTipText, 579);
//#endif
#ifndef _UNICODE
	if (pNMHDR->code == TTN_NEEDTEXTA){
		lstrcpyn(ff1,strTipText,1024);
		pTTTA->lpszText= ff1;
		pTTTA->szText[0]=NULL;
	}
	else{
		int rr=MultiByteToWideChar(CP_ACP,0,strTipText,-1,ff2,1024);
		pTTTW->lpszText= ff2;
		pTTTW->szText[0]=NULL;
	}
#else
	if (pNMHDR->code == TTN_NEEDTEXTA)
		pTTTA->lpszText = (LPSTR)(LPWSTR)(LPCWSTR)strTipText;
	else
	    pTTTW->lpszText = (LPWSTR)(LPCWSTR)strTipText;
#endif
	*pResult = 0;

	return TRUE;    // message was handled
}
Exemple #16
0
CComClass::CComClass(CComGeneralClass *gc)
	:	m_pGeneralClass(gc)
	,	m_pModuleState(AfxGetModuleState())
{
	ZeroStruct(m_iid);
	if (gc) {
		AFX_MODULE_STATE *pMS = AfxGetModuleState();
		if (!pMS->m_typeLib.m_iTypeLib)
			pMS->m_typeLib.Load();
		AfxGetModuleThreadState()->m_classList.push_back(unique_ptr<CComClass>(this));
	}
}
// cleanup (opposite of init()). Destroys the window, unregisters the window class
void quitaltacast(struct winampDSPModule *this_mod)
{
	KillTimer(NULL, timerId);
    
    AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();

    if (pState->m_pmapHWND) {
        mainWindow->DestroyWindow();
    }

    delete mainWindow;
	int a = 1;
}
Exemple #18
0
_PNH AFXAPI AfxSetNewHandler(_PNH pfnNewHandler)
{
#ifdef _AFXDLL
	AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
	_PNH pfnOldHandler = pState->m_pfnNewHandler;
	pState->m_pfnNewHandler = pfnNewHandler;
	return pfnOldHandler;
#else
	_PNH pfnOldHandler = _afxNewHandler;
	_afxNewHandler = pfnNewHandler;
	return pfnOldHandler;
#endif
}
/*
================
CSyntaxRichEditCtrl::OnMouseMove
================
*/
void CSyntaxRichEditCtrl::OnMouseMove( UINT nFlags, CPoint point ) {
	CRichEditCtrl::OnMouseMove( nFlags, point );

	if ( point != mousePoint ) {
		mousePoint = point;

		// remove tool tip and activate the tool tip control, otherwise
		// tool tips stop working until the mouse moves over another window first
		AFX_MODULE_THREAD_STATE *state = AfxGetModuleThreadState();
		state->m_pToolTip->Pop();
		state->m_pToolTip->Activate( TRUE );
	}
}
CToolTipCtrl&  gGetToolTipCtrl() {
    AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();
    CToolTipCtrl* ctrl = pModuleThreadState->m_pToolTip;

    if (!ctrl) {
        pModuleThreadState->m_pToolTip = ctrl = CToolTipCtrlEx::Create();
        ctrl->Create(AfxGetMainWnd(), TTS_ALWAYSTIP | WS_VISIBLE | WS_POPUP);
        ctrl->ModifyStyleEx(0, WS_EX_TOPMOST);
        ctrl->SetDelayTime(-1);
        ctrl->Activate(TRUE);
    }

    return *ctrl;
}
Exemple #21
0
HIMAGELIST CImageList::Detach()
/*****************************/
{
    if( m_hImageList == NULL ) {
        return( NULL );
    }
    HIMAGELIST hImageList = m_hImageList;
    m_hImageList = NULL;
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHIMAGELIST;
    ASSERT( pHandleMap != NULL );
    pHandleMap->RemoveHandle( hImageList );
    return( hImageList );
}
Exemple #22
0
BOOL CImageList::Attach( HIMAGELIST hImageList )
/**********************************************/
{
    ASSERT( m_hImageList == NULL );
    if( hImageList == NULL ) {
        return( FALSE );
    }
    m_hImageList = hImageList;
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHIMAGELIST;
    ASSERT( pHandleMap != NULL );
    pHandleMap->SetPermanent( hImageList, this );
    return( TRUE );
}
Exemple #23
0
BOOL CMenu::Attach( HMENU hMenu )
/*******************************/
{
    ASSERT( m_hMenu == NULL );
    if( hMenu == NULL ) {
        return( FALSE );
    }
    m_hMenu = hMenu;
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHMENU;
    ASSERT( pHandleMap != NULL );
    pHandleMap->SetPermanent( hMenu, this );
    return( TRUE );
}
Exemple #24
0
HMENU CMenu::Detach()
/*******************/
{
    if( m_hMenu == NULL ) {
        return( NULL );
    }
    HMENU hMenu = m_hMenu;
    m_hMenu = NULL;
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHMENU;
    ASSERT( pHandleMap != NULL );
    pHandleMap->RemoveHandle( hMenu );
    return( hMenu );
}
Exemple #25
0
HDC CDC::Detach()
/***************/
{
    if( m_hDC == NULL ) {
        return( NULL );
    }
    HDC hDC = m_hDC;
    m_hDC = NULL;
    m_hAttribDC = NULL;
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHDC;
    ASSERT( pHandleMap != NULL );
    pHandleMap->RemoveHandle( hDC );
    return( hDC );
}
Exemple #26
0
BOOL CDC::Attach( HDC hDC )
/*************************/
{
    ASSERT( m_hDC == NULL );
    ASSERT( m_hAttribDC == NULL );
    if( hDC == NULL ) {
        return( FALSE );
    }
    m_hDC = hDC;
    m_hAttribDC = hDC;
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHDC;
    ASSERT( pHandleMap != NULL );
    pHandleMap->SetPermanent( hDC, this );
    return( TRUE );
}
Exemple #27
0
void CControlBar::OnDestroy()
{
	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();
	if (pModuleThreadState->m_pLastStatus == this)
	{
		SetStatusText(static_cast<INT_PTR>(-1));
		ASSERT(pModuleThreadState->m_pLastStatus == NULL);
	}

	if (m_pDockSite != NULL)
	{
		m_pDockSite->RemoveControlBar(this);
		m_pDockSite = NULL;
	}

	CWnd::OnDestroy();
}
Exemple #28
0
BOOL CWnd::_EnableToolTips(BOOL bEnable, UINT nFlag)
{
    ASSERT(nFlag == WF_TOOLTIPS || nFlag == WF_TRACKINGTOOLTIPS);

    AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();
    CToolTipCtrl* pToolTip = pModuleThreadState->m_pToolTip;

    if (!bEnable)
    {
        // nothing to do if tooltips not enabled
        if (!(m_nFlags & nFlag))
            return TRUE;

        // cancel tooltip if this window is active
        if (pModuleThreadState->m_pLastHit == this)
            CancelToolTips(TRUE);

        // remove "dead-area" toolbar
        if (pToolTip->GetSafeHwnd() != NULL)
        {
            TOOLINFO ti;
            memset(&ti, 0, sizeof(TOOLINFO));
            ti.cbSize = sizeof(AFX_OLDTOOLINFO);
            ti.uFlags = TTF_IDISHWND;
            ti.hwnd = m_hWnd;
            ti.uId = (UINT_PTR)m_hWnd;
            pToolTip->SendMessage(TTM_DELTOOL, 0, (LPARAM)&ti);
        }

        // success
        m_nFlags &= ~nFlag;
        return TRUE;
    }

    // if already enabled for tooltips, nothing to do
    if (!(m_nFlags & nFlag))
    {
        // success
        AFX_MODULE_STATE* pModuleState = _AFX_CMDTARGET_GETSTATE();
        pModuleState->m_pfnFilterToolTipMessage = &CWnd::_FilterToolTipMessage;
        m_nFlags |= nFlag;
    }
    return TRUE;
}
Exemple #29
0
static CHandleMap* afxMapHGDIOBJ(BOOL bCreate)
{
	AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
	if (pState->m_pmapHGDIOBJ == NULL && bCreate)
	{
		BOOL bEnable = AfxEnableMemoryTracking(FALSE);
#ifndef _AFX_PORTABLE
		_PNH pnhOldHandler = AfxSetNewHandler(&AfxCriticalNewHandler);
#endif
		pState->m_pmapHGDIOBJ = new CHandleMap(RUNTIME_CLASS(CGdiObject),
			offsetof(CGdiObject, m_hObject));

#ifndef _AFX_PORTABLE
		AfxSetNewHandler(pnhOldHandler);
#endif
		AfxEnableMemoryTracking(bEnable);
	}
	return pState->m_pmapHGDIOBJ;
}
Exemple #30
0
BOOL CDC::DeleteDC()
/******************/
{
    HDC hDC = m_hDC;
    if( m_hDC == NULL || !::DeleteDC( m_hDC ) ) {
        return( FALSE );
    }
    AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
    ASSERT( pState != NULL );
    CHandleMap *pHandleMap = pState->m_pmapHDC;
    ASSERT( pHandleMap != NULL );
    pHandleMap->RemoveHandle( m_hDC );
    m_hDC = NULL;
    if( m_hAttribDC != hDC && m_hAttribDC != NULL && !::DeleteDC( m_hAttribDC ) ) {
        return( FALSE );
    }
    m_hAttribDC = NULL;
    return( TRUE );
}