Win32Max Module, mini test

Community Forums/Showcase/Win32Max Module, mini test

skn3(Posted 2005) [#1]
Ok been tinkering away at a win32 module and thought people might want to see. Im sure other peoples win32 modules are further alogn than this, but I have been working hard to develop a really powerfull, and easy module. Plus the fact there are alot of hurdles when first getting used to bmax.

Anyway: http://skn3.acsv.net/junk/win32max.rar
The rar contains the module (no source included) plus an example file. It should be everythign to give it a try out.

The example program in the rar archive.
Import skn3.win32Max

'create gadget class
Global class:TGadgetClass = CreateGadgetClass("myclass",Null,0,0,COLOR_3DFACE+1)

'create gadgets
Global window:TGadget = CreateGadget("My window",500,5,600,400,class,0,WS_VISIBLE | WS_TILEDWINDOW | WS_SIZEBOX)
Global group:TGadget = CreateGadget("My group",5,5,500,300,"Button",window,WS_CHILD | WS_VISIBLE | BS_GROUPBOX | WS_CLIPCHILDREN)
Global button:TGadget = CreateGadget("My button",5,25,200,40,"Button",group,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_CLIPCHILDREN)

'create some events
button.AddEvent(WM_LBUTTONUP)
button.AddEventCallBack(MyButtonCallback,WM_LBUTTONUP)

'main event loop
Repeat
	Select WaitMessage()
		Case WM_LBUTTONUP
			Notify "Clicked button at x:"+eventx+" y:"+eventy
	End Select
	FlushMem()
Forever

'(advanced) event callbac
Function MyButtonCallback()
	'This will be built into the basic button object, but is just show to display the flexability of the system.
	Select eventid
		Case WM_LBUTTONUP
			'check mouse hit was in button
			If ApiPtInRect(eventgadget.Rect(),eventx,eventy)
				'we want to modify the eventx and eventy so they are local to the gadget rather than screen coords.
				eventx = lparamX(eventlparam)
				eventy = lparamY(eventlparam)
				'allow event to return mouse click detected
				Return False
			Else
				'stop event from returning
				Return True
			End If
	End Select
End Function


This demonstrates the flexability of the module. The way inwhich gadget events happen can be designed within your bmax source code. (see MyButtonCallback() for example)

Anyway, tell me what you think. Bare in mind, there will be pre-designed gadget classes so you want have to deal with what is shown in the example.


skn3(Posted 2005) [#2]
You might have to rename pub.mod/win32.mod to pub.mod/win32.mod.backup

Bmax needs an intelligent compile =/


fredborg(Posted 2005) [#3]
It works here :) What a nice button!

A small question: Why does Return True stop the event and Return False let it pass through instead of the opposite?


skn3(Posted 2005) [#4]
Because if you want the function to halt you return true. So return false(which is the default return value anyway) will always let it continue. I could do it so you do something like return Bm_HaltEvent or something, but return true is just the same.


EOF(Posted 2005) [#5]
the cusor seems to retain its current state (hour glass/resize) until you move over the button.
Is that because only the button is being checked for events?

Do you have a WM_CLOSE message in there which is returned when the window is closed down by [X] , alt+f4 , appmenu>close etc?