MessageDlg buttons

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
dcornelius
Posts: 7
Joined: Fri May 27, 2011 4:40 pm

MessageDlg buttons

Post by dcornelius »

I've got the MessageDlg function properly showing strings for different languages defined, but the OK/Cancel/Yes/No buttons never have any text--they are just blank.

I've got a Dialogs section in my .sil file, but perhaps it's not the right class name or something. Is there some detailed documentation about how to use this? How do I trouble-shoot my settings?
David Cornelius
Retail Dimensions, Inc.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,
The most possible reason for this could be either:
1. TsiLang components has no Dialogs section and you don't load it from the SIL/SIB file.
2. You've used same TsiLang component names for different forms and use something like this, for example in the Unit of Form1:

with Form2 do
begin
siLang1.MessageDlg(....);
end;

This will use siLang1 from FORM2 but you intended to use the siLang1 from FORM1.

Please let us know if this helps.
Best regards,
Igor Siticov.
dcornelius
Posts: 7
Joined: Fri May 27, 2011 4:40 pm

Post by dcornelius »

Thanks for your quick reply. I haven't made any progress yet. Here's what I've got--perhaps explaining my situation further will reveal something I've done wrong.

My project has several forms and one unit without a form. I added a data module to hold the main TsiLang and TsiLangDispatcher components. All other forms have TsiLinkedLang components pointing to the TsiLang component on the data module.

One of the forms, whose labels and other controls can show various translations correctly, needs to display a message in certain circumstances. It calls the local component to do that:

Code: Select all

siLangLinked.MessageDlg(siLangLinked.GetTextOrDefault('ID_CustomMsg'), mtInformation, [mbOK, mbCancel], 0);
The text from the GetTextOrDefault call shows correctly, but the OK/Cancel buttons are blank.

The .sil file, which is loaded through the data module's TsiLang component, has entries in the Dialogs section. The wizard automatically created a bunch with the class name of the data module as a prefix (i.e. TMyDataModule.All, TMyDataModule.Cancel, etc.). I have manually added entries for the form from which I am calling MessageDlg (i.e. TMyForm.All, TMyForm.Cancel, etc.) hoping that would fix the problem.

But the buttons are still blank.

Do I need to add entries to the CharSets or Fonts section? Or should I not be using a data module to hold the main TsiLang component?

One other question: I will also need to display messages from the one unit that does not have a form. How do I do that if the MessageDlg function uses the local form's font and CharSet settings? Will I have to find a way to refactor the code in order to display the messages from forms instead? Or will I have to call CreateMessageDlg and set the fonts and CharSets manually?

(Sorry for the long post...!)
David Cornelius
Retail Dimensions, Inc.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

It looks like CommonContainer property of TsiLangLinked is not set to TsiLang component. This is the reason for empty buttons.

When you translate unit without form usign TsiLang Expert (menu File | Source | Without Form) it will automatically insert the code that will use the existing TsiLang on some form (that will hole translations for this string). So you don't need to create anything special.
Best regards,
Igor Siticov.
dcornelius
Posts: 7
Joined: Fri May 27, 2011 4:40 pm

Post by dcornelius »

I'm pretty sure all that was set. I tried several things that seemed to make sense and match what you're telling me, but there must still be something amiss in my .SIL file or in my configuration.

I will mention that this project is a Delphi 5 plug-in that works inside a large application and the main part of the code does not have a form at all. Many of the messages need to display when there was no form already showing.

What I've done is create a form just for messages. I'm passing the ID of the string into an Execute method and the message is displayed dynamically. This is working (and I'm getting text on the buttons!) but the CharSet is not set correctly. In other words, English and Spanish work fine, but my tests with Russian and Chinese just show up as garbage.

I'll hit it again tomorrow--I know I'm close now.
David Cornelius
Retail Dimensions, Inc.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Incorrect chars displayed on dialog buttons under Russian or Chinese language caused by use of ANSI IDE and VCL. So when your OS Default Locale doesn't support these languages the regional chars could be displayed incorrectly. You may consider to use Unicode IDE or VCL for message dialogs. Please check http://www.tsilang.com/delphiglobalizat ... aq.html#21

Hope this helps.
Best regards,
Igor Siticov.
dcornelius
Posts: 7
Joined: Fri May 27, 2011 4:40 pm

Post by dcornelius »

I can't use anything but Delphi 5 for this particular project because it is a plug-in (.BPL). All the other forms are displaying other character sets correctly. My new one is not--I know it's something different and haven't figured it out yet. However, I used the wizard with the others and this one I added manually because I've added lots of entries the .SIL file. I may have to create a separate one for this form and merge the .SIL entries.
David Cornelius
Retail Dimensions, Inc.
dcornelius
Posts: 7
Joined: Fri May 27, 2011 4:40 pm

Post by dcornelius »

I finally got this all working. I created a custom form and was still having problems with that, but I carefully compared the new form with a different form that was working and discovered there was a form-level setting on either the Fonts or the Charset section (I don't recall now). Basically, I needed to add an entry for TMyForm.TMyForm. (At least, I pretty sure that's what fixed it.)

In any case, it wasn't the components or the form itself, but the entries in my .SIL file that I needed to get straightened out.

Thanks for the help!
David Cornelius
Retail Dimensions, Inc.
Post Reply