How To Create Window with CreateWindowEx ?

Miscellaneous Forums/Win32 Discussion/How To Create Window with CreateWindowEx ?

I'm trying to add a font, but my CreateFont call makes Blitz quit:

Strict
Import "-luser32"
'Import "-lkernel32"
Extern 
	Function GetSysColorBrush:Int(nIndex:Int) = "GetSysColorBrush@4"
	Function SendMessage:Int(hWnd:Int,MSG:Int,wParam:Int,lParam:Int) = "SendMessageA@16"
	Function CreateFontA:Int(nHeight,nWidth,nEscapement,nOrientation ,fnWeight, fdwItalic,dwUnderline , fdwStrikeOut,fdwCharSet, fdwOutputPrecision , fdwClipPrecision,fdwQuality, fdwPitchAndFamily, lpszFace:String) = "CreateFontA@56"
	Function GetLastError() = "GetLastError@0"
	
	'Function CreateFontIndirectA:Int(lpLogFont:LOGFONT) '= "CreateFontIndirectA"
	
End Extern


'Type LOGFONT 
'  Field lfHeight:Int
'  Field lfWidth:Int 
'  Field lfEscapement:Int
'  Field lfOrientation:Int
'  Field lfWeight:Int
'  Field lfItalic:Byte
'  Field lfUnderline:Byte
'  Field lfStrikeOut:Byte
'  Field lfCharSet:Byte
'  Field lfOutPrecision:Byte
'  Field lfClipPrecision:Byte
'  Field lfQuality:Byte
'  Field lfPitchAndFamily:Byte
'  'TCHAR lfFaceName[LF_FACESIZE]; 
'End Type




Const COLOR_BTNFACE = 15

Local WinProcADDR:Byte Ptr = WinProc
If WinProcADDR > Null Then
	Print "winproc addr obtained "
EndIf

Local classname$ = "WindowCLASS"

Local class:WNDCLASS = New WNDCLASS
Local classADDR:Byte Ptr = Byte Ptr class 
class.hInstance = GetModuleHandleA(0)

class.lpfnWndProc = WinProcADDR

class.lpszClassName = Byte Ptr classname$


class.hbrBackground = GetSysColorBrush(COLOR_BTNFACE) 

If(RegisterClassA(classADDR) <> Null) Then
	Print "class reg ok"
EndIf

Local message:MSG = New MSG
'Local messageADDR:Byte Ptr = Byte Ptr message

Local windowTitle$ = "Testing"

Const WS_CAPTION = $C00000
Const WS_SYSMENU = $80000
Const WS_VISIBLE = $10000000
Const WS_MINIMIZEBOX = $20000
Const WS_MAXIMIZEBOX = $10000

Const WS_CHILD           = $40000000



Const WM_DESTROY = 2

Const WM_KEYDOWN = $100

Const WM_COMMAND = $111



Local lpParamADDR:Byte Ptr



Local window = CreateWindowExA( 0,Byte Ptr classname$,Byte Ptr windowTitle$,WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | WS_VISIBLE,100,100,400,350,0,0,GetModuleHandleA(0),lpParamADDR )



Global  btnOk = CreateWindowExA( 0 ,Byte Ptr "BUTTON",Byte Ptr "Ok",WS_CHILD | WS_VISIBLE,250,250,100,20,window ,0,GetModuleHandleA(0),Byte Ptr 0 )
Global  btnCancel = CreateWindowExA( 0 ,Byte Ptr "BUTTON",Byte Ptr "Cancel",WS_CHILD | WS_VISIBLE,250,250+24,100,20,window ,0,GetModuleHandleA(0),Byte Ptr 0)


Global  lblHeadline = CreateWindowExA( 0 ,Byte Ptr "STATIC",Byte Ptr "I am the label, I am",WS_CHILD | WS_VISIBLE,10,10,100,20,window ,0,GetModuleHandleA(0),Byte Ptr 0 )


Local Fontname:String = "Arial" + Chr(0) + Chr(0)


Local myfont =  CreateFontA(-16,0,0,0 ,400, 0,0 , 0,0, 4 , 0,0, 0, Fontname) 


DebugLog "GetLastError() " + GetLastError()
DebugLog "myfont " + myfont 


If Not myfont

	'WaitKey
	'End


EndIf





Local bRet 

Repeat 

	bRet = GetMessageA( message, 0, 0, 0 )
	
	DebugLog "bRet " + bRet 
    
    If bRet = -1
    	'handle the error And possibly Exit
		DebugLog "handle the error And possibly Exit"
	Else
		TranslateMessage(message)
		DispatchMessageA(message)
	EndIf
Until bret =0 






DebugLog "here"

'
'
'
Function WinProc(hWnd:Int,Msg:Int,wParam:Int,lParam:Int)
	
	Select Msg
		
		Case WM_DESTROY
			Notify "Bye!"
			End
		Case WM_KEYDOWN
		
			DebugLog "Keydown " + wParam + " " + lParam
			
			Select wParam
				Case 27 ' ESC
				
		'			SendMessage hWnd,WM_DESTROY,0,0
			End Select
			
		
		Case WM_COMMAND
		
			Select lParam
				Case  btnOk
					Notify "You clicked Ok"
				Case btnCancel
					Notify "You clicked Cancel"
			
			End Select
			
		Default
			'DebugLog Msg
		
			
	End Select
	
	Return DefWindowProcA(hWnd,Msg,wParam,lParam)
	
End Function