was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

24 Visitors Online


 
...verhindern, dass sich ein Control neu zeichnet?
Autor: Mike Orriss, P. Below
Homepage: http://www.teamb.com
[ Tip ausdrucken ]  

Tip Bewertung (16):  
     


{
  Question:

  Is there a way to stop a component from refreshing until I've completed some
  processing?

  Answer:

  Yes. Most controls can be blocked from redrawing by sending a WM_SETREDRAW
  message with wParam = 0 to them. Once you have finished the changes you send
  another WM_SETREDRAW with wparam = 1. For a grid this would look like this:
}

{
  Frage:

  Gibt es eine Möglichkeit, dass sich eine Komponente solange nicht neu zeichnet,
  bis ich mit einer Verarbeitungsroutine fertig bin?

  Antwort:

  Ja. Die meisten Controls können "eingefroren" werden, indem man ihnen ein
  WM_SETREDRAW Nachricht mit wParam = 0 schickt.
  Danach kann man WM_SETREDRAW mit wparam = 1 schicken, um das Updaten wieder zulassen.
  Für ein Grid sieht es z.B so aus:
}


procedure LockControl(c: TWinControl; bLock: Boolean);
begin
  if 
(c = nilor (c.Handle = 0) then Exit;
  if bLock then
    
SendMessage(c.Handle, WM_SETREDRAW, 0, 0)
  else
  begin
    
SendMessage(c.Handle, WM_SETREDRAW, 1, 0);
    RedrawWindow(c.Handle, nil, 0,
      RDW_ERASE or RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
LockControl(DBGrid1, True);
  try
    
// do convoluted things to the grid
  
finally
    
LockControl(DBGrid1, False);
  end;
end;

{
  A number of controls have a build-in way to do that, the BeginUpdate and
  EndUpdate methods. You often find these not on the control itself but on
  some object property that manages the controls data, e.g. for a TMemo you use
  Lines.BeginUpdate and Lines.EndUpdate. The EndUpdate automatically forces a
  redraw of the control.
}

{
  Viele Controls besitzen schon die Methoden BeginUpdate und EndUpdate.
  Meistens findest man diese Methoden nicht direkt beim Control aber bei
  einer Objekt Eigenschaft, welche diese Methoden aufweist.
  Bei einem TMemo kann man z.B Lines.BeginUpdate und Lines.EndUpdate aufrufen.
  Mit BeginUpdate kann man verhindern, daß die Bildschirmanzeige aktualisiert wird,
  wenn Einträge angehängt, gelöscht und eingefügt werden. EndUpdate veranlasst
  das Control neu zu zeichnen.
}


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


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