I use ES_NUMBER/ES_UPPERCASE/ES_LOWERCASE to force the textbox style.
Can it be un-done ?
I tried Call SendMessage(hWnd, EM_UNDO, 0, ByVal 0&) but this did not work.
In general I have a combo with two options "Numbers only" and "Upper case"
When it is set to the first value - the textbox is set to numbers only.
When I set it to the second (meaning - second time I use em_something) it is
not set to upper case and stays as "Numbers only"
I tried to use EM_UNDO before setting it to the desired case but could not.
Please show the correct way :)
TIA
Guy
To "turn it off", instead of....
style = style Or ES_NUMBER
use...
style = style And Not ES_NUMBER
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..
If you are using "hWnd" alone, then it refers to the Form, use Text1.hWnd
instead. Also, EM_UNDO doesn't undo the last style change. It is equivalent
to pressing Ctrl+z only.
In addition to what Ken suggested, you could turn off all the 3 styles off
before selecting the new one like this:
' Remove the 3 styles first, if you don't know what it was set to before
style = style And Not ES_UPPERCASE
style = style And Not ES_LOWERCASE
style = style And Not ES_NUMBER
' Set the desired style
style = style Or ES_UPPERCASE
"Guy Cohen" <con...@mediatek.co.il> wrote in message
news:O2zb1Cqu...@TK2MSFTNGP10.phx.gbl...
You have received direct answers to your question, so I won't repeat
them here. However, I wonder if you are aware that using the numbers
only option (ES_NUMBER constant) will NOT stop someone from pasting in
non-numeric text into your TextBox. I have some non-API code available
to handle your options if this revelation turns out to be a problem for
you.
Rick
if style AND ES_NUMBER then
style = style XOR ES_NUMBER
end if
call sendmessage ...
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------
"Guy Cohen" <con...@mediatek.co.il> wrote in message
news:O2zb1Cqu...@TK2MSFTNGP10.phx.gbl...
: Hi all,
:
:
I know what I did wrong :)
Logic problem.
Here is the solution:
/////////////////////
Dim L As Long
L = GetWindowLong(hWnd, GWL_STYLE)
If CBool(L And ES_NUMBER) Then
Call SetWindowLong(hWnd, GWL_STYLE, L - ES_NUMBER)
End If
L = GetWindowLong(hWnd, GWL_STYLE)
If CBool(L And ES_UPPERCASE) Then
Call SetWindowLong(hWnd, GWL_STYLE, L - ES_UPPERCASE)
End If
L = GetWindowLong(hWnd, GWL_STYLE)
If CBool(L And ES_LOWERCASE) Then
Call SetWindowLong(hWnd, GWL_STYLE, L - ES_LOWERCASE)
End If
L = GetWindowLong(hWnd, GWL_STYLE)
Select Case venTextStyle
Case enTextStyle.Number
Call SetWindowLong(hWnd, GWL_STYLE, L Or ES_NUMBER)
Case enTextStyle.UpperCase
Call SetWindowLong(hWnd, GWL_STYLE, L Or ES_UPPERCASE)
Case enTextStyle.LowerCase
Call SetWindowLong(hWnd, GWL_STYLE, L Or ES_LOWERCASE)
End Select
/////////////////////
Guy
"Guy Cohen" <con...@mediatek.co.il> wrote in message
news:O2zb1Cqu...@TK2MSFTNGP10.phx.gbl...