Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-08
10
Medium Priority
?
379 Views
Last Modified: 2012-05-11
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
Comment
Question by:jnsprad
  • 5
  • 4
10 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35078286
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
 
LVL 1

Author Comment

by:jnsprad
ID: 35087701
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
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35087861
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:jnsprad
ID: 35137047
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
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35137139
>>>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
 
LVL 1

Author Comment

by:jnsprad
ID: 35164588
bump?
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 2000 total points
ID: 35166184
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
 
LVL 1

Author Comment

by:jnsprad
ID: 35506164
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
 
LVL 1

Author Closing Comment

by:jnsprad
ID: 35506172
Can be applied to any other programs as well..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question