whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews ¦  misc ¦  forum
 kylix ¦  tutorials ¦  online shop ¦  photos ¦  Add&Win Game

Tips (1565)

Database (91)
Files (139)
Forms (113)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (133)
IntraWeb (0)
Kylix (10)
Math (77)
Misc (128)
Multimedia (46)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (246)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


SwissDelphiCenter is a Borland Technology Partner
 
...show a form without focusing?
Autor: hadi forghani
[ Print tip ]  

Tip Rating (12):  
     


//in TCustomForm class,in protected section add

    
procedure ShowParam(var param : integer);dynamic;
    {
    this procedure call when form should be show,
    now you should override this method and write your option for
    ShowWindow API. see the example
    }
    
function InShowFocus : boolean ;dynamic;
    //this function determine that after show the Form , focus on it or no.

//and it's code is

procedure TCustomForm.ShowParam(var param: Integer);
const
  
ShowCommands: array[TWindowState] of Integer =
    (SW_SHOWNORMAL, SW_SHOWMINNOACTIVE, SW_SHOWMAXIMIZED);
begin
  
param := ShowCommands[FWindowState];
end;

function TCustomForm.InShowFocus: Boolean;
begin
  
Result := True;
end;
//-------------------------------------------------------
//now in your class you can use from themunit Unit2;

interface

uses
  
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  
TForm2 = class(TForm)
  private
    
{ Private declarations }
  
protected
    procedure 
ShowParam(var param: Integer); override;
    function InShowFocus: Boolean; override;
  public
    
{ Public declarations }
  
end;

var
  
Form2: TForm2;

implementation

{$R *.dfm}

{ TForm2 }

function TForm2.InShowFocus: Boolean;
begin
  
Result := False;
end;

procedure TForm2.ShowParam(var param: Integer);
begin
  inherited
;
  param := SW_SHOWNOACTIVATE;
end;

end.


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners