RAD Studio VCL Reference
|
Determines whether the control's image is rendered directly to the window or painted to an in-memory bitmap first.
property DoubleBuffered: Boolean;
__property Boolean DoubleBuffered;
When DoubleBuffered is false, the windowed control paints itself directly to the window. When DoubleBuffered is true, the windowed control paints itself to an in-memory bitmap that is then used to paint the window. Double buffering reduces the amount of flicker when the control repaints, but is more memory intensive.
When a windowed control is a dock site and has an associated dock manager, it must be double-buffered.
C++ Examples:
/* This code comes from an application that contains a list box and three labels, each with a different font and color. The DragMode property for each of the labels is dmAutomatic. The user can select a label and drag it to a list box and drop it. When the label is dropped, the items in the list box assume the color and font of the dropped label. */ // This OnDragOver event handler permits the list box to // accept a dropped label: void __fastcall TForm1::ListBox1DragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = Source->ClassNameIs("TLabel"); } /* This OnDragDrop event handler implements the drop behavior. */ void __fastcall TForm1::ListBox1DragDrop(TObject *Sender, TObject *Source, int X, int Y) { if (Sender->ClassNameIs("TListBox") && Source->ClassNameIs("TLabel")) { TListBox *DestList = dynamic_cast<TListBox *>(Sender); DestList->Font = (dynamic_cast<TLabel *>(Source))->Font; DestList->Color = (dynamic_cast<TLabel *>(Source))->Color; DestList->DoubleBuffered = true; DestList->Color = clWindow; } } void __fastcall TForm1::FormCreate(TObject *Sender) { ListBox1->Items->Add("Not"); ListBox1->Items->Add("In"); ListBox1->Items->Add("Alphabetical"); ListBox1->Items->Add("Order"); }
Delphi Examples:
{ This code requires a list box and three labels, each with a different font and color. The DragMode property for each of the labels is dmAutomatic. The user can select a label and drag it to a list box and drop it. When the label is dropped, the items in the list box assume the color and font of the dropped label. } procedure TForm1.FormCreate(Sender: TObject); begin ListBox1.Items.Add('Not'); ListBox1.Items.Add('In'); ListBox1.Items.Add('Alphabetical'); ListBox1.Items.Add('Order'); end; // This OnDragOver event handler permits the list box to // accept a dropped label: procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := Source is TLabel; end; // This OnDragDrop event handler implements the drop behavior. procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer); begin if (Sender is TListBox) and (Source is TLabel) then begin with Sender as TListBox do begin Font := (Source as TLabel).Font; Color := (Source as TLabel).Color; DoubleBuffered := true; Color := clWindow; end; end; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|