Page 1 of 1
[i18n] CultureBox changing occurs creation forms!

Posted:
July 12th, 2012, 6:14 pm
by arhangelsoft
Hello!
The project have non auto-creation forms, and when I change language by choosing it in TCultureBox. These forms will be create automatically(not by me), and i Can't close it Only terminate the process and refuse using i18n.
Can you fix this problem?
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 12th, 2012, 8:35 pm
by Kambiz
Sorry, I didn't get how this happens. Could you please post or attach the code?
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 12th, 2012, 9:23 pm
by arhangelsoft
hm, I'm not understand how it's happens o_O.
I've made sample application and all works fine..
Only what I can do now is a made video demo:
https://www.dropbox.com/sh/k69ia1st0blj ... ample2.zipOn each form placed TTranslator and linked to TLocalizer on main form. Window with no title is a EmptyForm, other windows is a RulesEditorForm. These forms is auto-create. One window also was shows while I'm not disabled DoubleBuffered property on it. Now I was disabled this form property on all forms but result you can see now on demo. Two forms already stays and makes problem.
How I can help you to find this bug? Where i'm need to place breakpoint in source code of TCultureBox(or in some else code of some?) for find bug?
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 13th, 2012, 5:23 pm
by Kambiz
Sorry but it's difficult to find the reason of that problem using a video.
I need a sample code that regenerates the issue, otherwise it is impossible for me to find out origin of the problem and fix it.
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 13th, 2012, 6:05 pm
by arhangelsoft
Sorry, I'm don't have a bug code...
I think, it happens when translate/class/interface component call the form for enumerate it's child controls. Where I can find it?
Where and what event arises when I change the language? (in TCultureBox, I doesn't found it)
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 14th, 2012, 10:29 am
by Kambiz
The select (protected) method of TCustomCultureBox changes the localizer's locale, but knowing that is not so much help.
I do suggest to review your code. Maybe by a mistake click, an event handler is connected to one of the localizer or translator events.
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 14th, 2012, 6:46 pm
by arhangelsoft
YES! I'm made it!
I'm made example project with this bug.
Notes:
All forms with visible:=False
Localizer placed in DataModule
After start, Main form are visible and I have two windows: Form2 and Form3 is also visible but it's fake windows and I can't control it(Likes in a demo video).
But now I'm only start program, no change language or something else.. I think problems in Localizer initialization or creation..
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 15th, 2012, 4:20 pm
by Kambiz
The creation order of auto-created data modules and forms is important. For your case, the DataModule must be created before other forms.
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 16th, 2012, 11:10 am
by arhangelsoft
Problem resolved in demo:) , but don't fixed in project
The magic window still created and I'm can't control it.
Why this bug occurs without DataModule, If I'm put TLocalizer on MainForm?
1 problem with constants also not resolved. What do you think about it?
Thanks

Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 18th, 2012, 6:03 pm
by arhangelsoft
I'm resolved problem in my project, but forms creation in run-time isn't solution.
Not all forms might be created in run-time.
Please fix this bug.
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
July 23rd, 2012, 9:09 pm
by Kambiz
I believe that the problem is the order of form creation not the auto form creation.
Or maybe component loading in Delphi XE2 has changed, because I've tested the i18n package on Delphi 2009 and 2010 only.
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
August 18th, 2012, 4:20 pm
by arhangelsoft
Greetings, Kambiz! I'm found the "error" code..
- Code: Select all
procedure TTranslator.EndUpdate;
begin
Dec(fUpdateCount);
if (fUpdateCount = 0) and (Owner is TWinControl) then
begin
if TWinControl(Owner).HandleAllocated then
begin
//TWinControl(Owner).Perform(WM_SETREDRAW, 1, 0);
{RedrawWindow(TWinControl(Owner).Handle, nil, 0,
RDW_ERASE or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_UPDATENOW); }
end;
if (Owner is TCustomForm) and Assigned(fActiveControl) then
TCustomForm(Owner).ActiveControl := fActiveControl;
end;
end;
hm, before showing, the window is invisible... Your code doesn't consider that and paint it. So we have 2 windows, 1 painted by TApplication and is invisible, 2 window painted by i18n and is visible, but non control.
I've comment these strings and bug is fixed, but now after change language, window doesn't redraw automatically.
How fix it?
Also:
http://msdn.microsoft.com/en-us/library ... 19(v=vs.85).aspx
If the application sends the WM_SETREDRAW message to a hidden window, the window becomes visible (that is, the operating system adds the WS_VISIBLE style to the window).
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
August 19th, 2012, 2:03 pm
by Kambiz
Thank you so much! Finding the reason of a bug is mostly as same as fixing it.
You can download
i18n package v1.2, which fixed the bug.
Re: [i18n] CultureBox changing occurs creation forms!

Posted:
August 19th, 2012, 2:23 pm
by arhangelsoft
Thanks for quick response and fix!
Your i18n package is the bests of all!