CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    96

    TextBox's case style

    I know how to set a TextBox to only accept upper/lower case characters by using the SetWindowLong API and changing the ES_UPPERCASE or ES_LOWERCASE styles. My problem is...how do I change the textbox back to "normal" (accept both UCase AND LCase)? Any help is appreciated.

    Thanx,
    Rippin


  2. #2
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    96

    Re: TextBox's case style

    Nevermind, I figured it already. In case anyone else is having this problem, here is the code:


    'Declarations/constants
    '
    Const ES_UPPERCASE = &H8&
    Const ES_LOWERCASE = &H10&
    Const GWL_STYLE = (-16)
    '
    private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (byval hWnd as Long, byval nIndex as Long) as Long
    '
    private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (byval hWnd as Long, byval nIndex as Long, byval dwNewLong as Long) as Long
    '
    '
    'Here's the code.
    '
    Dim lngStyle as Long
    Dim lngReturn as Long
    '
    'get the current style.
    lngStyle = GetWindowLong(Text1.hWnd,GWL_STYLE)
    '
    'Change the style.
    lngStyle = lngStyle Or (ES_UPPERCASE And ES_LOWERCASE)
    '
    'Update the textbox with the new style.
    lngReturn = SetWindowLong(Text1.hWnd,GWL_STYLE,lngStyle)




    Rippin


  3. #3
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    96

    Re: TextBox's case style

    Oops, spoke too soon (as usual). My problem still exists, I only "thought" it worked. The code I showed in my last post actually does nothing (or does something that isn't noticeable). So I thought it was working, until I set a textbox to uppercase only THEN set it back to "normal"...it don't work. Any help is...well , you know.

    Rippin


  4. #4
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: TextBox's case style

    Generally when you combine arguments in API calls, you OR them together instead of AND.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured