WndProc?

Just starting out? Need help? Post your questions and find answers here.
marksibly
New User
New User
Posts: 4
Joined: Wed Jan 21, 2009 10:40 pm

WndProc?

Post by marksibly »

Hi,

I'm trying to create a custom Wndproc for a window - the code looks like this:

Code: Select all

Procedure WinCallback( hwnd,msg,wp,lp )
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

OpenWindow( 0,32,32,640,480,"Blitz3D Window",#PB_Window_SystemMenu )

SetWindowCallback( @WinCallback,0 )

Repeat
  Select WindowEvent()
  Case #PB_Event_CloseWindow
    End
   EndSelect
ForEver
However, this just 'hourglasses' and eventually does a 'window not responding'...

If I remove SetWindowCallback, it works as expected, so am I missing something in WinCallback?

Bye!
Mark
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Code: Select all

SetWindowCallback(@WinCallback()) 
I may look like a mule, but I'm not a complete ass.
marksibly
New User
New User
Posts: 4
Joined: Wed Jan 21, 2009 10:40 pm

Post by marksibly »

Thanks!

(ps: this forum doesn't work too well in Chrome...)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

marksibly wrote:Thanks!

(ps: this forum doesn't work too well in Chrome...)
Then don't use Chrome! :wink:
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Mark Sibly...? I find it hard to believe that a coder of Mark's advanced skills would ask a question of this nature, so may I assume you aren't him? If not, why use his name for a nick :?:
BERESHEIT
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Mark Sibly? Wtf? This is some kind of bad joke?

For those of you who don't know ...

Mark Sibly is the lead developer of Blitz Basic! :!:

Just a coincidence? Hard to believe ...
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
marksibly
New User
New User
Posts: 4
Joined: Wed Jan 21, 2009 10:40 pm

Post by marksibly »

Hi,

Yep it's me - fearlessly asking stupid questions if it'll save me a bit of time! And, the missing '()' from the function wasn't exactly *obvious* (IMHO).

Anyway, I'm just working on Blitz3DSDK's 'render direct to hwnd' code and have it going quite nicely now:

Code: Select all

IncludeFile "../include/blitz3dsdk.pbi"

Global suspended=0

Procedure WinCallback( hwnd,msg,wparam,lparam )

	Select msg
	Case #WM_PAINT	;A reasonably sane place to validate graphics...
		Select bbValidateGraphics()
		Case 0
			;graphics are unavailable
			;(eg: another app has gone fullscreen)
			suspended=1
		Case -1
			;graphics are *borked*
			;(eg: desktop resolution has changed in windowed mode)
			Print( "FATAL GRAPHICS PROBLEM" )
			End
		Default
			;>0, graphics are OK.
			;(returned value is number of times graphics have been 'restored').
			If suspended
				;this refreshes graphics if app is suspended
				;(just keeps window 'clean' when bits are revealed - not really necessary in fullscreen)
				bbFlip( 0 )
			EndIf
		EndSelect
	Case #WM_ERASEBKGND
;		ProcedureReturn 1
	Case #WM_ACTIVATEAPP
	  If wparam
	    suspended=0
    Else
	    suspended=1
	  EndIf
	Case #WM_CLOSE
	  End
	EndSelect
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

OpenWindow( 0,32,32,640,480,"Blitz3D Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered )

SetWindowCallback( @WinCallback(),0 )

bbBeginBlitz3DEx( WindowID( 0 ),0 )

;bbGraphics3D( 640,480,32,1 )
bbGraphics3D( 640,480,0,2 )

;Create a brush
tex=bbCreateTexture( 64,64 )
bbScaleTexture( tex,0.125,0.125 )
bbSetBuffer( bbTextureBuffer( tex ) )
bbColor( 64,192,255 )
bbRect( 32,0,32,32 )
bbRect( 0,32,32,32 )
bbColor( 255,255,255 )
bbRect( 0,0,32,32 )
bbRect( 32,32,32,32 )
bbSetBuffer( bbBackBuffer() )
bbColor( 255,255,255 )
brush=bbCreateBrush()
bbBrushTexture( brush,tex,0,0 )

;Create a camera
camera=bbCreateCamera()
bbCameraClsColor( camera,128,0,255 )
bbPositionEntity( camera,0,0,-6 )

;Create a light
light=bbCreateLight()
bbTurnEntity( light,45,45,0 )

;Create a cube
cube=bbCreateCube()
bbPaintEntity( cube,brush )

Repeat
  Repeat
    While suspended
      WaitWindowEvent()
    Wend
    While WindowEvent()
    Wend
  Until Not suspended

	;App is up and running!

  bbTurnEntity( cube,0,3,0 )
  bbUpdateWorld()
  bbRenderWorld()
  bbFlip( 1 )
   
ForEver
Only one question:

With WM_ERASEBKGND, you're meant to return '1' if window was erased. However, I'm not returning values to Win32 but to PB (correct?), so how can I do this?

It doesn't really matter, it all runs sweetly without WM_ERAASEBKGND handling, I'm just curious really...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Firstly, WELCOME!!! Great to have someone of your stature aboard, truly!
I'm not returning values to Win32 but to PB (correct?)
Because you're returning the value from a callback, it is being returned to Win32, never fear.
BERESHEIT
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

<offtopic>
marksibly wrote:Yep it's me - fearlessly asking stupid questions if it'll save me a bit of time!
:lol: ... you made my day!

btw... Welcome.
</offtopic>
oh... and have a nice day.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Also offtopic, if you were to release your B3DSDK as a PureBasic user library, it would sell pretty well here imho. I know I'd buy it.
BERESHEIT
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Welcome, Mark. I'm glad to see people getting excited over games in PureBasic. We need more stimulus in this area. :)

Do you have an ETA on when this might be available?
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Hi Mark! I have always believed in the stupid / silly question! I ask them frequently!

There was a bit of work on this previously as well... some of the ideas therein might help / inspire you:

http://www.purebasic.fr/english/viewtop ... =word+wrap

I can't locate the two others... but I am bad at searching!

:D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Hmm, so many people quick to believe it's Mark with no proof but his word?
Would you also believe it was Bill Gates if he came here and said it was him?
See the analogy? I severely doubt it's Mark. As if someone from a competing
language would come here and start asking the most simple of questions.
Think about it, guys! :roll:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Mark.s
User
User
Posts: 16
Joined: Wed Dec 17, 2008 1:43 pm
Location: Finland

Post by Mark.s »

@PB

I don't believe too, are that person real "Mark Sibly". Well its not a matter, if that person not are real "Mark Sibly".
But hoax is always bad.

Well nobody can be sure who is it in real life. But anyways, if marksibly is real "Mark Sibly", i say welcome, otherwise i say nothing. Well people need proofs and whitout proofs some words are nothing in internet.

In my opinion its weird, if a BlitzBasic creator ask simple questions. Not sure if that are simple.
pdwyer wrote:Storm in a teacup

:lol: No i am not are "Mark Sibly". Well that ".s" just coming from "string" to last part of my nickname.
Last edited by Mark.s on Thu Jan 22, 2009 1:50 pm, edited 8 times in total.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Maybe that's because YOU are the real Mark Sibly and know it's an imposter!! :shock: A doppleganger! <Gasp> Thinly disguised behind a "Mark.s" name. Where's Scooby Doo to expose the truth?


:lol: Storm in a teacup :lol:
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Post Reply