CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2011
    Posts
    11

    [RESOLVED] WinAPI hidden control in spy++ tool?

    Hey,

    I'm following my previous thread: http://www.codeguru.com/forum/showthread.php?t=516777

    To sum up the other thread: I was trying to automate a program using FindWindow and SendMessage. All is working just fine till I got to my next problem:

    When I'm starting this application: AVI ReComp I only see 2 out of 5 tabs I'm supposed to see using the spy++ tool but when I actually look at the program I see all 5 tabs.

    Weird?

    Wait it gets even weirder...

    When I click on the tab that's not been showing in spy++, when I refresh the windows in spy++ tool it suddenly appears with all its controls.

    Also, the same thing happens when I'm trying to get the handle for that same tab.
    If I put a breakpoint after the program is loaded but before the handle is created and click on the tab before I continue, the handle works fine and gets all the correct values.
    BUT, if I don't the handle is empty.

    What could be the problem?

  2. #2
    Join Date
    Jun 2011
    Posts
    11

    Re: WinAPI hidden control in spy++ tool?

    One more thing, when I switch between the tabs using TCM_SETCURSEL it only shows that it switched the tab but in fact the tab remains the same.

    I've done some research in google and found out that this command doesn't send the WM_NOTIFY command so I need to send it myself right after I call TCM_SETCURSEL.

    So, even after I called the WM_NOTIFY command myself, it still didn't do anything and the tab stayed the same.

    Am I missing something?

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: WinAPI hidden control in spy++ tool?

    Quote Originally Posted by BarrMan View Post
    Am I missing something?
    Yes. You're missing the part where I said you need to use Active Accessibility.

  4. #4
    Join Date
    Jun 2011
    Posts
    11

    Re: WinAPI hidden control in spy++ tool?

    I looked at the documentation of AccessibleObjectFromWindow and I didn't understand the usage of it and what it does and how it could help me with my strange problem.

    Can you elaborate please?

  5. #5
    Join Date
    Jun 2011
    Posts
    11

    Re: WinAPI hidden control in spy++ tool?

    Ok, I finally solved this issue.

    The issue contained 2 problems:
    1. Each tab was created only when a click event occurred on it.
    2. There was no way to switch between the tabs using the regular methods of TCM_SETCURSEL and such.

    The answer to both questions is to generate a click event for each tab you want to use during the program. The click must happen from the tab container (The empty window which has the sys32tabcontrol class) and you must supply the right control coordinates (this can be retrieved from spy++ WM_LBUTTONUP/WM_LBUTTONDOWN events). Finally, use the MakeLParam function to combine the x and y coordinates of the click and insert them as parameters to SendMessage function.

    Here's the code to generate these clicks:

    //Force creation of Additions Tab
    SendMessage(hwnd_tabContainer, WM_LBUTTONDOWN, 0, (IntPtr)MakeParam(120, 10));
    SendMessage(hwnd_tabContainer, WM_LBUTTONUP, 0, (IntPtr)MakeParam(120, 10));

    //Force creation of Settings Tab
    SendMessage(hwnd_tabContainer, WM_LBUTTONDOWN, 0, (IntPtr)MakeParam(210, 10));
    SendMessage(hwnd_tabContainer, WM_LBUTTONUP, 0, (IntPtr)MakeParam(210, 10));

    //Force creation of Queue Tab
    SendMessage(hwnd_tabContainer, WM_LBUTTONDOWN, 0, (IntPtr)MakeParam(270, 10));
    SendMessage(hwnd_tabContainer, WM_LBUTTONUP, 0, (IntPtr)MakeParam(270, 10));

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