Faceți căutări pe acest blog

joi, 4 ianuarie 2018

Changing the hyperlink tooltip

Editboxes can allow following hyperlinks by setting EnableHyperlinks = .T.
In this case, any hyperlink is enhanced (the forecolor is blue and is underlined), and performing a CTRL+click, the default browser is launched.

If the form has Showtips = .T., then the tooltip "CTRL + click to follow the link" is showed each time you point to a hyperlink.

The application object _VFP, has a property named EditorOptions, which allow to switch between CTRL + click and Click to follow hyperlinks (among other things).
EditorOptions is a string, and contains by default "K", meaning CTRL +click for hyperlinks.
If you change "K" into "k", then only a mouse click is needed for the same action (without pressing CTRL).



PUBLIC ofrm
_vfp.EditorOptions = CHRTRAN(_vfp.EditorOptions, "K", "k") && Click instead of CTRL+Click
ofrm = CREATEOBJECT("MyForm")
ofrm.Show()

DEFINE CLASS MyForm as Form
      Showtips = .T.
      ADD OBJECT ed as Editbox WITH Value = "www.foxite.com" + CHR(13) + CHR(13) + "www.google.com",;
             EnableHyperlinks = .T.,;
             width = 300
ENDDEFINE


But the hyperlink tooltip remains unchanged, i.e. shows "CTRL + click to follow the link".

If you want to change this into "Click to follow the link", you have two options.

The easiest way is to disable the hyperlinks tooltip, and to add your own tooltip to editbox.



PUBLIC ofrm
_vfp.EditorOptions = CHRTRAN(_vfp.EditorOptions, "K", "k") && Click instead of CTRL+Click
sys(3008,0) && disable hyperlink tooltips
ofrm = CREATEOBJECT("MyForm")
ofrm.Show()

DEFINE CLASS MyForm as Form
      Showtips = .T.
      ADD OBJECT ed as Editbox WITH Value = "www.foxite.com" + CHR(13) + CHR(13) + "www.google.com",;
             EnableHyperlinks = .T.,;
             width = 300,;
             ToolTipText = "Click to follow link"
ENDDEFINE
 

But pointing hyperlinks, no tooltip is shown.

The second option is to edit (hack) the resource file. The file is stored in HOME(1), and depending on the language, this file is named VFP9ENU.DLL, VFP9KOR.DLL a.s.o

Because all you need is to change a string, you have to locate the position of the string, and to change it into another null-char ended string, with the same length.
Be aware that this is a potential dangerous action.
Make a copy of your DLL, before trying the next one (step one).


1) First made a safety copy of your DLL
2) move it from HOME(1) + VFP9ENU.DLL into a folder with enough rights (d:\teste in the next demo)
3) Run the next prg



ln = FOPEN("d:\teste\VFP9ENU.DLL",12)
?ln
?FSEEK(m.ln,0x5ef8) && 0x5ef8 is the offset of the "CTRL + click to follow link" message
lc = FGETS(m.ln,27) && 27 is the length of the "CTRL + click to follow link" message
lc = "Click to follow link" + REPLICATE(CHR(0),7) && the new message (7 is the number of deleted characters)
?FSEEK(m.ln,0x5ef8)
?FPUTS(m.ln,m.lc,27)
?FCLOSE(m.ln)

 4) copy the modified DLL back to HOME(1)

Similar steps can be made to the runtime DLL, stored in C:\Program Files\Common Files\microsoft shared\VFP and named VFP9RENU.DLL

The prg is a little different, because the string starts from another  byte



ln = FOPEN("d:\teste\VFP9RENU.DLL",12)
?ln
?FSEEK(m.ln,0x5e30) && 0x5e30 is the offset of the "CTRL + click to follow link" message
lc = FGETS(m.ln,27) && 27 is the length of the "CTRL + click to follow link" message
lc = "Click to follow link" + REPLICATE(CHR(0),7) && the new message (7 is the number of deleted characters)
?FSEEK(m.ln,0x5e30)
?FPUTS(m.ln,m.lc,27)
?FCLOSE(m.ln)
RETURN





Niciun comentariu:

Trimiteți un comentariu