Main form menu 'flickers' upon language load / change

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
John.Hofland
Posts: 5
Joined: Mon Mar 12, 2012 4:16 pm

Main form menu 'flickers' upon language load / change

Post by John.Hofland »

Hi,

We have project with a about 50 forms. Using Delphi XE and SiLang 6.5.4.3. The project contains 3 languages which are currently all in the program (no .SIL or .SIB loading at startup). On the main form we have SiLang and siLangDispatcher all other forms have TSiLinked components.

The ActiveLanguage is set in the Form's OnFormCreate. When it displays the form or when we switch languages from the menu the Main menu starts flickering for about a second or so (Looks like 'retyping' the menu - more then once, which users find very anoying).

Even tried Hiding and Showing the form (and when that did not work a loop containing Sleep and Application.ProcessMessage for about 10 times). But then the flickering just came when the screen was shown again.

Anything we can do to prevent this?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,

Do you use the standard VCL main menu or some custom VCL? It just looks like repainting problem of some custom drawing menu.
Best regards,
Igor Siticov.
John.Hofland
Posts: 5
Joined: Mon Mar 12, 2012 4:16 pm

Response

Post by John.Hofland »

It is an 'normal' TMainMenu.
AutoHotkeys = maAutomatic
AutoLineReduction = maAutomatic
AutoMerge = false
OwnerDraw = false

No events. And only one menu item with an OnClick that fills its sub-menu.

And just to be complete neither of the SiLang(Dispatcher) have events.

We did not have the problem before adding the TSiLang


I made a small 'movie' to show what is happening:
http://screencast.com/t/KNCTEvrfM77

It seems to ben just the 'top' menu/bar. And it also happens slowly when the 'manual' fill "Reopen" is 'opened'. But somehow not exactly the same. BTW the items in that sub-menu are excluded from translation.[/quote]
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

It looks like either VCL issue which flickers when it needs to re-align items. As you can see there is also some flickering when you click on "Re-open" item. TsiLang doesn't perform anything special, it just @changes the Caption property of controls". Does the flickering go away if you resize your form and all the menu items will be at a single line under all languages?
Best regards,
Igor Siticov.
John.Hofland
Posts: 5
Joined: Mon Mar 12, 2012 4:16 pm

Response

Post by John.Hofland »

I have been testing with this for some time. It still occurs when the screen is much wider (and one line).

Also checked DoubleBuffering of the form being on. This is currently the only program using SiComponents (before we had MultiLang, all other Windows tools are administration so just English and most of our programs are web based - using our own database based translation).

We tested a lot, also searched the web for TMainMenu having this problem (found none, except something with DoubleBuffering and Merging child menus which is not the case).

The only thing that we can see that differs is the SiLang components. But to be fair there are two other Forms in the same project with a TMainMenu and TSiLangLinked a that do not have the problem. But the main one is bigger and there are other components (Lang and Dispatcher).

So yes although logic dictates SiLang being the issue it could be somewhere else, but we found no way of debugging this and finding any other known problems, we put our hope on you (preferably a known issue).

Can you give us any suggestions??
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Could you please try the following:
1. Make a copy of the unit where the problem appears.
2. Remove all the code from it except TsiLang related code.
3. Create a new simple project only with this new unit and check if the problem still appears.
4. If the problem reproduced then please send us this sample project.
5. If problem won't be reproduced then the only way I could see is to delete partially the code in the original unit step-by-step and test everytime to detect which code causes such problem.
Best regards,
Igor Siticov.
John.Hofland
Posts: 5
Joined: Mon Mar 12, 2012 4:16 pm

Quick response

Post by John.Hofland »

Thanks for the reply. This will take some time to do. So probably get back to you somewhere next week.
John.Hofland
Posts: 5
Joined: Mon Mar 12, 2012 4:16 pm

Possible Solution

Post by John.Hofland »

After some testing with a fully functioning main screen but none of the sub-screens, I came to some conclusions.

* When a menu is updated (add and remove items, changing texts but also enabling and disabling menu items) Windows updates the whole menu (still a bit weird but that is what happens)

* The DoubleBuffering property goes for the whole client area of the screen. But the client area does not contain the window border, title and yes also not the main menu.

* We update the menu far to often. (e.g. after opening a project due to different area's it will in total do at least 3 updates from different locations. Which of course stresses the rebuilding of the menu much more (a short flicker 3 time becomes one longer annoying flickering)

I got two solutions:
The first is of course trying to limit the number of screen/menu-updates.
The second is only a visibility solution to make sure that when updating Windows does not modify the screen.

Code: Select all

  try
    LockWindowUpdate(Handle);
    Menu := nil;

    // Do menu updates here like:
    siLangDispatcher1.ActiveLanguage := (Sender as TComponent).Tag;

    Menu := MainMenu1;
  finally
    LockWindowUpdate(0);
  end;
This even removes any flickering when changing the language it just 'magically' swaps it.

I hope this is useful to other users...

And thanks very much for your time.
Post Reply