void CWinThread::DispatchThreadMessage( MSG *pMsg )
/*************************************************/
{
    const AFX_MSGMAP *pMessageMap = GetMessageMap();
    for( ;; ) {
        const AFX_MSGMAP_ENTRY *pEntries = pMessageMap->lpEntries;
        int i = 0;
        while( pEntries[i].nSig != AfxSig_end ) {
            if( pEntries[i].nMessage == 0xC000 ) {
                if( *(UINT *)pEntries[i].nSig == pMsg->message ) {
                    (this->*(PHANDLER_THREAD)(AFX_PMSGT)pEntries[i].pfn)(
                        pMsg->wParam, pMsg->lParam );
                    return;
                }
            } else if( pEntries[i].nMessage == pMsg->message ) {
                if( pEntries[i].nSig == AfxSig_v_w_l ) {
                    (this->*(PHANDLER_THREAD)(AFX_PMSGT)pEntries[i].pfn)(
                        pMsg->wParam, pMsg->lParam );
                }
                return;
            }
            i++;
        }
        if( pMessageMap->pfnGetBaseMap == NULL ) {
            break;
        }
        pMessageMap = pMessageMap->pfnGetBaseMap();
    }
}
Exemple #2
0
LRESULT CWnd::WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
{
	AFX_MSGMAP* pMessageMap;
	AFX_MSGMAP_ENTRY* lpEntry;

	if (nMsg == WM_COMMAND)
	{
		if (OnCommand(wParam, lParam))
		{
			return 1L;
		}
		else
		{
			return (LRESULT)DefWindowProc(nMsg, wParam, lParam);
		}
	}

	pMessageMap = GetMessageMap();


	for (;pMessageMap != NULL; pMessageMap = pMessageMap->pBaseMessageMap)
	{
		lpEntry = pMessageMap->lpEntries;
		printlpEntries(lpEntry);
	}
	return 0;
}
Exemple #3
0
LRESULT CWnd::WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
{
    AFX_MSGMAP* pMessageMap;
    AFX_MSGMAP_ENTRY* lpEntry;

    cout << "CWnd::WindowProc()" << endl;
    if (nMsg == WM_COMMAND) // special case for commands
    {
        if (OnCommand(wParam, lParam))
            return 1L; // command handled
        else
            return (LRESULT)DefWindowProc(nMsg, wParam, lParam);
    }

    pMessageMap = GetMessageMap();

    for (; pMessageMap != NULL;
         pMessageMap = pMessageMap->pBaseMessageMap)
    {
            lpEntry = pMessageMap->lpEntries;
            printlpEntries(lpEntry);
    }
    return 0;  // J.J.Hou: if find, should call lpEntry->pfn,
               // otherwise should call DefWindowProc.
               // for simplization, we just return 0.
}
Exemple #4
0
bool CNotifyPump::LoopDispatch(TNotifyUI& msg)
{
	const DUI_MSGMAP_ENTRY* lpEntry = NULL;
	const DUI_MSGMAP* pMessageMap = NULL;

#ifndef UILIB_STATIC
	for(pMessageMap = GetMessageMap(); pMessageMap!=NULL; pMessageMap = (*pMessageMap->pfnGetBaseMap)())
#else
	for(pMessageMap = GetMessageMap(); pMessageMap!=NULL; pMessageMap = pMessageMap->pBaseMap)
#endif
	{
#ifndef UILIB_STATIC
		ASSERT(pMessageMap != (*pMessageMap->pfnGetBaseMap)());
#else
		ASSERT(pMessageMap != pMessageMap->pBaseMap);
#endif
		if ((lpEntry = DuiFindMessageEntry(pMessageMap->lpEntries,msg)) != NULL)
		{
			goto LDispatch;
		}
	}
	return false;

LDispatch:
	union DuiMessageMapFunctions mmf;
	mmf.pfn = lpEntry->pfn;

	bool bRet = false;
	int nSig;
	nSig = lpEntry->nSig;
	switch (nSig)
	{
	default:
		ASSERT(FALSE);
		break;
	case DuiSig_lwl:
		(this->*mmf.pfn_Notify_lwl)(msg.wParam,msg.lParam);
		bRet = true;
		break;
	case DuiSig_vn:
		(this->*mmf.pfn_Notify_vn)(msg);
		bRet = true;
		break;
	}
	return bRet;
}
Exemple #5
0
BOOL CCmdTarget::OnCmdMsg(UINT nID, int nCode)
{
	AFX_MSGMAP* pMessageMap;
	AFX_MSGMAP_ENTRY* lpEntry;
	for (pMessageMap = GetMessageMap(); pMessageMap != NULL; pMessageMap = pMessageMap->pBaseMessageMap)
	{
		lpEntry = pMessageMap->lpEntries;
		printlpEntries(lpEntry);
	}
	return FALSE;
}
Exemple #6
0
void WindowImplBase::Notify(TNotifyUI& msg)
{
	const DUI_MSGMAP* pMessageMap = NULL;
	const DUI_MSGMAP_ENTRY* lpEntry = NULL;

#ifndef UILIB_STATIC
	for(pMessageMap = GetMessageMap(); pMessageMap!=NULL; pMessageMap = (*pMessageMap->pfnGetBaseMap)())
#else
	for(pMessageMap = GetMessageMap(); pMessageMap!=NULL; pMessageMap = pMessageMap->pBaseMap)
#endif
	{
#ifndef UILIB_STATIC
		ASSERT(pMessageMap != (*pMessageMap->pfnGetBaseMap)());
#else
		ASSERT(pMessageMap != pMessageMap->pBaseMap);
#endif
		if ((lpEntry = DuiFindMessageEntry(pMessageMap->lpEntries,msg)) != NULL)
		{
			goto LDispatch;
		}
	}
	return;

LDispatch:
	union DuiMessageMapFunctions mmf;
	mmf.pfn = lpEntry->pfn;

	int nSig;
	nSig = lpEntry->nSig;
	switch (nSig)
	{
	default:
		ASSERT(FALSE);
		break;
	case DuiSig_lwl:
		break;
	case DuiSig_vn:
		(this->*mmf.pfn_Notify_vn)(msg);
		break;
	}
}
Exemple #7
0
void CMainWindow :: callProc()
{
  const AFX_MSGMAP* pMessageMap;
  const AFX_MSGMAP_ENTRY *lpEntry;

  pMessageMap = GetMessageMap();
  lpEntry = pMessageMap->lpEntries;

  if( lpEntry->nMessage == 100) {
    (this->*lpEntry->pfn)();
  }
}
Exemple #8
0
BOOL CCmdTarget::OnCmdMsg(UINT nID, int nCode)
{
    cout << "CCmdTarget::OnCmdMsg()" << endl;
    // Now look through message map to see if it applies to us
    AFX_MSGMAP* pMessageMap;
    AFX_MSGMAP_ENTRY* lpEntry;
    for (pMessageMap = GetMessageMap(); pMessageMap != NULL;
         pMessageMap = pMessageMap->pBaseMessageMap)
    {
            lpEntry = pMessageMap->lpEntries;
            printlpEntries(lpEntry);
    }

    return FALSE;   // not handled
}
Exemple #9
0
bool CWinThread::DispatchThreadMessageEx(MSG& msg) {
	const AFX_MSGMAP* pMessageMap; pMessageMap = GetMessageMap();
	const AFX_MSGMAP_ENTRY* lpEntry;

	for (; pMessageMap->pfnGetBaseMap; pMessageMap=(*pMessageMap->pfnGetBaseMap)())
	{
		// Note: catch not so common but fatal mistake!!
		//      BEGIN_MESSAGE_MAP(CMyThread, CMyThread)
		ASSERT(pMessageMap != (*pMessageMap->pfnGetBaseMap)());

		if (msg.message < 0xC000)
		{
			// constant window message
			if ((lpEntry = AfxFindMessageEntry(pMessageMap->lpEntries,
				msg.message, 0, 0)) != NULL)
				goto LDispatch;
		}
		else
		{
			// registered windows message
			lpEntry = pMessageMap->lpEntries;
			while ((lpEntry = AfxFindMessageEntry(lpEntry, 0xC000, 0, 0)) != NULL)
			{
				UINT* pnID = (UINT*)(lpEntry->nSig);
				ASSERT(*pnID >= 0xC000);
				// must be successfully registered
				if (*pnID == msg.message)
					goto LDispatch;
				lpEntry++;      // keep looking past this one
			}
		}
	}
	return FALSE;

LDispatch:
	union MessageMapFunctions mmf;
	mmf.pfn_THREAD = 0;
	mmf.pfn = lpEntry->pfn;

	// always posted, so return value is meaningless

	(this->*mmf.pfn_THREAD)(msg.wParam, msg.lParam);
	return TRUE;
}
Exemple #10
0
//
//	[public] ODBCGridCtrl::IsCmdHandled
//
BOOL
ODBCGridCtrl::IsCmdHandled(UINT nCode, UINT nCmdId)
	{
	const AFX_MSGMAP*	pMsgMap = GetMessageMap();
	int					iLoop	= 0;
	
	while( pMsgMap->lpEntries[iLoop].nID )
		{
		
		if( pMsgMap->lpEntries[iLoop].nCode == nCode && 
			pMsgMap->lpEntries[iLoop].nID	== nCmdId )
			{
			return TRUE;
			}
		
		iLoop ++;
		}
	
	return FALSE;
	}
Exemple #11
0
//
//	[public] ODBCGridCtrl::InitCommands
//
void
ODBCGridCtrl::InitCommands(UINT nCmdDelete, UINT nCmdAddNew)
	{
	const AFX_MSGMAP*	pMsgMap = GetMessageMap();
	int					iLoop	= 0;
	// Replace identifiers in message map. ################
	while( pMsgMap->lpEntries[iLoop].nID )
		{
		UINT* pID = (UINT*)&pMsgMap->lpEntries[iLoop].nID;
		if( *pID == (WORD)-1 )
			{
			MEMORY_BASIC_INFORMATION mbi_thunk;
			VirtualQuery(pID, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
			VERIFY(VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, PAGE_READWRITE, &mbi_thunk.Protect));

			*pID = nCmdDelete;

			// Change the protection back to what it was before I blasted.
			DWORD dwOldProtect;
			VERIFY(VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, mbi_thunk.Protect, &dwOldProtect));
			}
		else
		if( *pID == (WORD)-2 )
			{
			MEMORY_BASIC_INFORMATION mbi_thunk;
			VirtualQuery(pID, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
			VERIFY(VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, PAGE_READWRITE, &mbi_thunk.Protect));

			*pID = nCmdAddNew;

			// Change the protection back to what it was before I blasted.
			DWORD dwOldProtect;
			VERIFY(VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, mbi_thunk.Protect, &dwOldProtect));
			}
		iLoop ++;
		}
	// ####################################################
	}