ChooseFont

Moderator: Enrico Maria Giordano

ChooseFont

Postby Ugo » Tue Dec 13, 2005 4: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
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: ChooseFont

Postby Enrico Maria Giordano » Tue Dec 13, 2005 7:09 pm

Mi dispiace ma il tuo esempietto non è compilabile.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8305
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Guest » Wed Dec 14, 2005 9: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 )

//------------------------------------------------------------------------------
Guest
 

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8305
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Ugo » Wed Dec 14, 2005 1: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
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Postby Pier Luigi » Wed Dec 14, 2005 3: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
User avatar
Pier Luigi
 
Posts: 58
Joined: Fri Oct 07, 2005 6:30 am
Location: Rome - Italy

Postby Enrico Maria Giordano » Wed Dec 14, 2005 3:10 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8305
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Pier Luigi » Wed Dec 14, 2005 3:24 pm

Ok. Fatto.

Ciao
Pier Luigi
User avatar
Pier Luigi
 
Posts: 58
Joined: Fri Oct 07, 2005 6:30 am
Location: Rome - Italy

Postby Enrico Maria Giordano » Wed Dec 14, 2005 3:48 pm

Grazie!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8305
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Ugo » Thu Dec 22, 2005 4: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
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy


Return to All products support

Who is online

Users browsing this forum: No registered users and 1 guest