Recent

Author Topic: Changing Form.Caption  (Read 11470 times)

tintinux

  • Sr. Member
  • ****
  • Posts: 365
    • Gestinux
Changing Form.Caption
« on: January 23, 2012, 06:16:05 pm »
Hi

In a TForm object, I change the title by Form.Caption := 'something else'

Most times, this changes nothing in display.
In only one Form of my project (over 30) this works perfectly, the title is changed.
I am unable to see any difference between the working form and all the others.

I do have added Update or Invalidate, and Application.ProcessMessages, but this changes nothing at all.

Any idea ?
Thanks !
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Changing Form.Caption
« Reply #1 on: January 23, 2012, 10:07:59 pm »
Can you give a simple example of the code you are using to change the window that works and the code for one of the other's that does not work?
What are you using to trigger the change to the form.caption on each of the windows / forms?

tintinux

  • Sr. Member
  • ****
  • Posts: 365
    • Gestinux
Re: Changing Form.Caption
« Reply #2 on: January 24, 2012, 01:32:51 pm »
Hi

The code to change the caption is the same, it is in a common unit, defining a TForm's descendant, used by all forms.

When a key is pressed, it finds translations, and update the form's caption.
All owned controls captions are correctly updated right after.

To simplify, something like :
Code: [Select]
procedure TGForm.DoKeyDown(Sender : TObject; var Key: Word; Shift: TShiftState);

begin
  case Key of
    VK_F4 : Self.Caption := 'some translation';
    end ;
end ;

I have checked that showmessage(caption) display the right one. This only looks like display/refresh issue.

The full pascal code is downloadable below.

Common unit : http://gestinux.svn.sourceforge.net/viewvc/gestinux/trunk/util/gform.pas
Calling form, not working : http://gestinux.svn.sourceforge.net/viewvc/gestinux/trunk/unitmenu.pas
Calling form, working : http://gestinux.svn.sourceforge.net/viewvc/gestinux/trunk/unitmoves.pas

Thanks !

PS : I'm using Lazarus 0.9.30. It happens with Linux GTK2 and Windows.
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Changing Form.Caption
« Reply #3 on: January 26, 2012, 02:59:27 am »
Probably not the issue, but a good practice anyway (so I've been told a few times by other board members.)

I noticed that you only have application.processmessages; in unitmoves.pas and not in unitmenu.pas.  I would suggest adding it after you write the caption text to the form and see if that does any good.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Changing Form.Caption
« Reply #4 on: January 26, 2012, 03:04:41 am »
(Rereading your second post) 
Are you saying that writing the caption to formX fails, but all other modifications for FormX work?  What happens if you change the order in which you make changes?  Do you get the same results?

tintinux

  • Sr. Member
  • ****
  • Posts: 365
    • Gestinux
Re: Changing Form.Caption
« Reply #5 on: January 26, 2012, 01:11:33 pm »
Quote from: IPguy
Are you saying that writing the caption to formX fails, but all other modifications for FormX work?  What happens if you change the order in which you make changes?  Do you get the same results?

Yes, the issue is only for caption of most of the forms.
Captions and Hints of components owned by the Form are 99% correctly updated.

I must say that I have noticed less than 1% of components not changing caption,  but may be there are other explanations. I have not investigated.

I have added Application.Process messages and tried to change the order. Even to remove processing of sub components. Same result !

Strange, isn't it ?

Thanks for trying to help !

Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Changing Form.Caption
« Reply #6 on: January 26, 2012, 02:04:41 pm »
How about the brute force method?
Create an onActivate event for each of the forms containing a line to set Form.caption and each time you run through the translate function, call the onActivate event for the "Self" form? 

tintinux

  • Sr. Member
  • ****
  • Posts: 365
    • Gestinux
Re: Changing Form.Caption
« Reply #7 on: January 27, 2012, 10:36:37 am »
I have just discovered that, when I update the caption, the new caption is (most time) not changed on the main window, but it is changed in the taskbar  !  What could do such a strange thing ? Sounds like a bug...

Quote from: IPGuy
Create an onActivate event...
I do not understand what this would change... and it doesn't do anything.

Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

 

TinyPortal © 2005-2018