What's wrong with this code? (MaxGUI)

BlitzMax Forums/BlitzMax Beginners Area/What's wrong with this code? (MaxGUI)

Strict

Const MENU_EXIT=1
Const MENU_FONTFOLDER=2
Const MENU_SAMPLETEXT=3
Const MENU_FONTSIZE=4
Const MENU_ABOUT=5

Global Dir,File$,loc_x,loc_y,ext$,counter,file2$,font:TGuiFont

Local a[][]=[[1],[2,3],[4,5,6]]

For Local a1[]=EachIn a
	For Local a2=EachIn a1
		Print a2
	Next
Next

Local window:TGadget=CreateWindow("Fonts ",200,200,500,500,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_STATUS)

Local filemenu:TGadget=CreateMenu("File",0,WindowMenu(window))
	CreateMenu "Quit",MENU_EXIT,filemenu
	
Local programmenu:TGadget=CreateMenu("Program",0,WindowMenu(window))
	CreateMenu "Font Folder",MENU_FONTFOLDER,programmenu
	CreateMenu "Sample Text",MENU_SAMPLETEXT,programmenu
	CreateMenu "Font Size",MENU_FONTSIZE,programmenu
	
Local helpmenu:TGadget=CreateMenu("Help",0,WindowMenu(window))
	CreateMenu "About",MENU_ABOUT,helpmenu

UpdateWindowMenu window

Global listbox:TGadget=CreateListBox(5,0,481,430,window,0)
	SetGadgetLayout listbox,1,1,1,1
	
ScanFolder("C:/WINDOWS/Fonts/")	

Local status:String="Click on a font to view its title and path."
	SetStatusText window,status

While WaitEvent()

	Select EventID()
	
		Case EVENT_WINDOWCLOSE
			
			End
			
		Case EVENT_MENUACTION
			
			Select EventData()
							
				Case MENU_EXIT
					End
					
				Case MENU_ABOUT
					Notify "Fonts 1.0 by Paul Leduc."
					
			End Select

		
		Default
		
			Print CurrentEvent.toString()
		
	End Select

Wend

'FUNCTIONS 

Function ScanFolder(Path$) 
	Dir=ReadDir(Path$) 
	Repeat 
		File$=NextFile(Dir) 
		If File$="" Then Exit 
		If IsFontFile(Path$+File$)=True 
			counter=counter+1 					
			File2$=Replace(File$,".ttf","")			
			Print File2$
			font:TGuiFont=LoadGuiFont(File2$,16,False,False,False)			
			SetGadgetFont(listbox,font)
			AddGadgetItem(listbox,"The quick brown fox jumps over a lazy dog.",GADGETITEM_NORMAL,Null,File2$,Null)
			loc_y=loc_y+15
		EndIf 
	Forever 
End Function

Function IsFontFile(File$)
	file$=Lower$(file$)
	ext$=Right$(file$,3)
	If ext$="ttf" 'Or ext$="fon"
		Return True
	EndIf	
End Function



I'm making a little font program which is supposed to load and display each font in your (Windows) font folder. The fonts load fine I think, as when you click each line, a different font shows. For some reason it is still displaying every font in arial. See anything wrong?

I believe that a ListBox can only have one font for all contents. By putting in a Delay 50, I can see as each font is loaded - all the text in the ListBox changes to that font.

As for defaulting to Arial - when some fonts are loaded, they don't seem to load properly. At those points, I see all text return to Arial.

Ok, so I'm going to have to use something other than a list box then.. Thanks.