1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88:
| unit ResizeControl;
interface
{$R Resize.dcr}
uses Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, ComCtrls, Buttons, StdCtrls;
type TResizeControl = class(TCustomPanel) private FToolBar : TToolBar; FUpDownBtn : TSpeedButton; FComb : TComboBox; FLow : Boolean; procedure ResetSize(Sender : TObject); protected public constructor Create(AOwner: TComponent); override; procedure CreateWnd; override; published property Parent; end;
procedure Register;
var PR : array[0..9] of PChar = ('0%', '5%', '10%', '15%', '20%', '25%', '30%', '35%', '40%', '45%');
implementation
procedure Register; begin RegisterComponents('Standard', [TResizeControl]); end;
constructor TResizeControl.Create(AOwner : TComponent); begin inherited Create(AOwner); Align := alBottom; FLow := True; FToolBar := TToolBar.Create(Self); FUpDownBtn := TSpeedButton.Create(FToolBar); FUpDownBtn.OnClick := ResetSize; FComb := TComboBox.Create(FToolBar); end;
procedure TResizeControl.CreateWnd; var I : Integer; begin FToolBar.Parent := Self; FUpDownBtn.Parent := FToolBar; FUpDownBtn.Glyph.LoadFromResourceName(HInstance, 'UP'); FComb.Parent := FToolBar;
for I:=0 to Length(PR) - 1 do FComb.Items.Add(PR[I]); FComb.ItemIndex := 1; FComb.OnChange := ResetSize; ResetSize(nil); end;
procedure TResizeControl.ResetSize(Sender : TObject); var S : String; H : Integer; begin S := FComb.Text; S := Copy(S, 0, Pos('%', S)-1); H := StrToInt(S); if(FLow)then begin Height := TWinControl(Parent).Height * (100 - H) div 100; FLow := False; FUpDownBtn.Glyph.LoadFromResourceName(HInstance, 'DOWN'); end else begin Height := TWinControl(Parent).Height * H div 100; FLow := True; FUpDownBtn.Glyph.LoadFromResourceName(HInstance, 'UP'); end; end;
end. |