How To Create Window with CreateWindowEx ?

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

here you go a working example using just blitzmax, this creates a window and waits for the close button.


Import "-luser32"
Extern 
	Function GetSysColorBrush:Int(nIndex:Int) = "GetSysColorBrush@4"
End Extern

Const COLOR_BTNFACE = 15

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

Local classname$ = "WindowCLASS"
Local CLASSNAME_ADRR:Byte Ptr = Byte Ptr classname$

Local class:WNDCLASS = New WNDCLASS
Local classADDR:Byte Ptr = Byte Ptr class 
class.hInstance = GetModuleHandleA(0)
class.lpfnWndProc = WinProcADDR
class.lpszClassName = CLASSNAME_ADRR
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"
Local windowTitleADDR:Byte Ptr = Byte Ptr windowTitle$

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

Const WM_DESTROY = 2

Local lpParamADDR:Byte Ptr

Local window = CreateWindowExA( 0,CLASSNAME_ADRR,windowTitleADDR,WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | WS_VISIBLE,100,100,200,200,0,0,GetModuleHandleA(0),lpParamADDR )

While Not KeyDown(KEY_ESCAPE) 
	GetMessageA(messageADDR,0,0,0)
	TranslateMessage(messageADDR)
	DispatchMessageA(messageADDR)
Wend 


'
'
'
Function WinProc(hWnd:Int,Msg:Int,wParam:Int,lParam:Int)
	
	Select Msg
		
		Case WM_DESTROY
			Notify "Bye!"
			End
			
	End Select
	
	Return DefWindowProcA(hWnd,Msg,wParam,lParam)
	
End Function 



needs cleaning up.

kev.