Canvas + B3DSDK + EVENT_MOUSEMOVE

Blitz3D SDK Forums/Blitz3D SDK Programming/Canvas + B3DSDK + EVENT_MOUSEMOVE

Hi

Anybody can help me ? :) I want to retrieve the event mousedown or mousemove with Canvas+ B3DSdk ? Uncomment the lines to see the problem in action. When B3D is not assigned to the canvas the events are ok.


Import blitz3d.blitz3dsdk
Import BRL.MaxGUI

MYwindow:TGadget=CreateWindow("Hell!",0,0,640,480,0,1)

W = ClientWidth(Desktop())
H = ClientHeight(Desktop() ) 

MYcanvas:TGadget = CreateCanvas(10, 10 ,520 , 400 , MYwindow)

' ------------------------
' Uncomment to see the bug
' ------------------------
'bbSetBlitz3DHWND(QueryGadget(MYcanvas,QUERY_HWND)) 
'bbBeginBlitz3D() 
'bbGraphics3D W , H , 0 , 2
'EnablePolledinput()


Global mx:Int , my:Int

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			DebugLog "CLOSING WINDOW"
			End
		Case EVENT_MOUSEMove
			 Select EventSource() 
			
			 	Case MYCANVAS
					DebugLog EventX() + " " + EventY()
					mx	= EventX()
					my	= EventY()
					drag = 1
					
					
					Print "HIT ME : "+MilliSecs()
			End Select
			
		 Case event_mouseup
			drag=0
		Case EVENT_GADGETPAINT
	  	    SetGraphics CanvasGraphics (MyCanvas)
    		DrawRect  20,20,50,80
        	Flip
		Case event_mousemove
			If drag
			 DebugLog "canvs : " + GadgetX(mycanvas) + " " + GadgetY(mycanvas)
			DebugLog "window : " + GadgetX(mywindow) + " " + GadgetY(mywindow)
			DebugLog MouseX() + " " + MouseY()
				x = EventX() + GadgetX(mycanvas) - mx
				y = EventY() + GadgetY(mycanvas) - my
				SetGadgetShape (mycanvas, x,y,GadgetWidth(mycanvas),GadgetHeight(mycanvas))
	        EndIf
	End Select
	
Forever
End



I wish we could tell the B3DSDK to ignore Windows events, and let us use MaxGUI/whatever to detect the events.

Use C++ and everything will go fine...

Not everybody can program in C++. I never could figure out how to get everything up and running. Maybe I'm just stupid. ;p

I don't have maxgui, but can't you use the bbSetBlitz3DEventCallback ?
http://www.blitzbasic.com/Community/posts.php?topic=72402

Maybe I'm just stupid

Definitely not!
I mentioned this just to emphasize that the SDK is more suitable to C++ and not to BMax. Hardness of C++ is a myth. You need only to clear some principles in your mind. Then all the power is at your hands!

Have Fun

Avant bbBeginBlitz3D()
Before bbBeginBlitz3D()
bbSetBlitz3DEventCallback(Int Byte Ptr BBEventHandler)


et la fonction pour ecraser la gestion des Events
And the function to overwrite Event Management
Global MouseDown1:byte
Global MouseHit1:Int
function MouseHit1:int()
	local Ms1:int=MouseHit1
	MouseHit1=0
	return Ms1
end function

Function BBEventHandler:Byte(hwnd , msg , wp , lp) "win32"
	Select msg
		' +> MouseX/MouseY
		Case WM_MOUSEMOVE' = 512
		Debuglog "MosX="+(lp & $FFFF)+" MosY="+(lp shr(16) & $FFFF)

		' Mouse 1 Down
		Case WM_LBUTTONDOWN
			if MouseDown1=false MouseHit1:+1
			MouseDown1=true
		Case WM_LBUTTONUP
			MouseDown1=false
		rem
			Fais la même chose avec :
			WM_MBUTTONUP/DOWN +> Bouton Molette
			WM_RBUTTONUP/DOWN +> Mouse 2
		endrem
		Default
			' Ici, tu peux lire tous les evenements de ta fenêtre windows ... utiles ou non
			' le flag est enregistré dans la variable "msg"
			' Les infos dans wp/lp
	End select
	Return -1
End function