String Table

String tables are programming resources to hold text strings. They can be added or edited by resource editor that is present in Visual Studio. String tables are basically a list of strings which are compiled and added in executable binary.

String Table in VC++

One Visual C++ project combines two types of programming resources. Source code files and resource files. Source code files are programming files those are compiled to become executable files. Resource script files are static or dymamic resource files like string tables and constants, dialogs, forms, menu items etc.

String tables are like a list of string texts those are displayed in the UI. String tables are just like C character array constants.

A new string table can be inserted into the main project file.

Insert String table VC++

Here we are inserting a new string table.

new-string-table-resource

We have to save the string table to a file.

save string table to file

Resource script can be opened in resource tab.

resource-tab-string-table

We have added a string named as IDS_TITLE and the caption of this string. The resource compiler will create a autogenerated header file resource.h for containing the resource IDs as C/C++ macros. These macro numbers can be used in application code.

string-table-string-value-eng

string-table-string-value-ite

Multilanguage UNICODE strings

String tables are mainly used to support Multilanguage string display in an application. Application can be used in different regions of the world and display can be in any local international languages available. User has to provide the string table resources needed for the application. However the main application source is never changed or never need to compile for different language. LoadString API call can be used to obtain string from string table.

LoadString Win32 API

Loads a string resource from the executable file associated with a specified module, copies the string into a buffer, and appends a terminating null character.

LoadString Syntax

int WINAPI LoadString (
    HINSTANCE hInstance,
    UINT uID,
    LPTSTR lpBuffer,
    int nBufferMax
);

LoadString table example

#include "stdafx.h"
#include "resource.h"
#include <stdio.h>

int APIENTRY WinMain (
  HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR     lpCmdLine,
  int       nCmdShow
)
{
  char szTitle[100];
  char szMsg[100];
  if (LoadString(hInstance, IDS_TITLE, szTitle, 100) > 0) {
    sprintf(szMsg, "This is a string from string table!\r\n"%s"", szTitle);
  MessageBox(NULL, szMsg, szTitle, MB_OK|MB_ICONASTERISK);
  }
  return 0;
}

String table English

String table English

String table Italian

String table Italian

About our authors: Team EQA

Further readings

Where is WinMain() function in MFC application ?

MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.

What is the utility of CWinApp class?

This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...

Basic steps in Win32 GUI Application with source code.

Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.

What is a Window CallBack procedure and what is its utility?

DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.

What are LPARAM and WPARAM in window proc function?

LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.

What are the basic steps of a typical MFC based application?

We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...

Learn on Youtube

#