none
Win32API.FindWindowByID for a VB Application ControlID returns zero..why? RRS feed

  • Question

  • Hello,

     There are 3 applications as given below

    1. CRM Web application

    2. .Net Asset Maintenance ( C# based) Software

    3.  Inventory Control applicaton developed in VB6.0   

    that I am integrating with AgentDesktop

    I have written three adapters for all the above so that when a new issue is created in CRM web app , it send the "Problem/Issue description" to other apps.  They in turn will use the data and manipulate it.

    The adapter for .Net application works fine. But  the VB6.0  adapter is having issues. Using spy++, I found out the ControlID (Which is 00000008).  Following is the code to populate the textbox in VB app with the data it reccives

    public override bool DoAction(Action action, ref string data)

    {

                if (action.Name == "CreateTicket")
                {
                    IntPtr txtDesc;
                    txtDesc = Win32API.FindWindowByID(this.process.MainWindowHandle, 8);
                    Win32API.SetWindowTextAny(txtDesc, data);
               
                }
                return true;

    }

    The above piece of code doesn't work at all.When I debugged I found Win32API.FindWindowByID function  returns 0 (Zero). Any idea why and how to resolve the same?

    Is it because it is a VB App. Thanks in advance

     

    Wednesday, January 3, 2007 7:46 AM

All replies

  • There's no FindWindowByID API - is that an alias for GetDlgItem? How is it declared?

    Are you sure the control is a direct child control of the main window?

    Wednesday, January 3, 2007 8:11 AM
  • I hope you are aware of CCF/worked on CCF adapters. It is part of Microsoft.Ccf.csr.Win32API assembly. Yes it is  the direct child control(just out of curiosity. how is it different if it is not a direct control)

     

    Thursday, January 4, 2007 3:15 AM
  • Sorry, I missed the fact that you were posting in the CCF forum. I really don't know anything about CCF, but from the name is sure looks like that assembly is just a wrapper for Win32 APIs.

    GetDlgItem (if that's the API being called internally) only looks for direct child controls. If you need a control deeper down in the hierarchy you need multiple calls.

     

    Thursday, January 4, 2007 8:31 AM