How to change AppTitle on run time.
BlitzMax Forums/BlitzMax Beginners Area/How to change AppTitle on run time.
| ||
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. |
| ||
Hi, yes you can change it simply by assigning new string value to it. -Henri |
| ||
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 |
| ||
I worked perfectly :) Thank you very much. |
| ||
Very helpful! Thanks Grable |