Hi
In the app in the What have you tried?
I expect that when I click another
application the language will charge
from Hebrew to English.
But it's not.
But when l come from the another app
to my app the language is changing.
can someone help in this.
Thank you.
What I have tried:
' 120420_2050
' C:\WINDOWS\Microsoft.NET\Framework\v3.5\vbc /target:winexe my_form_120420_1840.vb >> out.txt
'
Option Strict Off
Imports System
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports System.Globalization
Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports System.Diagnostics
Imports System.Drawing
Imports System.Threading
Imports System.Runtime.InteropServices
Module gimatria
Sub Main()
Dim myForm1 As New my_Form1
myForm1.ShowDialog()
myForm1.Dispose()
End Sub
End Module
'<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class my_Form1
Private nwl As MyNativeWindowListener
Dim _englishInput As InputLanguage
Dim _hebrewInput As InputLanguage
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
_englishInput = GetInputLanguageByName("english")
_hebrewInput = GetInputLanguageByName("hebrew")
nwl = New MyNativeWindowListener(Me)
End Sub
Public Shared Function GetInputLanguageByName(ByVal inputName As String) As InputLanguage
Dim lang As InputLanguage
For Each lang In InputLanguage.InstalledInputLanguages
If lang.Culture.EnglishName.ToLower().StartsWith(inputName) Then
Return lang
End If
Next
Return Nothing
End Function
Friend Sub ApplicationActivated(ByVal ApplicationActivated As Boolean)
' The application has been activated or deactivated
If ApplicationActivated = False Then
InputLanguage.CurrentInputLanguage = _englishInput
Me.Text = "Application Active = " + ApplicationActivated.ToString()
ElseIf ApplicationActivated = True Then
InputLanguage.CurrentInputLanguage = _hebrewInput
Me.Text = "Application Active = " + ApplicationActivated.ToString()
End If
End Sub
Private Sub my_Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
InputLanguage.CurrentInputLanguage = _englishInput
End Sub
Private Sub Form1_DoubleClick(sender As Object, e As EventArgs) Handles MyBase.DoubleClick
InputLanguage.CurrentInputLanguage = _englishInput
End Sub
End Class
'-----------------------------------------------------------------------------
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class my_Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.SuspendLayout()
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(515, 253)
Me.Name = "my_Form1"
Me.Text = "my_Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)
End Sub
End Class
'----------------------------------------------------------------------------------------------
' NativeWindow class to listen to operating system messages.
Friend Class MyNativeWindowListener
Inherits NativeWindow
' Constant value was found in the "windows.h" header file.
Private Const WM_ACTIVATEAPP As Integer = &H1C
Private parent As my_Form1
Public Sub New(ByVal parent As my_Form1)
AddHandler parent.HandleCreated, AddressOf Me.OnHandleCreated
AddHandler parent.HandleDestroyed, AddressOf Me.OnHandleDestroyed
Me.parent = parent
End Sub
' Listen for the control's window creation and hook into it.
Private Sub OnHandleCreated(ByVal sender As Object, ByVal e As EventArgs)
' Window is now created, assign handle to NativeWindow.
AssignHandle(CType(sender, Form).Handle)
End Sub
Private Sub OnHandleDestroyed(ByVal sender As Object, ByVal e As EventArgs)
' Window was destroyed, release hook.
ReleaseHandle()
End Sub
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for operating system messages
Select Case (m.Msg)
Case WM_ACTIVATEAPP
' Notify the form that this message was received.
' Application is activated or deactivated,
' based upon the WParam parameter.
parent.ApplicationActivated(m.WParam.ToInt32() <> 0)
End Select
MyBase.WndProc(m)
End Sub
End Class
'----------------------------------------------------------------------------------------------