BMax games = lame windowed mode support

BlitzMax Forums/BlitzMax Programming/BMax games = lame windowed mode support

Grey Alien(Posted 2006) [#1]
OK, I have just gone through tons of BMax mainstream games like Inca Quest, Toms Hen House, Platypus, Jewel Match, Temple of Tangram, C'Bubble and found that they either a) do not have a windowed mode support or b) windowed mode does not have minimise button and does not have an icon on the title bar.

I made sure that my framework had a proper minimise button and shows the icon on the title bar, although recently I've discovered that the title bar icon only shows if the windows them is Windows Classic - it doesn't show with the Windows XP theme! I've yet to figure out why and it's p*ssing me off, I don't know if it's a BMax problem, a problem with my icon file or a problem with the API calls I'm using or something else. This would be great to sort once and for all so that we can all have decent icon support for casual games in windowed mode.

Anyone seen any BMax games that DO correctly show the icon in windowed mode?

The annoying thing is that I'm using the *exact* same code as for Easter Bonus which was a Blitz Plus game and it DOES show the title bar icon when the Windows XP theme is active. grr

OK here's some example code:

Strict
Extern "win32"
	Function ExtractIconA%(hWnd%,File$z,Index%)
	Function GetActiveWindow%()
	Function SetClassLongA%(hWnd%,nIndex%,Value%)
End Extern

Global dumbfix=0

Graphics 640,480,0

Local WindowHandle = GetActiveWindow()

Local icon=ExtractIconA(WindowHandle ,"test.ico",0)
SetClassLongA(WindowHandle ,-14,icon)

If dumbfix Then
	EndGraphics
	Graphics 640,480,0
EndIf

While Not KeyHit(key_escape)
Wend

Make sure you have test.ico in the same folder as the .exe
Note how the icon is NOT set if you are using windows XP them but it is if you use classic theme.
Then set dumbfix=1 and try with Windows XP theme and it works! explain that...in fact how the hell can dumbfix even work because the original window + icon is destroyed with EndGraphics, then another one is made!


TartanTangerine (was Indiepath)(Posted 2006) [#2]
Apparently windowed mode is not really supported - yeah get that.

You can overcome these problems by playing with the window creation code in the modules or use plain using the windows API to overcome these shortfalls. I think that there is some code floating around here that deals with the issue.


Grey Alien(Posted 2006) [#3]
Indiepath: yeah I heard about not officially supported, well that's a shame as it's needed for casual games big time. Like I said I already have API code to handle minimise, close, and the icon - it's just the icon doesn't work in XP theme. I've just posted some code at the top of the thread. Yeah perhaps the answer is to tweak the window creation code in the modules but that's not very good is it as you'd have to do it after every BRL change to the module.


skidracer(Posted 2006) [#4]
Reading MSDN, modifying the window class icon field is not even supported. Reading a little more MSDN, there is a message called WM_SETICON.

Also, if you want to call things lame, please do so elsewhere, the personification of our products or code for the purposes of insult may cause your welcome on this site to be diminished.


H&K(Posted 2006) [#5]
errrr Dont ban me for this,
but lame means "unsatisfactory"
So lame windowed mode support = unsatisfactory windowed mode support. So its realy a proper description rather than anything else.

However, I agree, putting it in a thread Title cannot help the community at all.


Grey Alien(Posted 2006) [#6]
Yeah I've just found out about WM_SETICON. Modifying the class icon was all over the code archives but seems it may not be the best solution.

Sorry to use the word lame, perhaps you could change the thread title to "BMax Games and Windowed Mode Support"? You know I've been a solid member of this community for 2 years and fully support BMax so my intention is not negative, it's just to get this issue resolved.


Grey Alien(Posted 2006) [#7]
OK I have now the definitive way to set the icon for BMax in windowed mode (and the task swapper dialog):

' -----------------------------------------------------------------------------
' ccSetIcon
' -----------------------------------------------------------------------------
Function ccSetIcon(iconname$, TheWindow%)	
	?Win32
	Local icon=ExtractIconA(TheWindow,iconname,0)
	Local WM_SETICON = $80
	Local ICON_SMALL = 0
	Local ICON_BIG = 1
'	sendmessage(TheWindow, WM_SETICON, ICON_SMALL, icon) 'don't need this
	sendmessage(TheWindow, WM_SETICON, ICON_BIG, icon)
'	SetClassLongA(TheWindow,-14,icon)'obsolete as it doesn't work with Windows XP Theme!
	?
End Function

'call it like this
ccSetIcon("test.ico", GetActiveWindow())


and the externs:

?win32
Extern "win32"
	Function ExtractIconA%(hWnd%,File$z,Index%)
	Function GetActiveWindow%()
	Function SendMessage:Int(hWnd:Int,MSG:Int,wParam:Int,lParam:Int) = "SendMessageA@16"
End Extern
?


tada! Only took like um 4 hours gah...:-(

This fix will be in my framework V1.02.


Boulderdash(Posted 2006) [#8]
OK ,I saw this and had to put in my two cents worth....

I HAVE WANTED PROPER WINDOWS SUPPORT SINCE DAY 1 BUT BOTH B3D AND BMAX DONT SUPPORT WINDOWS!!!!!!!!!!!

.. you cant do basic stuff like change the APP TITLE in BMAX or put an icon, is there something wrong with a command like APPICON="c:\blah.icon" would that be impossible?????????

I tried putting in somecode to solve the problem, kinda doesnt work becuase my APP can resize the window, so you lose the minimise buttons etc when you change the window!

Surely the BMAX module could be made complete instead of alls sorts of stuff missing when it comes to setting up a window?

THAT WOULD BE MY MOST POPULAR REQUEST FOR FULL WINDOW SUPPORT!


Gabriel(Posted 2006) [#9]
.. you cant do basic stuff like change the APP TITLE in BMAX

Have you tried typing AppTitle into the IDE and pressing F1 twice at all? ;)


Defoc8(Posted 2006) [#10]
I HAVE WANTED PROPER WINDOWS SUPPORT SINCE DAY 1 BUT BOTH B3D AND BMAX DONT SUPPORT WINDOWS!!!!!!!!!!!

lol, funny that, cuz they work fine here ;)

..if id created bmax, id be very happy - its without doubt the
best "Basic" programming language ive seen. Theres some stuff
id like to see that will probably never make it into the language..like inlined methods and/or macros..perhaps
even inline assembly support, but none of this really that
important..

then again, i only really tinker about with bmax, havent
tried to create anything massively complicated - it does
what it says on the can :p ;) - mostly :]

ill probably take get some seriouse coding in - when the
3d module is ready..til then ill jst pop in here + make
pointles posts :]


xlsior(Posted 2006) [#11]
.. you cant do basic stuff like change the APP TITLE in BMAX or put an icon


You can't do an icon, but you can change the title of your application: simply use something like this:

AppTitle$="My own application"

..before you initialize your 'graphics' window, and it will show the specified title.

By the way: Thanks for sharing, Grey!


Grey Alien(Posted 2006) [#12]
xlsior: you are welcome. Now we have a definitive way of setting the icon. Just added it to the code archives.

Gav: my framework does allow you to swap between full-screen and windowed mode. Windowed mode has a working close button, system menu, working minimise, icon on the title bar and in the task-swapper window, app title etc. When the game is minimised the music pauses and so does the game and CPU time is given back to windows, the same happens if the window is unfocused. I've painstakingly researched the code on this forum and MSDN, + pestered people for help, to get it all working swimmingly. Try out my demo (click the framework link in my sig).

defoc8: yeah BMax is a great language, I love it. It's just that for professional Indie games you need a bit more functionality than it offers, that's why I had to make a framework for my games.


Warren(Posted 2006) [#13]
AppTitle$="My own application"

..before you initialize your 'graphics' window, and it will show the specified title.

Yeah, that tripped me up for ages. If you set it AFTER you issue the Graphics command it won't do anything. That was frustrating and I was running on the assumption that the command was broken - until I moved to BEFORE the Graphics command.


Grey Alien(Posted 2006) [#14]
in fact best to set it before you do any code because if you want to use notify to show an error (for loading for example), you want the notify dialog to have your apptitle instead of "BlitzMax Application"


Gabriel(Posted 2006) [#15]
Yeah, that tripped me up for ages. If you set it AFTER you issue the Graphics command it won't do anything. That was frustrating and I was running on the assumption that the command was broken - until I moved to BEFORE the Graphics command.


Good point, the docs are misleading here. They say :

Initially, AppTitle is set the value "BlitzMax Application". However, you may change AppTitle at any time with a simple assignment.


What they don't say is that changing it any time won't necessarily make the least bit of difference if you already have a graphics window open. Yeah, that should be added to the documentation to avoid people thinking it's broken. It's logical once you know, but it's not immediately apparent.


Grey Alien(Posted 2006) [#16]
It's just another of those little things you pick up - yeah shame it isn't in the manual. To be honest, I probably know a lot more BMax tips n tricks than beginners, yet I still only know a fraction of the total due to the area I'm coding in i.e. Casual games. That's why these forums are so valuable. For a long while at the start I read most threads just to gain knowledge that might one day be useful, or just to have a vague awareness of an issue so I could look it up if I needed to later on.


ImaginaryHuman(Posted 2006) [#17]
Glad you got it figured out, although MaxGUI is a very nice solution for creating proper windowed mode support. What you're relying on as `windowed mode` is really a barely window-mode originally implemented for test purposes only and not really meant to be a full-featured windowed mode. If people want to do extra things like adding functionality to the window etc then they should use MaxGUI. I know that means that people would then have to own MaxGUI for such things to work, but I think you should consider the growing crowd of people who have or will buy, or will buy because your framework supports it, the maxgui module to get the extra features. You can always keep it optional.


Grey Alien(Posted 2006) [#18]
The problem is, if you want to make a pro-Indie game, it needs windowed mode, and if you don't have MaxGUI, I had to offer something, hence the Graphics x,y,0 mode. It's very solid actually so no worries there, but yeah it won't have and GUI functionality like a drop down menu, and windows style controls (listboxes, combos, radios etc) but games don't need a drop down menu + I've made some game-based GUI elements so that's cool.


Damien Sturdy(Posted 2006) [#19]
HMM! Max doesnt officially support windowed mode, right?

MaxGUI- is it me or does this NOT support fullscreen? I mean, our current project lost its fullscreen mode purely because some dialogue boxes weren't showing up...!

Seems a bit strange that the two are to compliment each other but MaxGUI refuses to run in the "fully-supported" Max Fullscreen mode...


Grey Alien(Posted 2006) [#20]
they'll probably fix the GUI full-screen issue but they won't fix the windowed mode non-gui.


Dreamora(Posted 2006) [#21]
Vice versa is more logicall, as the GUI fullscreen thing is a restriction that comes from the GUI system itself. While Graphics contexts can be fullscreen, GUI can not be fullscreen, they can only be borderless maximized. (which is a little faster than normal window mode but significantly slower than fullscreen on many systems)


ImaginaryHuman(Posted 2006) [#22]
MaxGUI has never worked in fullscreen from what I remember. It is, after all, supposed to be part of the desktop gui environment.

Would be nice though (memories of Amiga).

Also there's only so much you can do with the basic window mode. If people are serious enough about having a good window mode they will have to buy MaxGUI.


Dreamora(Posted 2006) [#23]
This only solves problems partially. I own MaxGUI (actually bought it as I don't own BlitzPlus) and the canvas tends to have problems, the "non GUI" graphicwindow does not have. Don't ask me why, I actually never read that part of the sources.


ImaginaryHuman(Posted 2006) [#24]
I don't have any problems with Maxgui windowed canvas, what problems?


Grey Alien(Posted 2006) [#25]
yeah I know it's more logical to fix vice versa but based on the various chants of windowed mode graphics being "unsupported" I don't hold out much hope for it, esp when the MaxGUI and Max3D modules are getting so much BRL developer time.


Damien Sturdy(Posted 2006) [#26]
Um, By the way, I am able to change apptitle at any time... :S I'm using it to add a little "*" to my app title when the rendering gets too slow.


Grey Alien(Posted 2006) [#27]
Is your app GUI though?


*(Posted 2006) [#28]
The two things here that strike me as being daft are these:
1) You managed to change the icon etc in native max code so it can be done with a bit of work

2) If you want windowed mode in your games get the MaxGUI module as it allows you to output the rendering to a canvas as I have done with TileCascade.


Damien Sturdy(Posted 2006) [#29]
Ah right i see, Grey,

At first thoughts, yes.. but then I realised I had to extern some win32 to get the gui window title to change...


Grey Alien(Posted 2006) [#30]
EdzUp: re: 2) well lots of people buying the framework don't have MaxGUI and when there's a perfectly good windowed mode to use without it, I thought I'd make that work.

Cyg: aha I see.


Warren(Posted 2006) [#31]
2) well lots of people buying the framework don't have MaxGUI and when there's a perfectly good windowed mode to use without it, I thought I'd make that work.

I have to agree. If Max is going to let people compile release mode EXEs that support windowed mode, people are going to release those EXEs as products. If it's not supported, BRL needs to remove it, support it, or at least make it not work in release mode.


Grey Alien(Posted 2006) [#32]
I for one hope they don't remove it :-)


Warren(Posted 2006) [#33]
I hope they don't remove it either. It works. I don't know why they want to keep saying it's not supported and we shouldn't be using it. Seems silly.


Grey Alien(Posted 2006) [#34]
yeah it just needs a few commands to make it cool (my framework does this anyway):

1) ability to create the window at a certain screen pos (e.g. centred)
2) ability to have a minimise button. POssibly also a maximise button
3) ability to set a title bar icon (and task swapper icon)

and that's it :-)


*(Posted 2006) [#35]
I see IMHO I agree if windows mode is in there without MaxGUI then it should work 100% as it does in Blitz3d, I came to blitzmax when the GUI module come out so I had both from the beginning. I know loads of people done have the module but IMHO its well worth it to get much more control over windows.


ImaginaryHuman(Posted 2006) [#36]
It depends what you want to do I suppose but if you for example want a window without a title bar or with some custom gadgets MaxGUI is very handy.