Example #1
0
/*
 * Function CHyperLink::ConvertStaticToHyperlink
 */
BOOL CHyperLink::ConvertStaticToHyperlink(HWND hwndCtl, LPCTSTR strURL)
{
    if( !(setURL(strURL)) )
		return FALSE;
	
	// Subclass the parent so we can color the controls as we desire.

	HWND hwndParent = GetParent(hwndCtl);
	if (NULL != hwndParent)
	{
		WNDPROC pfnOrigProc = (WNDPROC) GetWindowLongPtr(hwndParent, GWLP_WNDPROC);
		if (pfnOrigProc != _HyperlinkParentProc)
		{
			SetProp( hwndParent, PROP_ORIGINAL_PROC, (HANDLE)pfnOrigProc );
			SetWindowLongPtr( hwndParent, GWLP_WNDPROC,
				           (LONG) (WNDPROC) _HyperlinkParentProc );
		}
	}

	// Make sure the control will send notifications.

	LONG_PTR Style = GetWindowLongPtr(hwndCtl, GWL_STYLE);
	SetWindowLongPtr(hwndCtl, GWL_STYLE, Style | SS_NOTIFY);

	// Create an updated font by adding an underline.

	m_StdFont = (HFONT) SendMessage(hwndCtl, WM_GETFONT, 0, 0);

	if( g_counter++ == 0 )
	{
		createGlobalResources();
	}

	// Subclass the existing control.

	m_pfnOrigCtlProc = (WNDPROC) GetWindowLongPtr(hwndCtl, GWLP_WNDPROC);
	SetProp(hwndCtl, PROP_OBJECT_PTR, (HANDLE) this);
	SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, (LONG) (WNDPROC) _HyperlinkProc);

	// Set font to underlined font

	SendMessage(hwndCtl, WM_SETFONT, (WPARAM)CHyperLink::g_UnderlineFont, FALSE);

	return TRUE;
}
Example #2
0
bool CLinkControl::ConvertStaticToLink(HWND hwndCtl)
{
    // Subclass the parent so we can draw the controls ourselves
    HWND hwndParent = GetParent(hwndCtl);
    if (hwndParent)
    {
        WNDPROC pfnOrigProc = (WNDPROC) GetWindowLongPtr(hwndParent, GWLP_WNDPROC);
        if (pfnOrigProc != _HyperlinkParentProc)
        {
            if (SetProp(hwndParent, PROP_ORIGINAL_PROC, (HANDLE)pfnOrigProc))
                SetWindowLongPtr(hwndParent, GWLP_WNDPROC, (LONG_PTR)(WNDPROC)_HyperlinkParentProc);
        }
    }

    // Make sure the control will send notifications.

    LONG_PTR Style = GetWindowLongPtr(hwndCtl, GWL_STYLE);
    SetWindowLongPtr(hwndCtl, GWL_STYLE, Style | SS_NOTIFY);

    // Create an updated font by adding an underline.

    m_StdFont = (HFONT) SendMessage(hwndCtl, WM_GETFONT, 0, 0);

    if (g_counter++ == 0)
    {
        createGlobalResources();
    }
    SendMessage(hwndCtl, WM_SETFONT, (WPARAM)CLinkControl::g_NormalFont, FALSE);

    // Subclass the existing control.

    m_pfnOrigCtlProc = (WNDPROC)GetWindowLongPtr(hwndCtl, GWLP_WNDPROC);
    if (SetProp(hwndCtl, PROP_OBJECT_PTR, (HANDLE)this))
        SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, (LONG_PTR)(WNDPROC)_HyperlinkProc);

    return true;
}