Modify the title configuration in title bar of the main form
Configuration in title bar One common complaint with dynamics ax 4.0 is that it is not possible for the user to determine in which environment they are working. participant ularly for consultants/developers who often have multiple ax applications open at one time, this is very frustrating and can easily lead to errors (developing in the wrong application ). in axapta 3.0 information was displayed in the title bar allowing users to determine the application, but this is missing in ax 4.0 this simple fix will display the configuration name in the main dynamics ax window title bar. you need to simply override the workspacewindowcreated () method in the info () Class (Special Class nearly at the bottom of the classes node in the AOT) and add a single line of code. after the change, the method shoshould appear as follows:
VoidWorkspacewindowcreated (Int_ Hwnd ){;// Put workspace window specific initialization here.// Show config in title barWinapi: setwindowtext (_ hwnd,Strfmt("% 1-% 2", Winapi: getwindowtext (_ hwnd), xinfo: configuration ()));}
Another option is shown below. This will put the current AOS and server name, as well as the logged in development layer, after the standard title bar text.
Void Workspacewindowcreated ( Int _ Hwnd) {sqlsystem = New Sqlsystem (); loginproperty = sqlsystem. createloginproperty ();; // Put workspace window specific initialization here. // Show application details in title bar If (Loginproperty) {winapi: setwindowtext (_ hwnd, Strfmt ( "% 1-% 2 @ % 3 (% 4 )" , Winapi: getwindowtext (_ hwnd), loginproperty. getdatabase (), loginproperty. getserver (), this. currentaolayer ()));}}
The details for these fixes came originally from posts to the Microsoft public axapta newsgroup. Alternative ax 3.0 solution The original solution for ax 3 used oneventgoingidle to adapt the window title. this is not optimal since this is called when thousands of times during the lifetime of an axapta session. unfortunalety, one can't simply use info: startuppost () to set the title, as the ax client set the final title only after the startup cycle has completed. one workaround for this is to defer the execution of the Title Update using the setTimeout () method with the idle flag set to true. this will delay the execution of the method in question to the point, where axapta goes idle for the first time: Addendum: It seems, that axapta 3 resets the title bar now and again. I have not yet found the root cause of this. however, if you experience this problem, working around it is rather easy. reschedule the canupdatewindowtitle to run every thirty seconds or so. this is not as stressfull as running it over and over again like the original solution did.
// Classes \ info \ startuppostVoidStartuppost (){// Needs delay until idle to allow axapta to initialize fullyThis. setTimeout (Identifierstr(Updatewindowtitle), 1,True);}
The actual function in question is pretty straight forward:
// Classes \ info \ updatewindowtitle Void Canupdatewindowtitle () {session; sqlsystem; # define. wm_settext (0x0c) Int Setwindowtext ( Str Title ){ Int RET; DLL _ DLL = New DLL ( 'User32' ); Dllfunction _ defwproc = New Dllfunction (_ DLL, 'Defwindowproca' ); _ Defwproc. Returns (exttypes: DWORD ); // Lresult _ Defwproc. Arg (exttypes: DWORD ); // Handle window _ Defwproc. Arg (exttypes: DWORD ); // Message _ Defwproc. Arg (exttypes: DWORD ); // Wparm _ Defwproc. Arg (exttypes: string ); // Lparm Ret = _ defwproc. Call (infolog. hwnd (), # wm_settext, 0, title ); Return RET;}; Session = New Session (); sqlsystem = New Sqlsystem (); If (Isaos () setwindowtext ( Strfmt ( "Axapta-% 1" , Session. aosname ())); Else Setwindowtext ( Strfmt ( "Axapta 2 T-DB % 1 on % 2" , Sqlsystem. logindatabase (), sqlsystem. loginserver ())); // In case you experience problems: enable this to rerun every 30 seconds if axapta changes // The title back to the default now and then. // This. setTimeout (identifierstr (canupdatewindowtitle), 30000 ); }
Original ax 3.0 solution From axforum \ Classes \ info \ oneventgoingidle
// event fired by kernel when the client GoE S idle. // It is not fired during Ctrl-break dialog. void oneventgoingidle () {This. operationprogressclear (); this. endlengthyoperation ( true ); // There shocould be a user who will work if error occured If ( strlwr ( curuserid ())! = 'admin' ) titlechanger: changetitle () ;}
Titlechanger: changetitle:
Static Void Changetitle () {# define. wm_settext (0x000c) Str Caption; Str Prefix = New Session (). aosname () + ":" ; Int Defwindowproc ( Int _ Handle, Int _ MSG, Int _ Wparam,Str _ Lparam ){ Int RET; DLL _ DLL = New DLL ( 'User32' ); Dllfunction _ defwproc = New Dllfunction (_ DLL, 'Defwindowproca' ); _ Defwproc. Returns (exttypes: DWORD ); // Lresult _ Defwproc. Arg (exttypes: DWORD ); // Handle window _ Defwproc. Arg (exttypes: DWORD ); // Message _ Defwproc. Arg (exttypes: DWORD );// Wparm _ Defwproc. Arg (exttypes: string ); // Lparm Return _ Defwproc. Call (_ HANDLE, _ MSG, _ wparam, _ lparam) ;}; caption = winapi: getwindowtext (infolog. hwnd ()); If (! Strutils: startswith (Caption, prefix) defwindowproc (infolog. hwnd (), # wm_settext, 0, prefix + Caption );}
Strutils: startswith:
// String _ s begins with _ suffixStatic BooleanStartswith (Str_ S,Str_ Prefix ){ReturnStrlen(_ S)> =Strlen(_ Prefix )&&Substr(_ S, 1,Strlen(_ Prefix) = _ prefix ;}