Hello,
Is it possible to write into a windows gadget (EditorGadget or ListViewGadget) the ASCII characters > 127 and especially the 'semi-graphical' characters of a .NFO file for example ?
Do you need to convert the file or is it just swtiching between two display modes ?
I really don't have a clue !
Thanks
AsCII characters
I obtain the right semi-graphical characters when I use the Console Mode windows. Here is a small code to see what I want (you must have a .NFO file !)
Hope it help !
Code: Select all
; PureBasic Visual Designer v3.63c Beta
;- Window Constants
;
#Fenetre_Principale = 0
;- Gadget Constants
;
#Liste_Titres = 0
#Affichage_repertoire = 1
#Bouton_repertoire = 2
#Bouton_Quitter = 3
#Liste_NFO = 4
Global FontID1
FontID1 = LoadFont(1, "FixedSys", 8)
Procedure Open_Fenetre_Principale()
hdc = OpenWindow(#Fenetre_Principale, 306, 31, 611, 555, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "NFO Reader")
If hdc
If CreateGadgetList(WindowID())
ListIconGadget(#Liste_Titres, 40, 85, 530, 70, "Titres", 530, #PB_ListIcon_CheckBoxes | #PB_ListIcon_MultiSelect | #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
StringGadget(#Affichage_repertoire, 40, 35, 275, 20, "")
ButtonGadget(#Bouton_repertoire, 335, 35, 225, 20, "Répertoire contenant le NFO")
ButtonGadget(#Bouton_Quitter, 440, 525, 130, 20, "Quitter")
EditorGadget(#Liste_NFO, 40, 165, 530, 350)
SetGadgetFont(#Liste_NFO, FontID1)
EndIf
EndIf
EndProcedure
Open_Fenetre_Principale()
Repeat
Event = WaitWindowEvent()
If Event= #PB_EventGadget
Select EventGadgetID()
Case #Bouton_repertoire
ClearGadgetItemList(#Liste_NFO)
fichier_NFO$ = OpenFileRequester("Fichier NFO", "", "Fichiers NFO |*.NFO", 0)
SetGadgetText(#Affichage_repertoire, fichier_NFO$)
AddGadgetItem(#Liste_Titres, -1, GetFilePart(fichier_NFO$))
OpenConsole()
ConsoleColor(0, 15)
If OpenFile(1, fichier_NFO$)
While Eof(1)=0
Texte$ = ReadString()
AddGadgetItem(#Liste_NFO,-1,Texte$)
PrintN(Texte$)
Wend
EndIf
CloseFile(1)
Input()
CloseConsole()
Case #Bouton_Quitter
Event = #PB_EventCloseWindow
EndSelect
EndIf
A solution !
Finally, I've found a solution : first, using a ListViewGadget instead of EditorGadget and then Calling GetStockObject() with #OEM_FIXED_FONT or #ANSI_FIXED_FONT parameters.
Here is the explanation from the site
http://www.geocities.com/thestarman3/hack/NPfont.htm
The GetStockObject function retrieves a handle to one of the predefined
stock pens, brushes, fonts, or palettes.
HGDIOBJ GetStockObject(
int fnObject // type of stock object
);
Parameters
fnObject -- Specifies the type of stock object. This parameter can be
any one of the following values [only the fonts shown above
will be listed here]:
SYSTEM_FIXED_FONT [ 16 = 10h ] Fixed-pitch (monospace) system font already used in Windows versions earlier than 3.0 [This is the font used by NOTEPAD.]
OEM_FIXED_FONT [ 10 = 0Ah ] Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font. [This gives us an acceptable approximation in Windows programs to the old DOS font characters on most systems.]
ANSI_FIXED_FONT [ 11 = 0Bh ] Windows fixed-pitch (monospace) system font. [Might be a nice alternative to the original font.]
Here is a small code sample :
Sorry to write such a long post !
Here is the explanation from the site
http://www.geocities.com/thestarman3/hack/NPfont.htm
The GetStockObject function retrieves a handle to one of the predefined
stock pens, brushes, fonts, or palettes.
HGDIOBJ GetStockObject(
int fnObject // type of stock object
);
Parameters
fnObject -- Specifies the type of stock object. This parameter can be
any one of the following values [only the fonts shown above
will be listed here]:
SYSTEM_FIXED_FONT [ 16 = 10h ] Fixed-pitch (monospace) system font already used in Windows versions earlier than 3.0 [This is the font used by NOTEPAD.]
OEM_FIXED_FONT [ 10 = 0Ah ] Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font. [This gives us an acceptable approximation in Windows programs to the old DOS font characters on most systems.]
ANSI_FIXED_FONT [ 11 = 0Bh ] Windows fixed-pitch (monospace) system font. [Might be a nice alternative to the original font.]
Here is a small code sample :
Code: Select all
; PureBasic Visual Designer v3.63c Beta
;- Window Constants
;
#Fenetre_Principale = 0
#OEM_FIXED_FONT = 10
#ANSI_FIXED_FONT = 11
;- Gadget Constants
;
#Liste_Titres = 0
#Affichage_repertoire = 1
#Bouton_repertoire = 2
#Bouton_Quitter = 3
#Liste_NFO = 4
#Option_ANSI = 5
#Option_ASCII = 6
Global FontID1
FontID1 = GetStockObject_(#ANSI_FIXED_FONT)
Procedure Open_Fenetre_Principale()
hdc = OpenWindow(#Fenetre_Principale, 306, 31, 611, 555, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "NFO Reader")
If hdc
If CreateGadgetList(WindowID())
OptionGadget(#Option_ANSI, 40, 90, 100, 25, "Version ANSI")
OptionGadget(#Option_ASCII, 200, 90, 100, 25, "Version ASCII")
SetGadgetState(#Option_ANSI,1)
StringGadget(#Affichage_repertoire, 40, 35, 275, 20, "")
ButtonGadget(#Bouton_repertoire, 335, 35, 225, 20, "Répertoire contenant le NFO")
ButtonGadget(#Bouton_Quitter, 440, 525, 130, 20, "Quitter")
ListViewGadget(#Liste_NFO, 40, 165, 530, 350)
SetGadgetFont(#Liste_NFO, FontID1)
EndIf
EndIf
EndProcedure
Open_Fenetre_Principale()
DisableGadget(#Option_ANSI,1)
DisableGadget(#Option_ASCII,1)
Repeat
Event = WaitWindowEvent()
If Event= #PB_EventGadget
Select EventGadgetID()
Case #Bouton_repertoire
ClearGadgetItemList(#Liste_NFO)
fichier_NFO$ = OpenFileRequester("Fichier NFO", "", "Fichiers NFO |*.NFO", 0)
If fichier_NFO$ <>""
SetGadgetText(#Affichage_repertoire, fichier_NFO$)
DisableGadget(#Option_ANSI,0)
DisableGadget(#Option_ASCII,0)
If OpenFile(1, fichier_NFO$)
While Eof(1)=0
Texte$ = ReadString()
AddGadgetItem(#Liste_NFO,-1,Texte$)
Wend
EndIf
CloseFile(1)
EndIf
Case #Option_ANSI
FontID1 = GetStockObject_(#ANSI_FIXED_FONT)
SetGadgetFont(#Liste_NFO, FontID1)
Case #Option_ASCII
FontID1 = GetStockObject_(#OEM_FIXED_FONT)
SetGadgetFont(#Liste_NFO, FontID1)
Case #Bouton_Quitter
Event = #PB_EventCloseWindow
EndSelect
EndIf
Until Event = #PB_EventCloseWindow
End