Ads 468x60px

Smaller time frame always follow the bigger time frame. It's better wait be patience to enter in position than risk with BIG SL. Having strong trading discipline and taking losses when necessary is a sign of serious trading approach
Subscribe:

Labels

Saturday, August 11, 2012

SPLASH WINDOWS FOR ALL YOUR SPECIAL OCCATIONS


Splash windows can be used to dress up many parts of your application. You could use them at the initialization of your application to display copyright and other information, or you could use them to display "please wait messages" while your application is in the middle of long operations. You could also use variations of "splash windows" to display floating tool bars and other properties. Well, you get the picture. Here's how to create a simple splash window dynamically:


var
  WaitForm  : TForm;
  WaitLabel : TLabel;

function WaitStart(
  TheParent : TComponent;
  sMsg : string )
    : boolean;
begin
  Result := False;
  // create our message form
  // only if it's not already
  // created
  if( Nil = WaitForm )then
  begin
    WaitForm :=
      TForm.Create( TheParent );
    with WaitForm do
    begin
      Position  := poScreenCenter;
      Width     := 500;
      Height    := 25;

      // create the message label
      WaitLabel :=
        TLabel.Create( WaitForm );
      with WaitLabel do
      begin
        Align       := alClient;
        Alignment   := taCenter;
        Font.Height := -30;
        ParentFont  := False;
        Caption     := sMsg;
        Parent      := WaitForm;
      end;

      // hide the title bar
      SetWindowLong( Handle,
        GWL_STYLE,
        GetWindowLong(
          Handle, GWL_STYLE )
          and not WS_CAPTION );
      ClientHeight := Height;

      Show;
      Update;
    end;
    Result := True;
  end;
end;

procedure WaitSetMsg( sMsg : string );
begin
  WaitLabel.Caption := sMsg;
  WaitForm.Refresh;
end;

function WaitEnd : boolean;
begin
  Result := False;
  if( Nil <> WaitForm )then
  begin
    WaitForm.Hide;
    WaitForm.Free;
    WaitForm := Nil;
    Result := True;
  end;
end;
Here's a sample on how to use above splash windows functions:
// start the splash window
  WaitStart( Self {or Nil},
    'Please wait...' );

  // start the long operation...
  WaitSetMsg( 'Almost done!...' );

  // continue the operation...
  WaitSetMsg( 'One more second...' );

  // complete the operation
  WaitSetMsg( 'Done.' );

  // wait a bit here if you want users
  // to see the "done." message

  // close the splash window
  WaitEnd;

comments