unit uROPoweredByRemObjectsButton; {----------------------------------------------------------------------------} { RemObjects SDK Library - Core Library } { } { compiler: Delphi 5 and up, Kylix 2 and up } { platform: Win32, Linux } { } { (c)opyright RemObjects Software. all rights reserved. } { } { Using this code requires a valid license of the RemObjects SDK } { which can be obtained at http://www.remobjects.com. } {----------------------------------------------------------------------------} {$I RemObjects.inc} interface uses {$IFDEF FPC}LResources,{$ENDIF} {$IFDEF LINUX} SysUtils, Classes {$IFDEF FPC}, Controls, Graphics {$ELSE}, QControls, QGraphics{$ENDIF}; {$ELSE} //ToDo: sort those out! Windows, SysUtils, Messages, Classes, Controls, Graphics, Forms, Dialogs, Menus, StdCtrls, ExtCtrls; {$ENDIF} {$IFNDEF FPC} {$R uROPoweredByRemObjectsButton.res} {$ENDIF} type TROPoweredByType = (atServer, atClient); TROPoweredByRemObjectsButton = class(TGraphicControl) private fBitmap: TBitmap; fApplicationType: TROPoweredByType; function GetHeight: byte; function GetWidth: byte; procedure SetHeight(const Value: byte); procedure SetWidth(const Value: byte); procedure SetApplicationType(const Value: TROPoweredByType); procedure UpdateBitmap; protected {$IFDEF MSWINDOWS} procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND; {$ENDIF} property Bitmap: TBitmap read fBitmap; procedure GetBitmap; virtual; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Paint; override; procedure Click; override; procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; published { Published properties and events } property Height: byte read GetHeight Write SetHeight; property Width: byte read GetWidth Write SetWidth; property Anchors; property ApplicationType: TROPoweredByType read fApplicationType write SetApplicationType default atServer; end; { TRoPoweredByRemObjectsButton } implementation {$IFDEF MSWINDOWS} uses ShellAPI; {$ENDIF MSWINDOWS} const STR_POWERED_BY_REMOBJECTS_CLIENT = 'POWERED_BY_REMOBJECTS_CLIENT'; STR_POWERED_BY_REMOBJECTS_SERVER = 'POWERED_BY_REMOBJECTS_SERVER'; constructor TRoPoweredByRemObjectsButton.Create(AOwner: TComponent); begin inherited Create(AOwner); fBitmap := TBitmap.Create(); UpdateBitmap(); SetBounds(Left, Top, -1, -1); { width/height get ignored anyway } {$IFDEF MSWINDOWS} Cursor := crHandPoint; {$ENDIF MSWINDOWS} end; { Create } destructor TRoPoweredByRemObjectsButton.Destroy; begin FreeAndNil(fBitmap); inherited Destroy; end; { Destroy } procedure TRoPoweredByRemObjectsButton.Paint; begin //inherited; Canvas.Draw(0,0,fBitmap); end; procedure TRoPoweredByRemObjectsButton.Click; begin {$IFDEF MSWINDOWS} ShellExecute(0,'open','http://www.remobjects.com',nil,nil,SW_SHOWNORMAL); {$ENDIF MSWINDOWS} end; procedure TRoPoweredByRemObjectsButton.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); begin inherited SetBounds(ALeft,ATop,fBitmap.Width,fBitmap.Height); end; procedure TROPoweredByRemObjectsButton.SetApplicationType(const Value: TROPoweredByType); begin if (fApplicationType <> Value) then begin fApplicationType := Value; UpdateBitmap; end; end; procedure TROPoweredByRemObjectsButton.UpdateBitmap; begin GetBitmap(); Invalidate; end; procedure TROPoweredByRemObjectsButton.GetBitmap; begin case fApplicationType of atServer: Bitmap.LoadFromResourceName(hInstance,STR_POWERED_BY_REMOBJECTS_SERVER); atClient: Bitmap.LoadFromResourceName(hInstance,STR_POWERED_BY_REMOBJECTS_CLIENT); end; { case } end; function TROPoweredByRemObjectsButton.GetHeight: byte; begin result := inherited Height; end; function TROPoweredByRemObjectsButton.GetWidth: byte; begin result := inherited Width; end; procedure TROPoweredByRemObjectsButton.SetHeight(const Value: byte); begin { no-op, width is fixed } end; procedure TROPoweredByRemObjectsButton.SetWidth(const Value: byte); begin { no-op, width is fixed } end; {$IFDEF MSWINDOWS} procedure TROPoweredByRemObjectsButton.WMEraseBkgnd(var Msg: TWMEraseBkgnd); begin Msg.Result := 0; end; {$ENDIF} {$IFDEF FPC} initialization {$I uROPoweredByRemObjectsButton.lrs} {$ENDIF} end.