Конференция "KOL" » Problem with 2.83 since 2.53 [Delphi, Windows]
 
  • Dodfr (21.10.07 17:12) [0]
    Hi,

    In my project I do some height and size changes of multiple forms within the OnPaint and for unknown reason it produce 100 %CPU since I jumped from KOL 2.53 to 2.83

    The 100% CPU is because it endless loop into KOL.TControl.ProcessMessages once the OnPaint is done.

    I know my question is nearly impossible to answer "as is" but may be somebody know if something changed in messages or form painting management ?

    regards.
  • homm © (21.10.07 17:47) [1]
    > [0] Dodfr   (21.10.07 17:12)
    > size changes of multiple forms within the OnPaint

    Maybe don't use events, which not intend for that purpose?
  • Dodfr (21.10.07 19:36) [2]
    What I do is to call form.invalidate from a Timer every second, which fire the OnPaint event from which I do the form drawings, this is the standard way to do it I think.

    TControl.ProcessMessages is were the program falls once OnPaint is done.
  • Vladimir Kladov © (21.10.07 20:26) [3]
    Possible scheme is:
    1) you change size in OnPaint;
    2) When out from OnPaint, message loop receives WM_PAINT (since size changed);
    goto 1)

    Very short loop. You can solve it, e.g. following way:
    if Control.Width <> newWidth then ControlWidth := newWidth;

    But this is not garantee, that every time newWidth will be another. It is better to send a WM_USER+magic_number to a form, and process it in OnMessage, calculating and assigning new size there.
  • ANTPro © (21.10.07 20:27) [4]
    > [2] Dodfr   (21.10.07 19:36)

    if assigned(form) then form.invalidate;

    ?
  • homm © (21.10.07 20:45) [5]
    Зачем изменять размер в OnPaint, убей не пойму. OnPaint  что-бы в нем рисовать!
  • Dodfr (21.10.07 21:02) [6]
    homm : sorry I can't read russian

    antpro : my forms are always assigned so no need to test for this.

    vlad : yes I do a form.height and form.width, it worked well with 2.53 but if you say about it then I will follow your advice. I tested it in a new empty project, put form.height:=100; form.width:=100; within .OnPaint and it worked so I thought it was not the real source of the problem.
  • homm © (21.10.07 21:22) [7]
    > [5] homm ©   (21.10.07 20:45)

    Ok, I try :)

    Why you use OnPaint for resizing you contols? This event need for painting and painting only.
    If you already use Timer, you can do resize from it metod OnTimer.
  • ANTPro © (21.10.07 22:09) [8]
    > [6] Dodfr   (21.10.07 21:02)

    Show your code :)


    > [6] Dodfr   (21.10.07 21:02)
    > I can’t read russian

    http://www.google.com/translate_t
  • Dodfr (21.10.07 22:48) [9]
    I understand that chaging height and width should (re)call OnPaint but the endless loop never go back to onPaint and stay inside ProcessMessage loop.

    The code is too long to be showed here but I am still wondering what changes from 2.53 to 2.83 make my drawing routine not work.

    If I remove some .height and .width the program works again, but not all have an impact over the loop.

    I will try to search more with your informations.

    Thank you all.
  • homm © (21.10.07 23:29) [10]
    > [9] Dodfr   (21.10.07 22:48)
    > I am still wondering what changes from 2.53 to 2.83 make
    > my drawing routine not work.

    You think changing size of controls is a «drawing routine»??? «Drawing routine» should works pefect.
  • Dodfr (22.10.07 01:02) [11]
    My window(s) may change size at each redraw this is why I change it during OnPaint drawing routine that calculate width and height space needed.
  • homm © (22.10.07 06:39) [12]
    > [11] Dodfr   (22.10.07 01:02)

    I say the same many times! Don't use OnPaint for enething else but drawing!
    You may calculate change size of you controls in another method, for example in timer. When you change size, windows will receive WM_PAINT messages automaticaly.
    Risize controls OnPaint is a bad idea!
  • GMax (23.10.07 01:29) [13]
    ANCHORS_WM_SIZE ?
    this is one "size" noticeable change
  • thaddy (23.10.07 12:16) [14]
    Can you email me the source? - to my real account - ?
    See what I can do.
 
Конференция "KOL" » Problem with 2.83 since 2.53 [Delphi, Windows]
Есть новые Нет новых   [134431   +10][b:0][p:0.001]