Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

How do i obtain the text from the search bar that is located in syspro's quotation window.

Hello once again!

Im attempting to master a search query here with syspro, and without having any reference material Ive resorted to the web for help. Im Building a customized Pane, with the pane it pulls Quote num, jobs available, Quotation date, real wip value, and the number of items quoted. I got part of the view working, but what id like to setup is to be able to search for a specific quote number, or quotation date, or even by job Number. I see that Syspro already has a search bar at the top of the page, but im not sure how i would find out whats in it progmatically. is there a handle that is set with the value of the text box? or is it set to do something else and manually refresh all the panes with the data?
0
jnsprad
Asked:
jnsprad
  • 5
  • 4
1 Solution
 
SiddharthRoutCommented:
jnsprad: Hi. I haven't worked with Syspro but yes it is possible to get the handle for any window using VB. You need to use the API for that.

Logic
Use FindWindow API to get the handle of the window using it's caption.

Enumerate Child windows (even textbox is window) and get it's handle.

Sid
0
 
jnspradAuthor Commented:
I understand your api command. But what i dont get is the ยท lpClassName what is that supposed to be? and how would i obtain that information from the other window?  I think your on to something though, if i could get its handle though, Syspro doenst use .net frame work (;-() so i cant use the.text to get the information inside of it... how would i go about reading the handle....the code syspro has is extreemly dull compared to .net.. i cant even use one line to define a variable. in .net i could use
 dim variable as string = "Something"

Open in new window

, in this i have to use:
 
dim varriable
varriable = "anyhting here, string, int, long anything"

Open in new window


just for refference, the code im using to find the windows handle is:
Public Class Form1
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim name As String = FindWindow(, "Job Query")
        Messagebox.show(name)
    End Sub
End Class

Open in new window


 the location of the text bar
0
 
SiddharthRoutCommented:
To start with, change the Type of 'name' from String to Long as that is that FindWindow Returns. Second use vbnullstring. See this code. Does the messagebox return a 'Number'?

Public Class Form1
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button1.Click
        Dim name As Long = FindWindow(vbNullString, "Job Query")
        MessageBox.Show(name)
    End Sub
End Class

Open in new window


Sid
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
jnspradAuthor Commented:
Sorry for the log timed reply, work is getting busy. Your code does return a number. although its not a static number... Changes everytime i click the button
0
 
SiddharthRoutCommented:
>>>Your code does return a number.

That's good :)

>>>Changes everytime i click the button

Yes, It will.

Let me write the next part and post it back. Will be able to do it in the next couple of hours as I am stepping out for sometime :)

Sid
0
 
jnspradAuthor Commented:
bump?
0
 
SiddharthRoutCommented:
jnsprad: Guess I am getting old. Sorry to have missed your thread.

Ok, since I don't have access to SysPro, here is the code that I tried with notepad and it works. You will have to do the rest at your end. However I am sure this will get you started.

Logic: Every Window has a HANDLE. Even menus in a window (Known as Child Windows) have a handle. Once you get the handle of a child window you can do what you want.

Now in your case SysPro has a handle. There are many child windows. The menu where the combobox is parked also has a handle. The combobox (Child Window of menubar) also has it's own handle. So you have to first find the handle of Syspro (ALREADY DONE ABOVE). Then you need to enumerate and get handle of all child windows. One of the child window is the Menubar where combo resides. Once you get the handle of that menu bar you again enumerate through child windows of that menubar and get the handle of the combobox.

The below example will give you the handle of all the child windows. Please note I am testing it with notepad. Please amend the code for syspro.

Hope this helps.

Sid

Code in a Module

Imports System.Runtime.InteropServices

Module Module1
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Public Function FindWindow( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As IntPtr
    End Function

    <DllImport("User32.dll")> _
    Public Function EnumChildWindows _
        (ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, _
        ByVal lParam As IntPtr) As Boolean
    End Function

    Public Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean

    Public Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr()
        Dim ChildrenList As New List(Of IntPtr)
        Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList)
        Try
            EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle))
        Finally
            If ListHandle.IsAllocated Then ListHandle.Free()
        End Try
        Return ChildrenList.ToArray
    End Function

    Private Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean
        Dim ChildrenList As List(Of IntPtr) = GCHandle.FromIntPtr(Parameter).Target
        If ChildrenList Is Nothing Then Throw New Exception("GCHandle Target could not be cast as List(Of IntPtr)")
        ChildrenList.Add(Handle)
        Return True
    End Function
End Module

Open in new window


Code in the Form Area

Public Class Form1
    Dim lpszParentClass As String = "Notepad"
    Dim lpszParentWindow As String = "Untitled - Notepad"

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim name As New IntPtr(0)
        name = FindWindow(lpszParentClass, lpszParentWindow)
        Dim i As Integer
        '~~> This will give you the handle of the main window
        Debug.Print(name)
        Dim childWindows() As IntPtr = GetChildWindows(name)

        '~~> This will give you the handle of all child windows
        For i = 0 To childWindows.Length - 1
            Debug.Print(childWindows(i).ToString)
        Next
    End Sub
End Class

Open in new window

0
 
jnspradAuthor Commented:
I have had Syllogist walk me through the procedure. I wasnt able to successfully able to gather the item due to multiple programming languages being used to produce the application. Ticket closed. Point awarded
0
 
jnspradAuthor Commented:
Can be applied to any other programs as well..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now