Frequently Asked Questions

·         Question 1: How can I develop an Arabic application using Visual Basic 6.0?

·         Answer First, you need to install the Arabic language pack for Windows XP or Windows 2000, to be able to use the RightToLeft property. On Windows 2000: "Regional Options" in the "General" tab, add Arabic to the "Language setting for the system"

On Windows XP: "Regional and Language Options" go to the "Advanced" tab and change the "Language for non Unicode programs" to an Arabic language.

PS. This will not affect the user interface language.

Visual Basic is used to develop Arabic applications and you may find more information at:

Arabic Application Development Using Microsoft Visual Basic 6.0
PRB: Question Marks and Garbage Characters Instead of Arabic Text

·         Question 2: Is it possible to transfer a Windows application to a Web application, using Visual Studio .NET?

·         Answer

There is no wizard that can do this but the good news is that you can still host your Windows Forms application on a web site and give your users the URL that points to your application and they can run it using this URL. Keep in mind they need the .NET framework to do so.

·         Question 3: I'm using Visual C++ 6.0. I need to store data as Unicode and access it using Unicode instead of ANSI to make the application independent of the system locale.

·         Answer

You need to build your project as Unicode.

To take advantage of the MFC and C run-time support for Unicode, you need to:

· Define _UNICODE.

At Project settings\C/C++\Preprocessor definitions, define the symbol _UNICODE.

· Specify entry point.

In the Output category of the Link tab in the Project Settings dialog box, set the Entry Point Symbol to wWinMainCRTStartup.

You will need to add some Unicode libraries and DLLs, you find them on your Visual Studio CDs or the MSDN.

You need to make sure that your code is Unicode aware.

·         Question 4: I'm writing an bilingual application (Arabic/English) and was wondering how I can get an Arabic version of the common dialogs such as print, file open etc.

·         Answer

First of all, the common dialogs are resources in the comdlg32.dll, and the version that ships with Arabic localized Windows 2000 and Windows XP contains English and two versions of Arabic (one is mirrored (right to left layout) and the other is not) resources, of course Windows 2000 and Windows XP multilingual version contains the same as the Arabic localized version.

This means the common dialog that ships with the English Windows 2000 and Windows XP has the English resources only, which means there is no way for you to display Arabic common dialogs on such platforms.

With this have been said, the only platforms that you can achieve the functionality you are looking for are Windows 2000 and Windows XP Arabic localized edition and Multilingual.

Now, how it works on these platforms?

Common dialog loads the appropriate resource language for your application, what this means?

It means if your user interface is English it loads the English common dialog for you, and if it is Arabic user interface it loads one of the two Arabic resources for you.

How common dialog knows that your Application is English or Arabic?

The common dialog examines the owner window's extended styles as shown below,

Owner Window ExStyle

Common dialog used

WS_EX_LAYOUTRTL

Mirrored

WS_EX_RIGHT or/and WS_EX_RTLREADING

Enabled

None of the above.

English

So you can control the common dialogs language by setting the appropriate window style to your common dialog's owner window prior to loading the common dialog.

·         Question 5: Is there a way to convert from one codepage to another using Windows APIs?

·         Answer

Windows does not have a single API that allows you to convert from CP (code page) to another CP but it has one API that allows you to convert from a given CP to Unicode and it has another one to convert from Unicode to given CP.

These two APIs are MultiByteToWideChar and WideCharToMultiByte.

The very first parameter for these two APIs is the coed page that you are converting from or converting to.

So if you want to convert a string from CP1 to CP2 all what you need to do is

//First convert the CP1 string to Unicode string

MultiByteToWideChar(CP1,.);

//Now your string is Unicode convert it to CP2 string

WideCharToMultiByte(CP2,.);

·         Question 6:I am trying to set the RightToLeft property in design time to true but am unable to do so. Do I need to design my software on a BI-DIRECTIONAL platform? Or do I need to set something special in Windows 2000?

·         Answer

First, you need to install the Arabic language pack for Windows XP or Windows 2000, to be able to use the RightToLeft property.

On Windows 2000: "Regional Options" in the "General" tab, add Arabic to the "Language setting for the system"

On Windows XP: "Regional and Language Options" go to the "Advanced" tab and change the "Language for non Unicode programs" to an Arabic language.

PS. This will not affect the user interface language.

·         Question 7: I opened my Visual Basic 6.0, and by default the RightToLeft property is set to false. I have tried to set it as true, but the program doesn't accept it. It returns the property back to false again.

·         Answer

You need to make sure you installed Arabic properly.
From the "Control Panel\regional settings" in the "Language" tab select "Details." for the input languages. You should find Arabic.
To test Arabic Input, run "notepad.exe", switch the keyboard to Arabic (by pressing ALT + Shift right) and type Arabic text. Is the Arabic text properly displayed? If not then you should make sure you installed the Arabic language pack properly.

·         Question 8:I am facing small problem regarding the screen flipping in Visual Basic 6.0 for the Arabic conversion of my application. Some of the controls are not laid out from right-to-left properly, even when I specify RightToLeft = True. Example Treeview and Toolbar. Is there any work around?

·         Answer

The RightToLeft property has limited effect over some controls. Examples Form, Treeview, Listview, Toolbar, Progressbar and Statusbar. In order to correctly achieve the RightToLeft look we need to adopt the SetWindowLong technique. The following is a code listing for its implementation.

Create a module and declare the following APIs

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal_

hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal_

hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As_

Long, ByVal bErase As Long) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal_

hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As_

String) As Long
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long)_

As Long
Public Const GW_CHILD = 5

 

At the form load add the mirroring effect as follows

Private Sub Form_Load() 'On Form Load you need to set the mirroring for the controls

Dim OldLong As Long

'For Form

OldLong = GetWindowLong(Me.hwnd, GWL_EXSTYLE)

SetWindowLong Me.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, Null, False

'For List

OldLong = GetWindowLong(List1.hwnd, GWL_EXSTYLE)

SetWindowLong List1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, Null, False

'For The StatusBar

OldLong = GetWindowLong(StatusBar1.hwnd, GWL_EXSTYLE)

SetWindowLong StatusBar1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, Null, False

'For TreeView

Dim nodX As Node

Set nodX = TreeView1.Nodes.Add(, , "R", "Root")

Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")

Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")

Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")

Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")

nodX.EnsureVisible

OldLong = GetWindowLong(TreeView1.hwnd, GWL_EXSTYLE)

SetWindowLong TreeView1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, Null, False

'For ListView

OldLong = GetWindowLong(ListView1.hwnd, GWL_EXSTYLE)

SetWindowLong ListView1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, Null, False

'For ProgressBar

ProgressBar1.Value = 50

OldLong = GetWindowLong(ProgressBar1.hwnd, GWL_EXSTYLE)

SetWindowLong ProgressBar1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, Null, False

'For ToolBar

mhwnd = GetWindow(Toolbar1.hwnd, GW_CHILD)

oldlong = GetWindowLong(mhwnd, GWL_EXSTYLE)

SetWindowLong mhwnd, GWL_EXSTYLE, oldlong Or WS_EX_LAYOUTRTL

InvalidateRect hwnd, 0, False

End Sub


home
 

 

 

1