CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    May 1999
    Posts
    3,332

    Password entry in ADO datagrid

    I use an ADO Datagrid in my VB 6 app.
    One of the columns should allow the user to enter a password.
    I'd like to use the password functionality of the regular Textbox control which displays "*" for each character entered.
    Does anyone know how to do that in a ADO datagrid?


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Password entry in ADO datagrid

    It sound's a bit tricky, but couldn't you :

    1. Find the hwnd of the edit control used (it's a standard windows 'edit' window)

    2. Change the style of the text control to ES_PASSWORD

    The tricky part would be '1' above, as you'd need to Enum / FindWindow first depending on what column you are in.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3
    Join Date
    May 1999
    Posts
    3,332

    Re: Password entry in ADO datagrid

    Thanks,
    that sounds like it could work.
    Unfortunately it requires much more work and time than I can afford at present.
    Also, I think that the Edit Control is dynamically created and destroyed, whenever you change cells...


  4. #4
    Guest

    Re: Password entry in ADO datagrid

    I know that this is a fudge and I have never used the DATA grid but for now could you not just add another invisible column to the grid and use the keypress event to first of all to add the Chr$(KeyAscii) to the invisible column and then set KeyAscii = 42 whenever a user types in your password column. Then you can do validation against the invisible column.


  5. #5
    Join Date
    May 1999
    Posts
    3,332

    Re: Password entry in ADO datagrid

    not a bad idea, thanks.
    OTOH just trapping keyPress isn't enough. The user might also move the arrow, select text portions with the mouse and so on.
    This sounds even like more work than finding the Edit control.



  6. #6
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Password entry in ADO datagrid

    Why not try and use a self made kind of inputbox whenever the user activates the field. You can use a textfield in it, wich has the passwordchar property. When he presses OK return the value to the hidden field (wich the anonymous person suggested), and display *'s in the visible (dummy) field.

    Tom Cannaerts
    [email protected]

    The best way to escape a problem, is to solve it.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  7. #7
    Join Date
    May 1999
    Posts
    3,332

    Re: Password entry in ADO datagrid

    That sounds like an improvement to Anyonymous's replay.
    Still, I'd have to take scrolling into account. If the user scrolls within the grid, I'll have to move the Input box, too.

    Thanks for your input.


  8. #8
    Join Date
    May 1999
    Posts
    3,332

    Re: Password entry in ADO datagrid

    Chris,
    I've done some "research".
    The datagrid has a hwndEditor property which is the hwnd of the editor window (it's of class "Edit"). It has a valid value as soon as the ColEdit Event is raised.

    Still, I can't set the style to ES_PASSWORD, because - according to the docs - that style cannot be set after the control has been created.
    (SetWindowLong fails).

    Sending EM_PASSWORDCHAR messages works only for controls with the ES_PASSWORD style set.

    I'm stuck.


  9. #9
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Password entry in ADO datagrid

    I'm stuck too

    I remember Matt Hart (http://www.matthart.com), or it might have been Matt Curland (http://www.vbpj.com), writing some code a while back that allowed you to trap (subclass) windows in VB, the moment they were created (some very lowlevel stuff). If you (or I) can find that code, it might be able to help.

    Having said all that, the other 'thread' might be the way to go (using your own textbox control) - I've only ever done this with the flexgrid, and that was quite a bit of work as well.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  10. #10
    Guest

    Re: Password entry in ADO datagrid

    I can't see the problem with scrolling within the grid as the arrow keys are not trapped in the keypress event.
    As for users selecting certain amount of your password field it's not that difficult to have your own pop up menu appear so that they can't cut/copy/paste/delete etc.
    I have to say though that I'm not sure about the windows shortcuts like Ctlr+C etc so that may be a problem.




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