Messagebox, text initialy not visible (Linux) till resized lazarus / 1-Linux ---------------------------------------------------------------------- han · 2016-05-27 12:53 I have a large application which works fine under MSwindows version. However when converted to Linux, the messagebox's used in the program (in 4 out 5 cases) don't show the text. Only when I resize them larger a few mm by pulling the bottom line down, the text  and the buttons suddenly become visible. Even a simple messagebox instruction like below doesn't display properly: Application.MessageBox('This is a text of the messagebox', 'Testbox', MB_ICONHAND); The same thing sometimes happens with a dialog window. Grey till I pull the bottom line down. If I build a small application, all messageboxes work but not in the larger application. An other Linux (Triquel & Zorin), version did not help. Any idea how to fix this? Later, the same happens using with "showmessage"  Just a grey window. Resize for this type not possible so text stays fully hidden. Must be common cause??? Later, this only happens when the dialog is placed/called from an "ONPAINT"event of the main form. ---------------------------------------------------------------------- Handoko · 2016-05-27 14:01 Welcome to Lazarus/FPC forum. We would like to help you. But because of lack of information, no one will be able to help you. What is the OS, version of the OS, screenshot. And it will be better if source code is provided, you know bug can hide in anywhere in the code. ---------------------------------------------------------------------- han · 2016-05-27 14:25 I have attached a test program. I already noticed it only happens when the showmessage or messagebox is placed in the event "ONPAINT of the main form. In any other place the messagebox works correctly. In mswindows this was never an problem. I use Trisquel (Ubuntu), i386, Lazarus 1.7 GTK2,  FPC3.1.1 ---------------------------------------------------------------------- Handoko · 2016-05-27 14:42 I run the code you provided. I saw a problem. The first time it started, the messagebox is blank, but if I close it and click the button, the messagebox can show correctly. Is it the problem that you mean? Is yes, then I know why. Similar to your case, someone asked the question in this forum some weeks ago. For your case, my suggestion is: Never put any messagebox, showmessage, etc on OnPaint event. ---------------------------------------------------------------------- Handoko · 2016-05-27 15:04 Tested again but by moving the things inside OnPaint to OnShow, and it works correctly on my Ubuntu Mate. Question: Why? I don't know how to explain, perhaps someone more experience can provide better explanation. I just feel the code should not put on OnPaint. Some weeks ago, there is a question why ShowMessage can't be put on OnCreate. ShowMessage and MessageBox, and similar things are command that performing painting on the screen it should only be called after the program 'completely' loaded. So it should not be called on TForm.OnCreate nor TForm.OnPaint. But why not on OnPaint but yes on OnShow?   I don't know how to answer, but I have a strong feeling they should be put on OnShow. ---------------------------------------------------------------------- han · 2016-05-27 15:17 Thanks for the idea's. Glad you confirmed this behaviour. Yes it works on "Onshow". The only disadvantage is that my "new user" message is displayed while the main form is not yet visible which is not a good introduction for a "new user" message. So I will probably link it to a "Onkeydown & OnmouseDown event. Thanks , I can live with this conclusion. ---------------------------------------------------------------------- JuhaManninen · 2016-05-27 16:19 TForm.OnPaint is supposed to draw on canvas, nothing else. Opening a message box which steels focus there is begging for trouble (as you noticed). Quote from: han on May 27, 2016, 05:17:19 pmYes it works on "Onshow". The only disadvantage is that my "new user" message is displayed while the main form is not yet visible which is not a good introduction for a "new user" message. So I will probably link it to a "Onkeydown & OnmouseDown event. A typical way to solve that is a timer or, even better, an OnIdle handler which runs immediately after the form is shown and CPU goes idle. Register it in OnCreate or in OnShow and unregister in the handler itself. Lazarus IDE's code has plenty of examples about using OnIdle. Slow GUI updates are often done in an OnIdle handler.