Mega Code Archive

 
Categories / Delphi / Examples
 

How to display status messages

Title: How to display status messages. Question: When my form was minimized to icon, I wanted to change the message viewed when switching between applications in the Task Manager. That's a very good work... Answer: First, you need to define the default messages: Const DefMsgNorm = 'MyApp version 1.0'; DefMsgIcon = 'MyApp. (Use F12 to turn of)'; And two global variables: Var ActMsgNorm : String; ActMsgIcon : String; When opening the main form, you should inizialize the variables to the constants. Procedure TFormMain.FormCreate( Sender : TObject ); Begin ActMsgNorm := DefMsgNorm; ActMsgIcon := DefMsgIcon; Application.Title := ActMsgNorm; End; Then, you only must add this in the OnResize event: Procedure TFormMain.FormResize( Sender : TObject ); Begin If ( FormMain.WindowState = wsMinimized ) Then Application.Title := ActMsgIcon Else Application.Title := ActMsgNorm; End; That's very portable, because if you need to change the messages at runtime, you just must change the value to the two variables and the system need no change.