Board index » delphi » Why Does Form Repaint?

Why Does Form Repaint?

When the user moves the mouse cursor onto and then off of the Control
(System) menu icon, without clicking the mouse, the form's OnPaint
event handler repaints the form.

Why does this occur, and how can I prevent it?

Many thanks.

 

Re:Why Does Form Repaint?


Sheldon Shallon schrieb:

Quote

> When the user moves the mouse cursor onto and then off of the Control
> (System) menu icon, without clicking the mouse, the form's OnPaint
> event handler repaints the form.

> Why does this occur, and how can I prevent it?

It doesn't occur on my system.

Create a new project, assign an OnPait handler to the form, and do a
beep there. Does it beep any longer?

-Michael

Re:Why Does Form Repaint?


The problem is that if the user moves the mouse cursor onto and off of
the Control (System) menu icon (without clicking), the form's OnPaint
event is triggered and the form is repainted.

I am using D3. The project uses several other forms; one other form
has the problem, but the others do not. The forms are all called
modally from the main form.

Here is the slimmed-down code for the form. What you see is the
complete code. I have deleted everything else so I could troubleshoot
the problem. ShowMessage is called from FormPaint so I can tell when
FormPaint is triggered.

-----------------------------------------------------
unit MWMapsSh;

interface
uses Forms;

type
  TMapsDisplayForm = class(TForm)
    procedure FormPaint(Sender: TObject);
  private
  public
  end;

var MapsDisplayForm: TMapsDisplayForm;

implementation
uses Dialogs;
{$R *.DFM}

procedure TMapsDisplayForm.FormPaint(Sender: TObject);
begin
 ShowMessage('In FormPaint');
end;

end.
------------------------------------------------------

In case you need it, here is the DFM file:

------------------------------------------------------
object MapsDisplayForm: TMapsDisplayForm
  Left = 361
  Top = 120
  HelpContext = 15
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  ClientHeight = 404
  ClientWidth = 573
  Font.Charset = ANSI_CHARSET
  Font.Color = clBlack
  Font.Height = -15
  Font.Name = 'Arial'
  Font.Style = []
  OnPaint = FormPaint
  PixelsPerInch = 120
  TextHeight = 17
end
------------------------------------------------------

Any ideas?

Other Threads