How to change AppTitle on run time.

BlitzMax Forums/BlitzMax Beginners Area/How to change AppTitle on run time.

Takis76(Posted 2015) [#1]
Hello,

I would like to ask is it possible to change the AppTitle variable on the runtime.

for example: In my level editor when I am loading some adventure , I would like to see on the Window bar (The appTitle) the file name of the adventure.

As I know the AppTitle initializes automatically when the application window opens when the program starts for the first time.

Is it possible to change the application title any time?

Thank you.


Henri(Posted 2015) [#2]
Hi,

yes you can change it simply by assigning new string value to it.

-Henri


grable(Posted 2015) [#3]
That wont work after the window has been created though.

Im guessing its a Graphics window you want to change? If so, you need to resort to platform specific code.
On Windows SetWindowText does the job, if you have a valid window handle.

Heres what i use to get the job done:
Function SetWindowTitle( title:String)
	Extern "Win32"
		Function SetWindowTextW:Int( handle:Int, text$w)
	EndExtern
	Local hwnd:Int = GetBlitzmaxWindow()
	If hwnd Then
		AppTitle = title
		SetWindowTextW( hwnd, title)	
	EndIf
EndFunction

Function GetBlitzmaxWindow:Int()
?Win32
	Extern "Win32"
		Function FindWindowW:Int( classname$w, windowtitle$w)	
	EndExtern
	Local handle:Int
	handle = FindWindowW( "BBDX9Device Window Class", AppTitle)			' D3D9Max2D
	If Not handle Then handle = FindWindowW( "BlitzMax GLGraphics", AppTitle)	' GLMax2D
	If Not handle Then handle = FindWindowW( "BBDX7Device Window Class", AppTitle)	' D3D7Max2D
	If Not handle Then handle  = FindWindowW( "BLITZMAX_WINDOW_CLASS", AppTitle)	' MaxGUI
	Return handle
?
EndFunction



Takis76(Posted 2015) [#4]
I worked perfectly :) Thank you very much.


GW(Posted 2015) [#5]
Very helpful! Thanks Grable