Mega Code Archive

 
Categories / Delphi / System
 

Application processmessages replacement

Not only is Application.ProcessMessages quite long to type, often extra functionality needs to be called when its used. To this end I have created two basic wrappers which can be used in its place: ... procedure ProcessMsg(); overload; procedure ProcessMsg(const SleepFor: Word); overload; implementation procedure ProcessMsg(); begin ProcessMsg(0); end; procedure ProcessMsg(const SleepFor: Word); overload; begin Application.ProcessMessages(); Sleep(SleepFor); end; ... Now instead of writing Application.ProcessMessages(); in your code you can write ProcessMsg(); instead. And in the future you can extend what happens around Application.ProcessMessages calls without visiting lots of different areas of your code. If your using Delphi 2005 or above you could append the inline directive to the procedure declaration. The above functions require "Forms" and "Windows" to be added to the uses clause. These procedures could easily be added to the code in this article (http://www.howtodothings.com/ViewArticle.aspx?Article=758)