Recent

Author Topic: Can FormPaint become overloaded that it affects the whole program?  (Read 2030 times)

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 479
  • Programming is FUN only when it works :)
    • Cool Technology
I've written a program that paints or draws objects much like MS Paint. It has a main window on which you draw the objects on after selecting object from the toolbar. However, there seems to be a problem. I also implemented a way of selecting objects that are already on the window by dragging the mouse to form a dotted square. Once you release the mouse, the dotted square goes away. The problem is that after selecting and drawing 2 or 3 objects on the window, the program stops drawing dotted square whenever I go to select objects that are already on the window as if the program is so busy drawing the objects that it doesn't give control back to the rest of the program.

Here is an implementation of the formpaint:

Code: Pascal  [Select][+][-]
  1. procedure TObjectFrm.FormPaint(Sender: TObject);
  2. begin
  3.    Canvas.Brush.Color := clWhite;
  4.    Canvas.FillRect(Rect(0,0,ClientWidth,ClientHeight);
  5.  
  6.    Canvas.Brush.Style := bsClear;
  7.    ObjectMgr.DrawObjects;
  8.    Canvas.Brush.Style := bsSolid;
  9. end;

Latest FPC, Lazarus and Mageia Linux Operating system.

Thanks for any help.

Handoko

  • Hero Member
  • *****
  • Posts: 5485
  • My goal: build my own game engine using Lazarus
Re: Can FormPaint become overloaded that it affects the whole program?
« Reply #1 on: April 18, 2016, 03:16:41 pm »
I'm not sure, but I think it may overload the machine only when it runs out of memory. It should be after drawing hundreds of objects. You said the problem raises after 2 or 3 objects, it sounds to me there is something wrong with your code.

Can you provide the whole code or the runable program so we can test and inspect?

 

TinyPortal © 2005-2018