Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Localization for Common Dialogs in Winform

0.00/5 (No votes)
3 Apr 2017 1  
Show different languages of Windows common dialogs, like file open dialog, color palette and font picker

Introduction

This is a tip to show different languages to common dialogs of Windows.

Background

Why did I post this? It is because I failed to get results even after Googling it for three hours, most of the responses were "No, you cannot do it." But, there must be a way.

Using the Code

First, the problem, try the following code anywhere inside a Winform app:

//
// C#
//
OpenFileDialog dlg = new OpenFileDialog();
dlg.ShowDialog();

You will see, the file opens a dialog popup with your OS languages. You could not modify it with properties of OpenFileDialog or CurrentUICulture. See this link.

The solution is easy, and I don't have much experience with Localization projects. I may update this in future if I work more on it.

//
// C#
//
// declare
//
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
static extern System.UInt16 SetThreadUILanguage(System.UInt16 LangId);

//
// Call before popup common dialog
//
SetThreadUILanguage(2052); // Chinese
//

Refer more from MSDN - SetThreadUILanguages.

Points of Interest

Nothing, just keep searching, pop up questions from different points, you may get more.

History

  • 3rd April, 2017: Initial version

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here