Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

winhyperlinks.h File Reference

#include <windows.h>

Include dependency graph for winhyperlinks.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define IDC_HAND   MAKEINTRESOURCE(32649)

Functions

BOOL MakeHyperlinkFromStaticCtrl (HWND hDlg, UINT ctrlID)


Define Documentation

#define IDC_HAND   MAKEINTRESOURCE(32649)
 

Definition at line 22 of file winhyperlinks.h.

Referenced by _HyperlinkProc().


Function Documentation

BOOL MakeHyperlinkFromStaticCtrl HWND  hDlg,
UINT  ctrlID
 

Definition at line 154 of file winhyperlinks.cpp.

References _HyperlinkParentProc(), _HyperlinkProc(), BOOL(), HANDLE(), hyperLinkFromStatic, hyperLinkOriginalFont, hyperLinkOriginalProc, and hyperLinkUnderlineFont.

Referenced by AboutProc().

00155 {
00156     BOOL result = FALSE;
00157 
00158     HWND hCtrl = GetDlgItem(hDlg, ctrlID);
00159     if (hCtrl)
00160     {
00161         // Subclass the parent so we can color the controls as we desire.
00162         HWND hParent = GetParent(hCtrl);
00163         if (hParent)
00164         {
00165             WNDPROC origProc = (WNDPROC)GetWindowLong(hParent, GWL_WNDPROC);
00166             if (origProc != _HyperlinkParentProc)
00167             {
00168                 SetProp(hParent, hyperLinkOriginalProc, (HANDLE)origProc);
00169                 SetWindowLong(hParent, GWL_WNDPROC, (LONG)(WNDPROC)_HyperlinkParentProc);
00170             }
00171         }
00172 
00173         // Make sure the control will send notifications.
00174         DWORD dwStyle = GetWindowLong(hCtrl, GWL_STYLE);
00175         SetWindowLong(hCtrl, GWL_STYLE, dwStyle | SS_NOTIFY);
00176 
00177         // Subclass the existing control.
00178         WNDPROC origProc = (WNDPROC)GetWindowLong(hCtrl, GWL_WNDPROC);
00179         SetProp(hCtrl, hyperLinkOriginalProc, (HANDLE)origProc);
00180         SetWindowLong(hCtrl, GWL_WNDPROC, (LONG)(WNDPROC)_HyperlinkProc);
00181 
00182         // Create an updated font by adding an underline.
00183         HFONT hOrigFont = (HFONT) SendMessage(hCtrl, WM_GETFONT, 0, 0);
00184         SetProp(hCtrl, hyperLinkOriginalFont, (HANDLE)hOrigFont);
00185 
00186         LOGFONT lf;
00187         GetObject(hOrigFont, sizeof(lf), &lf);
00188         lf.lfUnderline = TRUE;
00189 
00190         HFONT hFont = CreateFontIndirect(&lf);
00191         SetProp(hCtrl, hyperLinkUnderlineFont, (HANDLE)hFont);
00192 
00193         // Set a flag on the control so we know what color it should be.
00194         SetProp(hCtrl, hyperLinkFromStatic, (HANDLE)1);
00195 
00196         result = TRUE;
00197     }
00198 
00199     return result;
00200 }


Generated on Sat Jan 14 22:32:32 2006 for Celestia by  doxygen 1.4.1