KryptonMessageBox position bug + localization?

Topics related to the Krypton Toolkit.

Moderators: Phil Wright, Chris Porter

KryptonMessageBox position bug + localization?

Postby Wampek » Tue Sep 14, 2010 8:36 pm

Thank you very much for this new version of toolkit.

KryptonMessageBox is beautifull but found a possible bug. If it's displayed without any form showing (for example before we run do Application.Run(new MainForm());) he will show it in top left window position while it should be showned centered on the screen.

Not sure if this is a bug but this is how default MessageBox is working and by my guess this is how it should be. Basicly it seems that you always want to display it in the middle of the form but if form is not showned he will display it in top left corner. I think all messageboxes should be showned on center of the screen and not on center of the form.

Also the text is all in English. I read in blog that we need to edit the kryptonmanager.globalstrings.

How can this be done globaly for all application that are using toolkit?
Last edited by Wampek on Tue Sep 14, 2010 9:15 pm, edited 1 time in total.
Wampek
 
Posts: 16
Joined: Tue Jan 27, 2009 10:16 pm

Re: KryptonMessageBox position bug?

Postby Wampek » Tue Sep 14, 2010 9:14 pm

Just remembered that I was looking for a way how to get the locale messagebox string out of windows. With help of google and some digging I came up with this source:

Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace MessageBoxLocale
{
    class Program
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
        [DllImport("kernel32")]
        static extern IntPtr LoadLibrary(string lpFileName);

        private const uint OK_CAPTION = 800;
        private const uint CANCEL_CAPTION = 801;
        private const uint ABORT_CAPTION = 802;
        private const uint RETRY_CAPTION = 803;
        private const uint IGNORE_CAPTION = 804;
        private const uint YES_CAPTION = 805;
        private const uint NO_CAPTION = 806;
        private const uint CLOSE_CAPTION = 807;
        private const uint HELP_CAPTION = 808;
        private const uint TRYAGAIN_CAPTION = 809;
        private const uint CONTINUE_CAPTION = 810;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder(256);

            IntPtr user32 = LoadLibrary(Environment.SystemDirectory + "\\User32.dll");

            LoadString(user32, OK_CAPTION, sb, sb.Capacity);
            string ok = sb.ToString();

            LoadString(user32, CANCEL_CAPTION, sb, sb.Capacity);
            string cancel = sb.ToString();

            LoadString(user32, ABORT_CAPTION, sb, sb.Capacity);
            string abort = sb.ToString();

            LoadString(user32, RETRY_CAPTION, sb, sb.Capacity);
            string retry = sb.ToString();

            LoadString(user32, IGNORE_CAPTION, sb, sb.Capacity);
            string ignore = sb.ToString();

            LoadString(user32, YES_CAPTION, sb, sb.Capacity);
            string yes = sb.ToString();

            LoadString(user32, NO_CAPTION, sb, sb.Capacity);
            string no = sb.ToString();

            LoadString(user32, CLOSE_CAPTION, sb, sb.Capacity);
            string close = sb.ToString();

            LoadString(user32, HELP_CAPTION, sb, sb.Capacity);
            string help = sb.ToString();

            LoadString(user32, TRYAGAIN_CAPTION, sb, sb.Capacity);
            string tryAgain = sb.ToString();

            LoadString(user32, CONTINUE_CAPTION, sb, sb.Capacity);
            string cont = sb.ToString();

            Console.WriteLine("OK: " + ok);
            Console.WriteLine("Cancel: " + cancel);
            Console.WriteLine("Abort: " + abort);
            Console.WriteLine("Retry: " + retry);
            Console.WriteLine("Ignore: " + ignore);
            Console.WriteLine("Yes: " + yes);
            Console.WriteLine("No: " + no);
            Console.WriteLine("Close: " + close);
            Console.WriteLine("Help: " + help);
            Console.WriteLine("Try again: " + tryAgain);
            Console.WriteLine("Continue: " + cont);
        }
    }
}


The output for Slovenian Windows is:

Code: Select all
OK: V redu
Cancel: Prekliči
Abort: Pre&kini
Retry: Poskusi &znova
Ignore: Pre&zri
Yes: &Da
No: N&e
Close: &Zapri
Help: Pomoč
Try again: Poskusi &znova
Continue: &Nadaljuj


Maybe something like this you can implement already inside KryptonMessageBox for default strings. If you edit them in KryptonManager.GlobalStrings then he should use those inputed. But by default he should display the ones from current Windows localization.
Wampek
 
Posts: 16
Joined: Tue Jan 27, 2009 10:16 pm

Re: KryptonMessageBox position bug + localization?

Postby Phil Wright » Wed Sep 15, 2010 9:04 am

Thanks for the bug report on the window location, I will fix that in the next release.

The localization of the strings is possible by adding a KryptonManager to your form and then setting the values of the KryptonManager.GlobalStrings as needed per-language.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia


Return to Krypton Toolkit

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron