Re: Table Unicode
Publié : lun. 05/juil./2010 10:58
Tu as oublié un "Next" avant avant dernière ligne
Sinon ça chie tjrs en unicode pour ma part.
Sinon ça chie tjrs en unicode pour ma part.
Cela fonctionne toujours pas en unicode : Windows SevenLe Soldat Inconnu a écrit :j'ai trouvé le bug en faisant un essai sous Vista. C'était un problème avec le dessin du chr(10)
en gros mon code dessine un chr(10) (ça fait un petit carré blanc avec bordure noire), du moins sur XP, sous Vista non. Du coup, je ne filtre plus les caractères et je me retrouve avec un final de 32600 caractère à afficher donc 32600 images + 32600 gadget, alors forcement, plus de place en mémoire et crash.
Essaie à nouveau le code
toujours pareilLe Soldat Inconnu a écrit :j'ai encore modifier le code, cela donne quoi ?
Code : Tout sélectionner
; Auteur : Le Soldat Inconnu
; Version de PB : 4
;
; Explication du programme :
; Création de la table ASCII ou UNICODE (en fonction du mode de compilation)
Structure Structure_Table
Chr.s
x.i
y.i
EndStructure
NewList Table.Structure_Table()
; Création de la fenêtre et de la GadgetList
CompilerIf #PB_Compiler_Unicode
Titre.s = "Table Unicode"
Maximum = 32768
CompilerElse
Titre.s = "Table ASCII"
Maximum = 255
CompilerEndIf
If OpenWindow(0, 0, 0, 600, 400, Titre, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0
End
EndIf
; Temps1 = ElapsedMilliseconds()
Define WindowDefaultFontName.s
Define ncm.NONCLIENTMETRICS
ncm\cbSize = SizeOf(NONCLIENTMETRICS)
SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
WindowDefaultFontName = PeekS(@ncm\lfMessageFont\lfFaceName, 32)
LoadFont(0, WindowDefaultFontName, 8, #PB_Font_HighQuality)
LoadFont(1, WindowDefaultFontName, 10, #PB_Font_HighQuality)
ScrollAreaGadget(0, 0, 0, 600, 370, 600, 370, 50, #PB_ScrollArea_BorderLess)
ProgressBarGadget(1, 0, 0, 600, 30, 32, 100)
#Taille = 16
CreateImage(0, #Taille, #Taille, 24)
Dim CaracterePrecedent.l(#Taille - 1, #Taille - 1)
Dim Caractere.l(#Taille - 1, #Taille - 1)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(0))
FrontColor($FFFFFF)
AddElement(Table())
Table()\Chr = " "
For n = 33 To Maximum
Box(0, 0, #Taille, #Taille, 0)
DrawText(0, 0, Chr(n))
For x = 0 To #Taille - 1
For y = 0 To #Taille - 1
Caractere(x, y) = Point(x, y)
Next
Next
If CompareMemory(@Caractere(), @CaracterePrecedent(), #Taille * #Taille * 4)
DeleteElement(Table())
Else
AddElement(Table())
Table()\Chr = Chr(n)
CopyMemory(@Caractere(), @CaracterePrecedent(), #Taille * #Taille * 4)
EndIf
Temps = ElapsedMilliseconds()
If Temps > TempsMemoire + 200
TempsMemoire = Temps
SetGadgetState(1, 50 * n / Maximum)
While WindowEvent() : Wend
EndIf
Next
DrawingFont(FontID(1))
Caractere_Dimension = TextHeight("a")
StopDrawing()
FreeImage(0)
; Temps2 = ElapsedMilliseconds()
; MessageRequester("Temps", Str(Temps2 - Temps1))
Caractere_Dimension + 4
Largeur = Int(570 / Caractere_Dimension)
Hauteur = Round(ListSize(Table()) / Largeur, #PB_Round_Up) * Caractere_Dimension
Largeur * Caractere_Dimension
SetWindowColor(0, $FFFFFF)
If Hauteur <= 32767
If CreateImage(1, Largeur, Hauteur, 24)
If StartDrawing(ImageOutput(1))
Box(0, 0, Largeur, Hauteur, $FFFFFF)
DrawingMode(#PB_2DDrawing_Transparent | #PB_2DDrawing_Outlined)
DrawingFont(FontID(1))
Ligne = 0
Colonne = 0
ForEach Table()
Table()\x = Colonne * Caractere_Dimension
Table()\y = Ligne * Caractere_Dimension
Box(Table()\x, Table()\y, Caractere_Dimension, Caractere_Dimension, $C0C0C0)
DrawText(Table()\x + (Caractere_Dimension - TextWidth(Table()\Chr)) / 2, Table()\y + (Caractere_Dimension - TextHeight(Table()\Chr)) / 2, Table()\Chr, 0)
Colonne + 1
If Caractere_Dimension * Colonne >= Largeur
Colonne = 0
Ligne + 1
EndIf
Temps = ElapsedMilliseconds()
If Temps > TempsMemoire + 200
TempsMemoire = Temps
SetGadgetState(1, 50 + 50 * ListIndex(Table()) / ListSize(Table()))
While WindowEvent() : Wend
EndIf
Next
StopDrawing()
EndIf
FreeGadget(1)
SetGadgetAttribute(0, #PB_ScrollArea_InnerWidth, Largeur)
SetGadgetAttribute(0, #PB_ScrollArea_InnerHeight, Hauteur)
SetGadgetColor(0, #PB_Gadget_BackColor, $FFFFFF)
ImageGadget(3, 0, 0, Largeur, Hauteur, ImageID(1))
Else
SetGadgetState(1, 100)
EndIf
CloseGadgetList()
HideGadget(0, 0)
EndIf
StringGadget(1, 0, 370, 100, 30, "")
SetGadgetFont(1, FontID(1))
StringGadget(2, 100, 370, 400, 30, "")
SetGadgetFont(2, FontID(1))
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 3
If EventType() = #PB_EventType_LeftClick
x = WindowMouseX(0)
y = WindowMouseY(0) + GetGadgetAttribute(0, #PB_ScrollArea_Y)
ForEach Table()
If x >= Table()\x And x < Table()\x + Caractere_Dimension And y >= Table()\y And y < Table()\y + Caractere_Dimension
Break
EndIf
Next
SetGadgetText(1, "Chr(" + Str(Asc(Table()\Chr)) + ")")
SetGadgetText(2, Right(GetGadgetText(2), 30) + Table()\Chr)
EndIf
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
Code : Tout sélectionner
If CreateImage(1, Largeur, Hauteur, 24)
The height is negative