Results 1 to 12 of 12

Thread: Control handle

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    I need to disable a control on another program. I can call the window and retrieve its handle. How would I get the specific control's handle? Would I then use sendmessage?

    Thanks in advance,
    Wade

  2. #2
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    I hope I can help.

    I found a really neat page today ( the code has a few erros) But if you play with it, it will work. This , After edited will print out every handle of the Window, and all the other Info.
    Try this.. http://support.microsoft.com/support.../Q147/6/59.asp

    And I dont Know the sendmessage command to disable a window.. but I hope that helps some

  3. #3
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    I hope I can help.

    I found a really neat page today ( the code has a few erros) But if you play with it, it will work. This , After edited will print out every handle of the Window, and all the other Info.
    Try this.. http://support.microsoft.com/support.../Q147/6/59.asp

    And I dont Know the sendmessage command to disable a window.. but I hope that helps some

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    The article is for window handles which I already have. I need to get the control handle.

    Anyone else know?

    Thanks.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    The Control is just a Child Window, so you need the Child Windows Handle, you could get this using the FindWindowEx API and look for the specific controls Class, it's really going to be application specific.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    ajyoung@pressenter.com


  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    Aaron,

    If I renum all of the windows and pop a messagebox, I can see all of the class names. Is there anything you can tell me that I should look for when looking for a particular control? Would spy++ be helpful?

    Thanks,
    Wade

  7. #7
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Spy++ would be very useful, it's not much use my giving you a Class name as the App you're looking at could use an entirely different class altogether.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    ajyoung@pressenter.com


  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    Ok, I have the class name thru Spy++, so I can get the control handle. Can I use SendMessage to disable the control?

    Thanks.

  9. #9
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    arghhhhh noooo!! the murky world of subclassing

    yes you probably can.. unless the other app has been coded so the control is always enabled..
    its all a bit dodgy: anyway why do u need to disable the control? isnt there an easier solution to whatever your prob is?

    ------------------
    cintel rules
    www.cintelsoftware.co.uk

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    The control is for the username on a login screen. I need to prevent the user from attempting to login with someone else's name.

    So can I use SendMessage to disable it? Could someone share the syntax?

    Thanks so much,
    Wade

  11. #11
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Once you have the Controls Window Handle you can use the EnableWindow() API, ie.

    Call EnableWindow(lCtrlHwnd, 0) 'Disable Control
    Or..
    Call EnableWindow(lCtrlHwnd, 1) 'Enable Control


    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    ajyoung@pressenter.com


  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    Thanks for the EnableWindow api. I ran Spy++ to get the control's class and it turns out that 2 controls share the same class. Although they have different text values, Spy++ says they both have "" for the caption. What can I do to differentiate the 2 controls?

    Thanks,
    Wade

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