FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index All products support ChooseFont
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
ChooseFont
Posted: Tue Dec 13, 2005 04:48 PM

Ciao FW's
devo rendere interattiva a scelta di font per la stampa, non riesco a verificare le fasi di annullamento da parte dell'utente, infatti se seleziona un qualsiasi font e poi annulla nell'array ritorna l'impostazione effettuata.
Inoltre non mi sembra funzionare bene l'impostazione della dimensione, imposto 12 e visualizza 9, poi seleziono 12 e ritorna 16 ????

Uso ancora la versione 2.5 forse ci sono stati degi aggiornamenti...

Mi confermate?

Grazie per le risposte.

Esempietto:

define LF_HEIGHT 1

define LF_WIDTH 2

define LF_ESCAPEMENT 3

define LF_ORIENTATION 4

define LF_WEIGHT 5

define LF_ITALIC 6

define LF_UNDERLINE 7

define LF_STRIKEOUT 8

define LF_CHARSET 9

define LF_OUTPRECISION 10

define LF_CLIPPRECISION 11

define LF_QUALITY 12

define LF_PITCHANDFAMILY 13

define LF_FACENAME 14

define FW_NORMAL 400

define FW_BOLD 700

//------------------------------------------------------------------------------

FUNCTION SelectFont( )

LOCAL aFont[14], oIni, aOldFont, cFont

INI oIni FILE DirPrg() + "\" + ExeName() + ".INI"
GET cFont SECTION "Stampanti" ENTRY "FontInStampa" OF oIni DEFAULT "Arial| 0| -12| 0| 0| 0| 0| 0"
ENDINI

MsgInfo( cFont )

aFont[LF_FACENAME] := ALLTRIM(StrToken(cFont,1,"|" ))
aFont[LF_WIDTH] := VAL( StrToken( cFont, 2, "|" ))
aFont[LF_HEIGHT] := VAL( StrToken( cFont, 3, "|" ))
aFont[LF_WEIGHT] := IF( VAL( StrToken( cFont, 4, "|" )) > 0, FW_BOLD, FW_NORMAL )
aFont[LF_ESCAPEMENT] := VAL( StrToken( cFont, 5, "|" ))
aFont[LF_ITALIC] := VAL( StrToken( cFont, 6, "|" )) > 1
aFont[LF_UNDERLINE] := VAL( StrToken( cFont, 7, "|" )) > 1

aOldFont := AClone( aFont )

aFont := ChooseFont( aFont )

cFont := aFont[LF_FACENAME] + "|" +;
cValToChar( aFont[LF_WIDTH] ) + "|" +;
cValToChar( aFont[LF_HEIGHT] ) + "|" +;
cValToChar( aFont[LF_WEIGHT] ) + "|" +;
cValToChar( aFont[LF_ESCAPEMENT] ) + "|" +;
cValToChar( aFont[LF_ITALIC] ) + "|" +;
cValToChar( aFont[LF_UNDERLINE] )

// Test in uscita
MsgInfo( cFont )

return If( ! Empty( aFont[ LF_FACENAME ] ), aFont, aOldFont )

//------------------------------------------------------------------------------

Ciao, best regards,

Ugo
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ChooseFont
Posted: Tue Dec 13, 2005 07:09 PM

Mi dispiace ma il tuo esempietto non è compilabile.

EMG

Posts: 155
Joined: Tue Dec 30, 2008 03:07 AM
ChooseFont
Posted: Wed Dec 14, 2005 09:38 AM

Prova ora:

define LF_HEIGHT 1

define LF_WIDTH 2

define LF_ESCAPEMENT 3

define LF_ORIENTATION 4

define LF_WEIGHT 5

define LF_ITALIC 6

define LF_UNDERLINE 7

define LF_STRIKEOUT 8

define LF_CHARSET 9

define LF_OUTPRECISION 10

define LF_CLIPPRECISION 11

define LF_QUALITY 12

define LF_PITCHANDFAMILY 13

define LF_FACENAME 14

define FW_NORMAL 400

define FW_BOLD 700

//------------------------------------------------------------------------------

FUNCTION Main( )

LOCAL aFont[14], oIni, aOldFont, cFont

INI oIni FILE "prova.ini"
GET cFont SECTION "Stampanti" ENTRY "FontInStampa" OF oIni DEFAULT "Arial| 0| -12| 0| 0| 0| 0| 0"
ENDINI

MsgInfo( cFont )

aFont[LF_FACENAME] := ALLTRIM(StrToken(cFont,1,"|" ))
aFont[LF_WIDTH] := VAL( StrToken( cFont, 2, "|" ))
aFont[LF_HEIGHT] := VAL( StrToken( cFont, 3, "|" ))
aFont[LF_WEIGHT] := IF( VAL( StrToken( cFont, 4, "|" )) > 0, FW_BOLD, FW_NORMAL )
aFont[LF_ESCAPEMENT] := VAL( StrToken( cFont, 5, "|" ))
aFont[LF_ITALIC] := VAL( StrToken( cFont, 6, "|" )) > 1
aFont[LF_UNDERLINE] := VAL( StrToken( cFont, 7, "|" )) > 1

aOldFont := AClone( aFont )

aFont := ChooseFont( aFont )

cFont := aFont[LF_FACENAME] + "|" +;
cValToChar( aFont[LF_WIDTH] ) + "|" +;
cValToChar( aFont[LF_HEIGHT] ) + "|" +;
cValToChar( aFont[LF_WEIGHT] ) + "|" +;
cValToChar( aFont[LF_ESCAPEMENT] ) + "|" +;
cValToChar( aFont[LF_ITALIC] ) + "|" +;
cValToChar( aFont[LF_UNDERLINE] )

// Test in uscita
MsgInfo( cFont )

return If( ! Empty( aFont[ LF_FACENAME ] ), aFont, aOldFont )

//------------------------------------------------------------------------------

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
ChooseFont
Posted: Wed Dec 14, 2005 11:06 AM

Sì, ora va. Confermo i problemi che hai riscontrato. Sembra che non ci sia modo di capire se l'utente ha premuto Annulla. Al più potresti capire se ha annullato o confermato lo stesso font. Inoltre la dimensione restituita effettivamente non corrisponde (ma potresti anche ignorare la cosa dato che quello che serve a te è solo il font restituito).

EMG

Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
ChooseFont
Posted: Wed Dec 14, 2005 01:11 PM

> Confermo i problemi che hai riscontrato.
> Sembra che non ci sia modo di capire se l'utente ha premuto Annulla.
> Al più potresti capire se ha annullato o confermato lo stesso font.
> Inoltre la dimensione restituita effettivamente non corrisponde

> (ma potresti anche ignorare la cosa dato che quello che serve a te è
solo il font restituito)

Purtroppo invece mi serve il nome del font, la dimensione e se è bold, italico e quanto ho definito nella variabile aFont, con la quale costruisco il font sulla stampante...

Grazie, cmq.
Posto sull'internazionale!

Ciao,
Ugo

Ciao, best regards,

Ugo
Posts: 58
Joined: Fri Oct 07, 2005 06:30 AM
ChooseFont
Posted: Wed Dec 14, 2005 03:06 PM

Per intercettare il tasto Annulla è necessario modificare la funzione ChooseFont contenuta nel modulo font.c

...

if ( !bOk )
_reta(0);
else {
_reta( 14 );
_storni( ( bOk || bInitLF ) ? lf.lfHeight: 0, -1, LF_HEIGHT );
_storni( ( bOk || bInitLF ) ? lf.lfWidth: 0, -1, LF_WIDTH );
_storni( ( bOk || bInitLF ) ? lf.lfEscapement: 0, -1, LF_ESCAPEMENT );
_storni( ( bOk || bInitLF ) ? lf.lfOrientation: 0, -1, LF_ORIENTATION );
_storni( ( bOk || bInitLF ) ? lf.lfWeight: 0, -1, LF_WEIGHT );
_storl( ( bOk || bInitLF ) ? lf.lfItalic: 0, -1, LF_ITALIC );
_storl( ( bOk || bInitLF ) ? lf.lfUnderline: 0, -1, LF_UNDERLINE );
_storl( ( bOk || bInitLF ) ? lf.lfStrikeOut: 0, -1, LF_STRIKEOUT );
_storni( ( bOk || bInitLF ) ? lf.lfCharSet: 0, -1, LF_CHARSET );
_storni( ( bOk || bInitLF ) ? lf.lfOutPrecision: 0, -1, LF_OUTPRECISION );
_storni( ( bOk || bInitLF ) ? lf.lfClipPrecision: 0, -1, LF_CLIPPRECISION );
_storni( ( bOk || bInitLF ) ? lf.lfQuality: 0, -1, LF_QUALITY );
_storni( ( bOk || bInitLF ) ? lf.lfPitchAndFamily: 0, -1, LF_PITCHANDFAMILY );
_storc( ( bOk || bInitLF ) ? lf.lfFaceName: "", -1, LF_FACENAME );

...

Ciao a tutti.

Pier Luigi

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
ChooseFont
Posted: Wed Dec 14, 2005 03:10 PM

Perché non lo segnali ad Antonio così la corregge?

EMG

Posts: 58
Joined: Fri Oct 07, 2005 06:30 AM
ChooseFont
Posted: Wed Dec 14, 2005 03:24 PM

Ok. Fatto.

Ciao
Pier Luigi

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
ChooseFont
Posted: Thu Dec 22, 2005 04:05 PM
Grazie Pier Luigi e Enrico,

ma la condizione non dovrebbe essere già gestita?

if ( !bOk )
_reta(0);
else {
_reta( 14 );
_storni( ( bOk || bInitLF ) ? lf.lfHeight: 0, -1, LF_HEIGHT );
_storni( ( bOk || bInitLF ) ? lf.lfWidth: 0, -1, LF_WIDTH );

Mi sembra che || siano OR forse in questo caso ci va un'AND?
... e la dimensione?
Ciao, best regards,

Ugo

Continue the discussion