click me

Started by paulDiagnos, January 19, 2009, 07:51:34 AM

Previous topic - Next topic

paulDiagnos

Hi Guys,

currently I have a Gui that the title displays info for the user to look at.

Ideally what i want is when the user does something wrong to have a help 'Click Me' in the style of a blue underlined link

so the Title would say something like :

"Error you have done something wrong for help click me "

looking at the Richtext it seems it could be done this way but has trouble redrawing and looks a mess. is there a way to do this using the labels?

Paul.

TechSupport

Hi Paul,

FireFly 3 has a dedicated label/link type of custom control so this sort of thing will be very easy to do. In the meantime, you can simulate the hyperlink type of label by using code like I have posted below.

The code basically changes the font of the label control whenever the mouse hovers over it. In the FireFly designer, set the initial font of the label to whatever font style and size you wish and also its color (blue). The code below simply takes this font and adds an underline to it.


'------------------------------------------------------------------------------------------------------------------------
Function FRMLINK_LBLLINK_STN_CLICKED ( _
                                     ControlIndex     As Long,  _  ' index in Control Array
                                     hWndForm         As Dword, _  ' handle of Form
                                     hWndControl      As Dword, _  ' handle of Control
                                     idStaticControl  As Long   _  ' identifier of static control
                                     ) As Long
   
    MsgBox "Label has been clicked"
   
End Function


'------------------------------------------------------------------------------------------------------------------------
Function FRMLINK_LBLLINK_CUSTOM ( _
                                ControlIndex  As Long,  _  ' index in Control Array
                                hWndForm      As Dword, _  ' handle of Form
                                hWndControl   As Dword, _  ' handle of Control
                                wMsg          As Long,  _  ' type of message
                                wParam        As Dword, _  ' first message parameter
                                lParam        As Long   _  ' second message parameter
                                ) As Long

   Local trackMouse As TRACKMOUSEEVENTAPI
   Local lf         As LOGFONT
   
   Static hOrigFont As Long
   Static hHotFont  As Long
   

   Select Case wMsg
   
      Case %WM_MOUSEMOVE
         trackMouse.cbSize      = SizeOf(trackMouse)
         trackMouse.dwFlags     = %TME_LEAVE
         trackMouse.hwndTrack   = hWndControl
         trackMouse.dwHoverTime = 1
         TrackMouseEvent trackMouse
         
         ' Save the current font
         If hOrigFont = 0 Then
            hOrigFont = SendMessage( hWndControl, %WM_GETFONT, 0, 0 )
         End If
         
         ' Create the HotFont if it does not already exist. Base it on the
         ' curent font but underline it.
         If hHotFont = 0 Then
            GetObject hOrigFont, SizeOf(lf), ByVal VarPtr(lf)
            lf.lfUnderline = %TRUE
            hHotFont       = CreateFontIndirect(lf)
         End If

         ' Change the font of the Label to use the hot font. Check if the
         ' font is already set in order to reduce flicker.
         If SendMessage( hWndControl, %WM_GETFONT, 0, 0 ) <> hHotFont Then
            SendMessage hWndControl, %WM_SETFONT, hHotFont, %TRUE
         End If
     
      Case %WM_MOUSELEAVE
         ' Change the font back to its original
         SendMessage hWndControl, %WM_SETFONT, hOrigFont, %TRUE

     
      Case %WM_DESTROY
         ' Destroy the hot font
         DeleteObject hHotFont
         
   End Select
   
End Function


Hope this works for you!


paulDiagnos

brilliant as always Paul, I want to have your children...

its just a shame i can choose what part of the text is to be underlined, or change the colour of it.

here is to ff3

Paul.

TechSupport

Quote from: paulDiagnos on January 19, 2009, 11:03:19 AM
brilliant as always Paul, I want to have your children...
:D

Quote
its just a shame i can choose what part of the text is to be underlined, or change the colour of it.
A workaround would be to place a normal label to the left before the "hot" link label. You could put your normal text in the normal label, and put your mouseover hot text in the second label.

Quote
here is to ff3
I can't wait to get this beast finished! I'm getting sick of looking at the code. :)