GetFont() function
Posted: Sat May 14, 2022 4:15 pm
Hi Devteam,
is it allowed to use reflection to implement a x# runtime function ? I ask because i currently try to implement the VFP GetFont() function. Unfortunately, the Setoption() method of the .net FontDialog class is an internal method, but fortunately this method is accessible via reflection. I´m using this method to disable the script combobox and to enable the font description.
Here´s a snippet how my code currently looks like:
What do you think ?
regards
Karl-Heinz
is it allowed to use reflection to implement a x# runtime function ? I ask because i currently try to implement the VFP GetFont() function. Unfortunately, the Setoption() method of the .net FontDialog class is an internal method, but fortunately this method is accessible via reflection. I´m using this method to disable the script combobox and to enable the font description.
Here´s a snippet how my code currently looks like:
Code: Select all
oDlg := FontDialog{}
oMi := TypeOf(FontDialog):GetMethod("SetOption", BindingFlags.NonPublic | BindingFlags.Instance)
IF oMi != NULL
// this enables the font description that is always shown in the left/bottom area of the VFP GetFont() dialog
oMI:Invoke(oDlg, { CF_PRINTERFONTS, TRUE })
// btw. Its possible to include fonts like Courier, FixedSys, Terminal
// But since the .net FontDialog supports true type fonts only, trying to select e.g. FixedSys
// would trigger the .net runtime error "only true type fonts are supported"!
//
// oMI:Invoke(oDlg, { 0x00040000L , FALSE }) // CF_TTONLY
ENDIF
oDlg:ShowEffects := FALSE
oDlg:ShowHelp := TRUE
oDlg:MinSize := 4
oDlg:MaxSize := 127
lReturnCharSet := IIF ( IsNil ( nFontCharSet ) , FALSE , TRUE )
IF oMi != NULL .and. ! lReturnCharSet
// this disables the script combobox
oMI:Invoke(oDlg, { CF_NOSCRIPTSEL, TRUE })
ENDIF
regards
Karl-Heinz