Kbase P14443: PUT-KEY-VALUE appears not to work for fonts when using custom environments.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/9/2009 |
|
Status: Verified
SYMPTOM(s):
PUT-KEY-VALUE appears not to work for fonts when using custom environments
Using SYSTEM-DIALOG FONT to change the font settings of a custom environment
PUT-KEY-VALUE FONT does not save changed fonts to specified environment
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
CAUSE:
This is expected behavior.
It caused by the way the fonts are handled during a session, and the way this interacts with the loading and using of custom environments.
The font settings are loaded only once, at session startup. LOADing and USEing an environment with font settings will not activate the new font settings.
In addition, the SYSTEM-DIALOG FONT used to change font settings at run-time interacts only with the default environment.
FIX:
To work around this, implement the following steps:
1. Add a dummy font to current environment.
2. Use the SYSTEM-DIALOG FONT box to let the user enter the font settings in that dummy font.
3. Save the dummy font to the default environment using PUT-KEY-VALUE.
4. Use GET-KEY-VALUE to get the font key value from the dummy font.
5. LOAD and USE the custom environment and use 'PUT-KEY-VALUE SECTION "Fonts" KEY "FontXX" VALUE <key value>' to save the key under the correct font number in the custom environment.
Example code:
/* Variables */
DEFINE VARIABLE cIniFilename AS CHARACTER NO-UNDO LABEL ".INI Filename".
DEFINE VARIABLE iOldNumEntries AS INTEGER NO-UNDO.
DEFINE VARIABLE iDummyFont AS INTEGER NO-UNDO.
DEFINE VARIABLE iFontNumber AS INTEGER NO-UNDO LABEL "Font number".
DEFINE VARIABLE cFontValue AS CHARACTER NO-UNDO.
/* Stretch font table and determine number for dummy font */
ASSIGN iOldNumEntries = FONT-TABLE:NUM-ENTRIES
FONT-TABLE:NUM-ENTRIES = FONT-TABLE:NUM-ENTRIES + 1
iDummyFont = FONT-TABLE:NUM-ENTRIES - 1.
/* Ask environment and font number to update */
UPDATE cIniFilename.
DISPLAY iFontNumber "( 8 - " + STRING(iOldNumEntries - 1) + ")".
UPDATE iFontNumber.
/* Ask for a font value using the dummy font */
SYSTEM-DIALOG FONT iDummyFont.
/* Put the value in the default environment and get the key value again */
/* to determine what value should be written to the ini-file. */
PUT-KEY-VALUE FONT iDummyFont.
GET-KEY-VALUE SECTION "Fonts" KEY "Font" + STRING(iDummyFont) VALUE cFontValue.
/* test code to show that the correct value is retrieved */
MESSAGE cFontValue VIEW-AS ALERT-BOX.
/* Load and use the environment where you want to write the key */
IF SEARCH(cIniFilename) = ? THEN LOAD cIniFilename BASE-KEY "INI" NEW.
ELSE LOAD cIniFilename BASE-KEY "INI".
USE cIniFilename.
PUT-KEY-VALUE SECTION "Fonts" KEY "Font" + STRING(iFontNumber) VALUE cFontValue.
/* clean up after write */
USE "".
UNLOAD cIniFilename.
PUT-KEY-VALUE SECTION "Fonts" KEY "Font" + STRING(iDummyFont) VALUE ?.
FONT-TABLE:NUM-ENTRIES = iOldNumEntries.