//***************************************************************************************
void CBCGPOleDocIPFrameWnd::OnContextHelp ()
{
	m_bContextHelp = TRUE;

	if (!m_bHelpMode && CanEnterHelpMode())
	{
		CBCGPToolBar::SetHelpMode ();
	}

	CFrameWnd::OnContextHelp ();

	if (!m_bHelpMode)
	{
		CBCGPToolBar::SetHelpMode (FALSE);
	}

	m_bContextHelp = FALSE;
}
예제 #2
0
void COleIPFrameWnd::OnContextHelp()
{
	if (m_bHelpMode == HELP_ACTIVE || !CanEnterHelpMode())
		return;

	// notify container that we are entering context sensitive help
	BOOL bHelpMode = m_bHelpMode;
	m_bHelpMode = HELP_ACTIVE;
	ASSERT(m_lpFrame != NULL);
	if (m_lpFrame->ContextSensitiveHelp(TRUE) != S_OK ||
		(m_lpDocFrame != NULL && m_lpDocFrame->ContextSensitiveHelp(TRUE) != S_OK))
	{
		m_bHelpMode = HELP_INACTIVE;
		return;
	}
	m_bHelpMode = bHelpMode;

	// echo help mode to top-level frame
	CFrameWnd* pFrameWnd = GetTopLevelFrame();
	ENSURE(pFrameWnd);
	if (pFrameWnd != this)
	{
		pFrameWnd->m_bHelpMode = HELP_ACTIVE;
	}

	// now enter context sensitive help mode ourselves
	CFrameWnd::OnContextHelp();

	// echo help mode to top-level frame
	if (pFrameWnd != this)
		pFrameWnd->m_bHelpMode = m_bHelpMode;

	if (m_bHelpMode == HELP_INACTIVE)
	{
		// make sure container exits context sensitive help mode
		m_lpFrame->ContextSensitiveHelp(FALSE);
		if (m_lpDocFrame != NULL)
			m_lpDocFrame->ContextSensitiveHelp(FALSE);
	}
}
예제 #3
0
파일: winfrmx.cpp 프로젝트: Rupan/winscp
void CFrameWnd::OnContextHelp()
{
	// don't enter twice, and don't enter if initialization fails
	if (m_bHelpMode == HELP_ACTIVE || !CanEnterHelpMode())
		return;

	// don't enter help mode with pending WM_EXITHELPMODE message
	MSG msg;
	if (PeekMessage(&msg, m_hWnd, WM_EXITHELPMODE, WM_EXITHELPMODE,
		PM_REMOVE|PM_NOYIELD))
	{
		return;
	}

	BOOL bHelpMode = m_bHelpMode;
	ASSERT(m_bHelpMode == HELP_INACTIVE || m_bHelpMode == HELP_ENTERING);
	m_bHelpMode = HELP_ACTIVE;

#ifndef _AFX_NO_OLE_SUPPORT
	// allow any in-place active servers to go into help mode
	if (bHelpMode != HELP_ENTERING && m_pNotifyHook != NULL &&
		!m_pNotifyHook->OnContextHelp(TRUE))
	{
		TRACE0("Error: an in-place server failed to enter context help mode.\n");
		m_pNotifyHook->OnContextHelp(FALSE);    // undo partial help mode
		m_bHelpMode = HELP_INACTIVE;
		return;
	}
#endif

	if (bHelpMode == HELP_INACTIVE)
	{
		// need to delay help startup until later
		PostMessage(WM_COMMAND, ID_CONTEXT_HELP);
		m_bHelpMode = HELP_ENTERING;
		return;
	}

	ASSERT(m_bHelpMode == HELP_ACTIVE);

	// display special help mode message on status bar
	UINT nMsgSave = (UINT)SendMessage(WM_SETMESSAGESTRING,
		(WPARAM)AFX_IDS_HELPMODEMESSAGE);
	if (nMsgSave == 0)
		nMsgSave = AFX_IDS_IDLEMESSAGE;

	DWORD   dwContext = 0;
	POINT   point;

	GetCursorPos(&point);
	SetHelpCapture(point, NULL);
	LONG lIdleCount = 0;
	CWinApp* pApp = AfxGetApp();

	while (m_bHelpMode)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!ProcessHelpMsg(msg, &dwContext))
				break;
			ASSERT(dwContext == 0);
		}
		else if (!pApp->OnIdle(lIdleCount++))
		{
			lIdleCount = 0;
			WaitMessage();
		}
	}

	m_bHelpMode = HELP_INACTIVE;
	ReleaseCapture();

	// make sure the cursor is set appropriately
	SetCapture();
	ReleaseCapture();

	// restore original status bar text
	SendMessage(WM_SETMESSAGESTRING, (WPARAM)nMsgSave);

#ifndef _AFX_NO_OLE_SUPPORT
	// tell in-place servers to exit Shift+F1 help mode
	if (m_pNotifyHook != NULL)
		m_pNotifyHook->OnContextHelp(FALSE);
#endif

	if (dwContext != 0)
	{
		if (dwContext == -1)
			SendMessage(WM_COMMAND, ID_DEFAULT_HELP);
		else
			pApp->WinHelp(dwContext);
	}
	PostMessage(WM_KICKIDLE);    // trigger idle update
}
예제 #4
0
void CFrameWnd::OnContextHelp()
/*****************************/
{
    if( !m_bHelpMode && CanEnterHelpMode() ) {
        m_bHelpMode = TRUE;
        ::SetCursor( _HelpCursor );
        
        UINT nIDOld = (UINT)::SendMessage( m_hWnd, WM_SETMESSAGESTRING,
                                           AFX_IDS_HELPMODEMESSAGE, 0L );
        if( nIDOld == 0 ) {
            nIDOld = AFX_IDS_IDLEMESSAGE;
        }
        
        CWinApp *pApp = AfxGetApp();
        ASSERT( pApp != NULL );
        
        MSG         msg;
        LONG        lCount = 0L;
        DWORD_PTR   dwHelpId = 0L;
        for( ;; ) {
            while( !::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) {
                if( pApp->OnIdle( lCount ) ) {
                    lCount++;
                } else {
                    ::WaitMessage();
                }
            }
            ::GetMessage( &msg, NULL, 0, 0 );
            if( msg.message == WM_EXITHELPMODE ) {
                break;
            } else if( msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE ) {
                break;
            } else if( (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) ||
                       msg.message == WM_SYSCOMMAND ) {
                if( !pApp->PreTranslateMessage( &msg ) ) {
                    ::TranslateMessage( &msg );
                    if( msg.message != WM_SYSKEYDOWN && msg.message != WM_SYSKEYUP &&
                        msg.message != WM_SYSCHAR && msg.message != WM_SYSDEADCHAR &&
                        msg.message != WM_SYSCOMMAND ) {
                        continue;
                    }
                }
            } else if( msg.message == WM_LBUTTONDOWN ||
                       msg.message == WM_NCLBUTTONDOWN ) {
                int nHitTest = (int)::SendMessage( msg.hwnd, WM_NCHITTEST, 0,
                                                   MAKELPARAM( msg.pt.x, msg.pt.y ) );
                if( nHitTest == HTCLIENT ) {
                    HWND hWnd = msg.hwnd;
                    while( hWnd != NULL && dwHelpId == 0L ) {
                        CPoint point( msg.pt );
                        ::ScreenToClient( hWnd, &point );
                        dwHelpId = (DWORD_PTR)::SendMessage( hWnd, WM_HELPHITTEST, 0,
                                                             MAKELPARAM( point.x,
                                                                         point.y ) );
                        hWnd = ::GetParent( hWnd );
                    }
                    break;
                } else if( nHitTest >= 0 && nHitTest != HTMENU &&
                           nHitTest != HTSYSMENU ) {
                    dwHelpId = HID_BASE_NCAREAS + nHitTest;
                    break;
                }
            }
            ::DispatchMessage( &msg );
        }
        m_bHelpMode = FALSE;
        ::SendMessage( m_hWnd, WM_SETMESSAGESTRING, nIDOld, 0L );

        POINT point;
        ::GetCursorPos( &point );

        HWND hWndCursor = ::WindowFromPoint( point );
        if( hWndCursor != NULL ) {
            int nHitTest = (int)::SendMessage( hWndCursor, WM_NCHITTEST, 0,
                                                 MAKELPARAM( point.x, point.y ) );
            ::SendMessage( hWndCursor, WM_SETCURSOR, (WPARAM)hWndCursor,
                           MAKELPARAM( nHitTest, WM_MOUSEMOVE ) );
        } else {
            HCURSOR hCursor = ::LoadCursor( NULL, IDC_ARROW );
            ::SetCursor( hCursor );
        }

        if( dwHelpId != 0L ) {
            pApp->WinHelpInternal( dwHelpId );
        }
    }
}