Recent

Author Topic: Is it possible to call Application.ProcessMessages from another unit?  (Read 1584 times)

asdlinux

  • New Member
  • *
  • Posts: 17
Hi Everyone,

I made a function to copy a directory recursive for my 'Filemanager' I am making to learn Lazarus/Free Pascal.
I have placed this function in a seperate unit to build a little 'function library' for myself. Now, When I am calling it from my main thread it, of course, hangs my gui until it finished copying. It there a way to call Application.ProcessMessages in my function or what would be the best solution? I want to be able to update a progress bar and status text while it is copying but I want the user to be able to locked from starting other work.

Thanks Magnus

avk

  • Sr. Member
  • ****
  • Posts: 269
    • my self-education project
Re: Is it possible to call Application.ProcessMessages from another unit?
« Reply #1 on: January 25, 2019, 11:21:40 am »
It there a way to call Application.ProcessMessages in my function
Have you tried to include unit Forms in the uses clause of your unit?

GetMem

  • Hero Member
  • *****
  • Posts: 3689
Re: Is it possible to call Application.ProcessMessages from another unit?
« Reply #2 on: January 25, 2019, 11:23:34 am »
In my opinion you should move the recursive search to a worker thread.

asdlinux

  • New Member
  • *
  • Posts: 17
Re: Is it possible to call Application.ProcessMessages from another unit?
« Reply #3 on: January 25, 2019, 11:59:24 am »
Adding Uses Forms did solve the problem, But As sugggested Using a worker thread would be a future solution.
Thank you for the help !!!
 :D

Curt Carpenter

  • Full Member
  • ***
  • Posts: 127
Thank you!  Mystery solved for me as well.
And thanks for the forums in general!!

 

TinyPortal © 2005-2018