Ignore:
Timestamp:
May 27, 2019, 12:06:17 AM (5 years ago)
Author:
chronos
Message:
  • Added: More DPI aware components.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DpiControls/Demo/UDpiFormMain.pas

    r534 r535  
    66
    77uses
    8   Classes, SysUtils, UDpiControls, Dialogs;
     8  Classes, SysUtils, UDpiControls, Dialogs, Graphics;
    99
    1010type
     
    1313
    1414  TDpiFormMain = class(TDpiForm)
    15     DpiButton1: TDpiButton;
     15    DpiPaintBox1: TDpiPaintBox;
    1616    procedure DpiButton1Click(Sender: TObject);
    1717    procedure DpiFormMainCreate(Sender: TObject);
     18    procedure DpiPaintBox1Paint(Sender: TObject);
    1819  private
    19 
    2020  public
    2121
     
    3333procedure TDpiFormMain.DpiFormMainCreate(Sender: TObject);
    3434var
    35   DpiButton: TDpiButton;
    36   DpiImage: TDpiImage;
     35  Button: TDpiButton;
     36  Image: TDpiImage;
     37  ListBox: TDpiListBox;
     38  I: Integer;
     39  PaintBox: TDpiPaintBox;
    3740begin
    38   DpiButton := TDpiButton.Create(DpiFormMain);
    39   DpiButton.Parent := Self;
    40   DpiButton.SetBounds(10, 10, 100, 30);
    41   DpiButton.Caption := 'Click me';
    42   DpiButton.Visible := True;
    43   DpiButton1.Parent := Self;
     41  Button := TDpiButton.Create(DpiFormMain);
     42  Button.Parent := Self;
     43  Button.SetBounds(10, 10, 100, 30);
     44  Button.Caption := 'Click me';
     45  Button.Visible := True;
    4446
    45   DpiImage := TDpiImage.Create(DpiFormMain);
    46   DpiImage.Parent := Self;
    47   DpiImage.SetBounds(150, 10, 100, 100);
    48   DpiImage.Visible := True;
    49   DpiImage.Stretch := True;
    50   DpiImage.VclImage.Picture.LoadFromFile('dance.jpg');
     47  Image := TDpiImage.Create(DpiFormMain);
     48  Image.Parent := Self;
     49  Image.SetBounds(150, 10, 100, 100);
     50  Image.Visible := True;
     51  Image.Stretch := True;
     52  Image.VclImage.Picture.LoadFromFile('dance.jpg');
     53  //Image.Picture.LoadFromFile('dance.jpg');
     54
     55  ListBox := TDpiListBox.Create(DpiFormMain);
     56  for I := 0 to 10 do
     57    ListBox.VclListBox.Items.Add('Item ' + IntToStr(I));
     58  ListBox.Parent := Self;
     59  ListBox.SetBounds(250, 10, 100, 100);
     60  ListBox.Visible := True;
     61
     62  DpiPaintBox1.BoundsRect := Rect(0, 0, 100, 100);
     63  DpiPaintBox1.VclPaintBox.Parent := VclForm;
     64  DpiPaintBox1.Repaint;
     65end;
     66
     67procedure TDpiFormMain.DpiPaintBox1Paint(Sender: TObject);
     68begin
     69  with DpiPaintBox1.Canvas do begin
     70    Brush.Color := clWhite;
     71    Brush.Style := bsSolid;
     72    FillRect(Rect(0, 0, 100, 100));
     73    Caption := IntToStr(Width);
     74    Pen.Color := clGreen;
     75    Pen.Style := psSolid;
     76    MoveTo(0, 0);
     77    LineTo(100, 100);
     78    Font.Color := clRed;
     79    TextOut(40, 10, 'Scaled text');
     80  end;
    5181end;
    5282
Note: See TracChangeset for help on using the changeset viewer.