65.9K
CodeProject is changing. Read more.
Home

Localization for Common Dialogs in Winform

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.79/5 (15 votes)

Apr 3, 2017

CPOL
viewsIcon

11431

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