PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Capital letters in Textbox

Reply

Capital letters in Textbox

 
Thread Tools Rate Thread
Old 08-07-2003, 08:49 AM   #1
Kenan
Guest
 
Posts: n/a
Default Capital letters in Textbox


Public Declare Function GetFocus Lib "Coredll" () As
Integer

Public Declare Function GetWindowLong Lib "Coredll"
Alias "GetWindowLongW" (ByVal hwnd As Integer, ByVal
nIndex As Integer) As Integer

Public Declare Function SetWindowLong Lib "Coredll"
Alias "SetWindowLongW" (ByVal hwnd As Integer, ByVal
nIndex As Integer, ByVal dwNewLong As Integer) As Integer

Const GWL_STYLE = -16
Const ES_NUMBER = 8192
Const ES_UPPERCASE = 8
Const ES_LOWERCASE = 16

Public Function EnsureNumeric(ByVal pTextBox As
TextBox, ByVal Force As Boolean)
Dim hWnd As Integer
Dim Style As Integer
Try
pTextBox.Focus()
hWnd = GetFocus

Style = GetWindowLong(hWnd, GWL_STYLE)
If Force Then
Style = Style Or ES_NUMBER
Else
Style = Style And Not ES_NUMBER
End If
SetWindowLong(hWnd, GWL_STYLE, Style)
Catch
End Try
End Function

Public Function EnsureUpperCase(ByVal pTextBox As
TextBox)
Dim hWnd As Integer
Dim Style As Integer

pTextBox.Focus()
hWnd = GetFocus

Style = GetWindowLong(hWnd, GWL_STYLE)
Style = Style Or ES_UPPERCASE
SetWindowLong(hWnd, GWL_STYLE, Style)
End Function




>-----Original Message-----
>Hi
>Does anybody know how to make textbox to display always
>text in capital letters even if Caps Lock is Off. Maybe
>somebody knows how to turn Caps Lock ON programatically.
>
>Thank You for any answer
>
>Jacek
>.
>

  Reply With Quote
Old 08-07-2003, 10:09 AM   #2
Neil Cowburn [MVP]
Guest
 
Posts: n/a
Default Re: Capital letters in Textbox

There's a MUCH simpler way....

In the TextChanged event of the textbox, do something like this:

// Convert Text to upper case
textBox1.Text = textBox1.Text.ToUpper();
// Move cursor to end of Text
textBox1.SelectionStart = textBox1.Text.Length;

HTH
Neil

--
Neil Cowburn
Microsoft Windows Embedded MVP
Content Master Ltd

www.contentmaster.com






"Kenan" <kenanmengu@hotmail.com> wrote in message
news:04d701c3452d$e2964690$a001280a@phx.gbl...
> Public Declare Function GetFocus Lib "Coredll" () As
> Integer
>
> Public Declare Function GetWindowLong Lib "Coredll"
> Alias "GetWindowLongW" (ByVal hwnd As Integer, ByVal
> nIndex As Integer) As Integer
>
> Public Declare Function SetWindowLong Lib "Coredll"
> Alias "SetWindowLongW" (ByVal hwnd As Integer, ByVal
> nIndex As Integer, ByVal dwNewLong As Integer) As Integer
>
> Const GWL_STYLE = -16
> Const ES_NUMBER = 8192
> Const ES_UPPERCASE = 8
> Const ES_LOWERCASE = 16
>
> Public Function EnsureNumeric(ByVal pTextBox As
> TextBox, ByVal Force As Boolean)
> Dim hWnd As Integer
> Dim Style As Integer
> Try
> pTextBox.Focus()
> hWnd = GetFocus
>
> Style = GetWindowLong(hWnd, GWL_STYLE)
> If Force Then
> Style = Style Or ES_NUMBER
> Else
> Style = Style And Not ES_NUMBER
> End If
> SetWindowLong(hWnd, GWL_STYLE, Style)
> Catch
> End Try
> End Function
>
> Public Function EnsureUpperCase(ByVal pTextBox As
> TextBox)
> Dim hWnd As Integer
> Dim Style As Integer
>
> pTextBox.Focus()
> hWnd = GetFocus
>
> Style = GetWindowLong(hWnd, GWL_STYLE)
> Style = Style Or ES_UPPERCASE
> SetWindowLong(hWnd, GWL_STYLE, Style)
> End Function
>
>
>
>
> >-----Original Message-----
> >Hi
> >Does anybody know how to make textbox to display always
> >text in capital letters even if Caps Lock is Off. Maybe
> >somebody knows how to turn Caps Lock ON programatically.
> >
> >Thank You for any answer
> >
> >Jacek
> >.
> >



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off